comparison src/core/ngx_connection.c @ 8510:532fe796b0e2 quic

Merged with the default branch.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 18 Aug 2020 16:22:00 +0300
parents 0d2b2664b41c 5440ff4ac6fc
children 13f7085b90d2
comparison
equal deleted inserted replaced
8509:bce9e9643444 8510:532fe796b0e2
1111 "but only %ui files are available", 1111 "but only %ui files are available",
1112 s, ngx_cycle->files_n); 1112 s, ngx_cycle->files_n);
1113 return NULL; 1113 return NULL;
1114 } 1114 }
1115 1115
1116 ngx_drain_connections((ngx_cycle_t *) ngx_cycle);
1117
1116 c = ngx_cycle->free_connections; 1118 c = ngx_cycle->free_connections;
1117
1118 if (c == NULL) {
1119 ngx_drain_connections((ngx_cycle_t *) ngx_cycle);
1120 c = ngx_cycle->free_connections;
1121 }
1122 1119
1123 if (c == NULL) { 1120 if (c == NULL) {
1124 ngx_log_error(NGX_LOG_ALERT, log, 0, 1121 ngx_log_error(NGX_LOG_ALERT, log, 0,
1125 "%ui worker_connections are not enough", 1122 "%ui worker_connections are not enough",
1126 ngx_cycle->connection_n); 1123 ngx_cycle->connection_n);
1301 ngx_drain_connections(ngx_cycle_t *cycle) 1298 ngx_drain_connections(ngx_cycle_t *cycle)
1302 { 1299 {
1303 ngx_uint_t i, n; 1300 ngx_uint_t i, n;
1304 ngx_queue_t *q; 1301 ngx_queue_t *q;
1305 ngx_connection_t *c; 1302 ngx_connection_t *c;
1303
1304 if (cycle->free_connection_n > cycle->connection_n / 16
1305 || cycle->reusable_connections_n == 0)
1306 {
1307 return;
1308 }
1309
1310 if (cycle->connections_reuse_time != ngx_time()) {
1311 cycle->connections_reuse_time = ngx_time();
1312
1313 ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
1314 "%ui worker_connections are not enough, "
1315 "reusing connections",
1316 cycle->connection_n);
1317 }
1306 1318
1307 n = ngx_max(ngx_min(32, cycle->reusable_connections_n / 8), 1); 1319 n = ngx_max(ngx_min(32, cycle->reusable_connections_n / 8), 1);
1308 1320
1309 for (i = 0; i < n; i++) { 1321 for (i = 0; i < n; i++) {
1310 if (ngx_queue_empty(&cycle->reusable_connections_queue)) { 1322 if (ngx_queue_empty(&cycle->reusable_connections_queue)) {