36 ngx_event_set_peer_session_pt original_set_session;
37 ngx_event_save_peer_session_pt original_save_session;
62 static void ngx_http_upstream_keepalive_dummy_handler(
ngx_event_t *ev);
63 static void ngx_http_upstream_keepalive_close_handler(
ngx_event_t *ev);
68 static ngx_int_t ngx_http_upstream_keepalive_set_session(
74 static void *ngx_http_upstream_keepalive_create_conf(
ngx_conf_t *cf);
79 static ngx_command_t ngx_http_upstream_keepalive_commands[] = {
83 ngx_http_upstream_keepalive,
99 ngx_http_upstream_keepalive_create_conf,
109 &ngx_http_upstream_keepalive_module_ctx,
110 ngx_http_upstream_keepalive_commands,
124 ngx_http_upstream_init_keepalive(
ngx_conf_t *cf,
135 ngx_http_upstream_keepalive_module);
143 us->
peer.
init = ngx_http_upstream_init_keepalive_peer;
149 if (cached == NULL) {
158 cached[
i].
conf = kcf;
173 "init keepalive peer");
176 ngx_http_upstream_keepalive_module);
198 kp->original_set_session = r->
upstream->
peer.set_session;
199 kp->original_save_session = r->
upstream->
peer.save_session;
200 r->
upstream->
peer.set_session = ngx_http_upstream_keepalive_set_session;
201 r->
upstream->
peer.save_session = ngx_http_upstream_keepalive_save_session;
219 "get keepalive peer");
248 "get keepalive peer: using connection %p", c);
279 "free keepalive peer");
306 "free keepalive peer: saving connection %p", c);
315 ngx_http_upstream_keepalive_close(item->
connection);
336 c->
write->
handler = ngx_http_upstream_keepalive_dummy_handler;
337 c->
read->
handler = ngx_http_upstream_keepalive_close_handler;
350 ngx_http_upstream_keepalive_close_handler(c->
read);
360 ngx_http_upstream_keepalive_dummy_handler(
ngx_event_t *ev)
363 "keepalive dummy handler");
368 ngx_http_upstream_keepalive_close_handler(
ngx_event_t *ev)
378 "keepalive close handler");
386 n = recv(c->
fd, buf, 1, MSG_PEEK);
403 ngx_http_upstream_keepalive_close(c);
417 c->ssl->no_wait_shutdown = 1;
418 c->ssl->no_send_shutdown = 1;
421 c->ssl->handler = ngx_http_upstream_keepalive_close;
440 return kp->original_set_session(pc, kp->
data);
449 kp->original_save_session(pc, kp->
data);
457 ngx_http_upstream_keepalive_create_conf(
ngx_conf_t *cf)
493 ngx_http_upstream_keepalive_module);
496 return "is duplicate";
509 n =
ngx_atoi(value[1].data, value[1].len);
513 "invalid value \"%V\" in \"%V\" directive",
514 &value[1], &cmd->
name);
522 if (
ngx_strcmp(value[i].data,
"single") == 0) {
524 "the \"single\" parameter is deprecated");
536 "invalid parameter \"%V\"", &value[i]);