Skip to content

Commit

Permalink
addr cache with http_server_coro
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jun 19, 2023
1 parent cc0a257 commit 3af3a27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ext-src/swoole_http_server_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,14 @@ static PHP_METHOD(swoole_http_server_coro, onAccept) {
zval *zserver = ctx->request.zserver;
add_assoc_long(zserver, "server_port", hs->socket->get_bind_port());
add_assoc_long(zserver, "remote_port", (zend_long) sock->get_port());
add_assoc_string(zserver, "remote_addr", (char *) sock->get_ip());

if (!ctx->addr_cache) {
auto addr = sock->get_ip();
ctx->addr_cache = zend_string_init(addr, strlen(addr), 0);
}
zval tmp;
ZVAL_STR_COPY(&tmp, ctx->addr_cache);
zend_hash_str_add(Z_ARRVAL_P(zserver), ZEND_STRL("remote_addr"), &tmp);

zend_fcall_info_cache *fci_cache = hs->get_handler(ctx);
zval args[2] = {*ctx->request.zobject, *ctx->response.zobject};
Expand Down

0 comments on commit 3af3a27

Please sign in to comment.