forked from Hakase/nginx-build
Latest update - 7340
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@
|
||||
<p>Sorry, the page you are looking for is currently unavailable.<br/>
|
||||
Please try again later.</p>
|
||||
<p>If you are the system administrator of this resource then you should check
|
||||
the <a href="http://nginx.org/r/error_log">error log</a> for details.</p>
|
||||
the error log for details.</p>
|
||||
<p><em>Faithfully yours, nginx.</em></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -36,8 +36,12 @@
|
||||
|
||||
#if (defined LIBRESSL_VERSION_NUMBER && OPENSSL_VERSION_NUMBER == 0x20000000L)
|
||||
#undef OPENSSL_VERSION_NUMBER
|
||||
#if (LIBRESSL_VERSION_NUMBER >= 0x2080000fL)
|
||||
#define OPENSSL_VERSION_NUMBER 0x1010000fL
|
||||
#else
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000107fL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x10100001L)
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
typedef struct {
|
||||
ngx_uint_t max_cached;
|
||||
ngx_uint_t requests;
|
||||
ngx_msec_t timeout;
|
||||
|
||||
ngx_queue_t cache;
|
||||
ngx_queue_t free;
|
||||
@@ -84,6 +86,20 @@ static ngx_command_t ngx_http_upstream_keepalive_commands[] = {
|
||||
0,
|
||||
NULL },
|
||||
|
||||
{ ngx_string("keepalive_timeout"),
|
||||
NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_msec_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_upstream_keepalive_srv_conf_t, timeout),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("keepalive_requests"),
|
||||
NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_num_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_upstream_keepalive_srv_conf_t, requests),
|
||||
NULL },
|
||||
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
@@ -133,6 +149,9 @@ ngx_http_upstream_init_keepalive(ngx_conf_t *cf,
|
||||
kcf = ngx_http_conf_upstream_srv_conf(us,
|
||||
ngx_http_upstream_keepalive_module);
|
||||
|
||||
ngx_conf_init_msec_value(kcf->timeout, 60000);
|
||||
ngx_conf_init_uint_value(kcf->requests, 100);
|
||||
|
||||
if (kcf->original_init_upstream(cf, us) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@@ -261,6 +280,10 @@ found:
|
||||
c->write->log = pc->log;
|
||||
c->pool->log = pc->log;
|
||||
|
||||
if (c->read->timer_set) {
|
||||
ngx_del_timer(c->read);
|
||||
}
|
||||
|
||||
pc->connection = c;
|
||||
pc->cached = 1;
|
||||
|
||||
@@ -298,6 +321,10 @@ ngx_http_upstream_free_keepalive_peer(ngx_peer_connection_t *pc, void *data,
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (c->requests >= kp->conf->requests) {
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (!u->keepalive) {
|
||||
goto invalid;
|
||||
}
|
||||
@@ -339,10 +366,9 @@ ngx_http_upstream_free_keepalive_peer(ngx_peer_connection_t *pc, void *data,
|
||||
|
||||
pc->connection = NULL;
|
||||
|
||||
if (c->read->timer_set) {
|
||||
c->read->delayed = 0;
|
||||
ngx_del_timer(c->read);
|
||||
}
|
||||
c->read->delayed = 0;
|
||||
ngx_add_timer(c->read, kp->conf->timeout);
|
||||
|
||||
if (c->write->timer_set) {
|
||||
ngx_del_timer(c->write);
|
||||
}
|
||||
@@ -393,7 +419,7 @@ ngx_http_upstream_keepalive_close_handler(ngx_event_t *ev)
|
||||
|
||||
c = ev->data;
|
||||
|
||||
if (c->close) {
|
||||
if (c->close || c->read->timedout) {
|
||||
goto close;
|
||||
}
|
||||
|
||||
@@ -486,6 +512,9 @@ ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf)
|
||||
* conf->max_cached = 0;
|
||||
*/
|
||||
|
||||
conf->timeout = NGX_CONF_UNSET_MSEC;
|
||||
conf->requests = NGX_CONF_UNSET_UINT;
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
@@ -518,6 +547,8 @@ ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
kcf->max_cached = n;
|
||||
|
||||
/* init upstream handler */
|
||||
|
||||
uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module);
|
||||
|
||||
kcf->original_init_upstream = uscf->peer.init_upstream
|
||||
|
||||
@@ -1546,6 +1546,8 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
|
||||
c = u->peer.connection;
|
||||
|
||||
c->requests++;
|
||||
|
||||
c->data = r;
|
||||
|
||||
c->write->handler = ngx_http_upstream_handler;
|
||||
|
||||
Reference in New Issue
Block a user