comparison src/core/ngx_connection.c @ 8704:13f7085b90d2 quic

Merged with the default branch.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 17 Feb 2021 14:48:35 +0300
parents 532fe796b0e2 6d98f29867e8
children 6674a50cbb6c
comparison
equal deleted inserted replaced
8703:d710c457171c 8704:13f7085b90d2
1314 "%ui worker_connections are not enough, " 1314 "%ui worker_connections are not enough, "
1315 "reusing connections", 1315 "reusing connections",
1316 cycle->connection_n); 1316 cycle->connection_n);
1317 } 1317 }
1318 1318
1319 c = NULL;
1319 n = ngx_max(ngx_min(32, cycle->reusable_connections_n / 8), 1); 1320 n = ngx_max(ngx_min(32, cycle->reusable_connections_n / 8), 1);
1320 1321
1321 for (i = 0; i < n; i++) { 1322 for (i = 0; i < n; i++) {
1322 if (ngx_queue_empty(&cycle->reusable_connections_queue)) { 1323 if (ngx_queue_empty(&cycle->reusable_connections_queue)) {
1323 break; 1324 break;
1326 q = ngx_queue_last(&cycle->reusable_connections_queue); 1327 q = ngx_queue_last(&cycle->reusable_connections_queue);
1327 c = ngx_queue_data(q, ngx_connection_t, queue); 1328 c = ngx_queue_data(q, ngx_connection_t, queue);
1328 1329
1329 ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0, 1330 ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0,
1330 "reusing connection"); 1331 "reusing connection");
1332
1333 c->close = 1;
1334 c->read->handler(c->read);
1335 }
1336
1337 if (cycle->free_connection_n == 0 && c && c->reusable) {
1338
1339 /*
1340 * if no connections were freed, try to reuse the last
1341 * connection again: this should free it as long as
1342 * previous reuse moved it to lingering close
1343 */
1344
1345 ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0,
1346 "reusing connection again");
1331 1347
1332 c->close = 1; 1348 c->close = 1;
1333 c->read->handler(c->read); 1349 c->read->handler(c->read);
1334 } 1350 }
1335 } 1351 }