Mercurial > hg > ngx_http_upstream_keepalive
comparison ngx_http_upstream_keepalive_module.c @ 29:c7c4b2d68fdf
Keepalive: set_session and save_session callbacks.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 30 Aug 2011 14:30:58 +0400 |
parents | baf671881a8d |
children | c5b498c5aa3c |
comparison
equal
deleted
inserted
replaced
28:baf671881a8d | 29:c7c4b2d68fdf |
---|---|
29 | 29 |
30 void *data; | 30 void *data; |
31 | 31 |
32 ngx_event_get_peer_pt original_get_peer; | 32 ngx_event_get_peer_pt original_get_peer; |
33 ngx_event_free_peer_pt original_free_peer; | 33 ngx_event_free_peer_pt original_free_peer; |
34 | |
35 #if (NGX_HTTP_SSL) | |
36 ngx_event_set_peer_session_pt original_set_session; | |
37 ngx_event_save_peer_session_pt original_save_session; | |
38 #endif | |
34 | 39 |
35 ngx_uint_t failed; /* unsigned:1 */ | 40 ngx_uint_t failed; /* unsigned:1 */ |
36 | 41 |
37 } ngx_http_upstream_keepalive_peer_data_t; | 42 } ngx_http_upstream_keepalive_peer_data_t; |
38 | 43 |
56 static void ngx_http_upstream_free_keepalive_peer(ngx_peer_connection_t *pc, | 61 static void ngx_http_upstream_free_keepalive_peer(ngx_peer_connection_t *pc, |
57 void *data, ngx_uint_t state); | 62 void *data, ngx_uint_t state); |
58 | 63 |
59 static void ngx_http_upstream_keepalive_dummy_handler(ngx_event_t *ev); | 64 static void ngx_http_upstream_keepalive_dummy_handler(ngx_event_t *ev); |
60 static void ngx_http_upstream_keepalive_close_handler(ngx_event_t *ev); | 65 static void ngx_http_upstream_keepalive_close_handler(ngx_event_t *ev); |
66 | |
67 #if (NGX_HTTP_SSL) | |
68 static ngx_int_t ngx_http_upstream_keepalive_set_session( | |
69 ngx_peer_connection_t *pc, void *data); | |
70 static void ngx_http_upstream_keepalive_save_session(ngx_peer_connection_t *pc, | |
71 void *data); | |
72 #endif | |
61 | 73 |
62 static void *ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf); | 74 static void *ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf); |
63 static char *ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, | 75 static char *ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, |
64 void *conf); | 76 void *conf); |
65 | 77 |
180 | 192 |
181 r->upstream->peer.data = kp; | 193 r->upstream->peer.data = kp; |
182 r->upstream->peer.get = ngx_http_upstream_get_keepalive_peer; | 194 r->upstream->peer.get = ngx_http_upstream_get_keepalive_peer; |
183 r->upstream->peer.free = ngx_http_upstream_free_keepalive_peer; | 195 r->upstream->peer.free = ngx_http_upstream_free_keepalive_peer; |
184 | 196 |
197 #if (NGX_HTTP_SSL) | |
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; | |
202 #endif | |
203 | |
185 return NGX_OK; | 204 return NGX_OK; |
186 } | 205 } |
187 | 206 |
188 | 207 |
189 static ngx_int_t | 208 static ngx_int_t |
427 ngx_close_connection(item->connection); | 446 ngx_close_connection(item->connection); |
428 ngx_queue_insert_head(&conf->free, &item->queue); | 447 ngx_queue_insert_head(&conf->free, &item->queue); |
429 } | 448 } |
430 | 449 |
431 | 450 |
451 #if (NGX_HTTP_SSL) | |
452 | |
453 static ngx_int_t | |
454 ngx_http_upstream_keepalive_set_session(ngx_peer_connection_t *pc, void *data) | |
455 { | |
456 ngx_http_upstream_keepalive_peer_data_t *kp = data; | |
457 | |
458 return kp->original_set_session(pc, kp->data); | |
459 } | |
460 | |
461 | |
462 static void | |
463 ngx_http_upstream_keepalive_save_session(ngx_peer_connection_t *pc, void *data) | |
464 { | |
465 ngx_http_upstream_keepalive_peer_data_t *kp = data; | |
466 | |
467 kp->original_save_session(pc, kp->data); | |
468 return; | |
469 } | |
470 | |
471 #endif | |
472 | |
473 | |
432 static void * | 474 static void * |
433 ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf) | 475 ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf) |
434 { | 476 { |
435 ngx_http_upstream_keepalive_srv_conf_t *conf; | 477 ngx_http_upstream_keepalive_srv_conf_t *conf; |
436 | 478 |