Remove unused codes in ngx_http_upstream_connect
Maxim Dounin
mdounin at mdounin.ru
Thu Apr 20 14:58:27 UTC 2023
Hello!
On Thu, Apr 20, 2023 at 02:24:53PM +0000, meng lynch wrote:
> Hello guys,
>
> Should the code from line 1517 to 1519 be removed? Because u->state is reallocated in line 1521.
>
> 1509 static void
> 1510 ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
> 1511 {
> 1512 ngx_int_t rc;
> 1513 ngx_connection_t *c;
> 1514
> 1515 r->connection->log->action = "connecting to upstream";
> 1516
> - 1517 if (u->state && u->state->response_time == (ngx_msec_t) -1) {
> - 1518 u->state->response_time = ngx_current_msec - u->start_time;
> - 1519 }
> 1520
> 1521 u->state = ngx_array_push(r->upstream_states);
> 1522 if (u->state == NULL) {
> 1523 ngx_http_upstream_finalize_request(r, u,
> 1524 NGX_HTTP_INTERNAL_SERVER_ERROR);
> 1525 return;
> 1526 }
>
In line 1521, the new state is allocated - the one which will be
used for the connection started with this
ngx_http_upstream_connect() call.
The code in lines 1517..1519 finalizes the previous state, the one
created by the previous connection (if any).
So no, this code shouldn't be removed, it is actually used.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list