Router: More accurately allocate request buffer memory.
In nxt_router_prepare_msg() we create a buffer (nxt_unit_request_t *req)
that gets sent to an application process that contains details about a
client request.
This buffer was always a little larger than needed due to allocating space
for the remote address _and_ port and the local address _and_ port. We
also allocate space for the local port separately.
->{local,remote}->length includes the port number and ':' and also the
'[]' for IPv6. E.g [2001:db8::1]:8080
->{local,remote}->address_length represents the length of the unadorned
IP address. E.g 2001:db8::1
Update the buffer size so that we only allocate what is actually needed.
Suggested-by: Zhidao HONG <z.hong@f5.com>
Cc: Zhidao HONG <z.hong@f5.com>
Reviewed-by: Zhidao HONG <z.hong@f5.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
This commit is contained in:
@@ -5206,8 +5206,8 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_http_request_t *r,
|
||||
req_size = sizeof(nxt_unit_request_t)
|
||||
+ r->method->length + 1
|
||||
+ r->version.length + 1
|
||||
+ r->remote->length + 1
|
||||
+ r->local->length + 1
|
||||
+ r->remote->address_length + 1
|
||||
+ r->local->address_length + 1
|
||||
+ nxt_sockaddr_port_length(r->local) + 1
|
||||
+ r->server_name.length + 1
|
||||
+ r->target.length + 1
|
||||
|
||||
Reference in New Issue
Block a user