Repository navigation
Tags
Tags
bugfix: stash peer data in module ctx to survive upstream wrappers. (#52 ) Since nginx 1.29.7 (commit 4fbe4b62, "Upstream: enabled keepalive by default for explicit upstreams.") the standard upstream keepalive module implicitly wraps every explicit upstream in "local" keepalive mode. Its init_peer overwrites r->upstream->peer.data with its own ~64-byte ngx_http_upstream_keepalive_peer_data_t after our init_peer returns. Our event handlers (ngx_http_drizzle_set_libdrizzle_ready, ngx_http_drizzle_process_events, set_thread_id_variable, and the output_* helpers) re-read r->upstream->peer.data and cast it back to ngx_http_upstream_drizzle_peer_data_t (~9256 bytes). With the keepalive wrapper in place, dp->drizzle_con reads past the end of the wrapper struct and returns garbage; dereferencing it segfaults the worker, e.g. ngx_http_drizzle_set_libdrizzle_ready (...drizzle_handler.c:389) dc->options |= DRIZZLE_CON_IO_READY; // dc == 0x21 Save the original drizzle peer-data pointer in the module ctx in init_peer, and add a small helper ngx_http_drizzle_get_peer_data() that returns the ctx-saved pointer (falling back to peer.data when no ctx is set). All consumers that previously read u->peer.data now go through the helper. The ngx_http_drizzle_ctx_t struct is now defined for all nginx versions (it was previously only built for nginx_version < 8017). While here, replace the ngx_http_upstream_drizzle_is_my_peer() probe in process_events with a NULL check on dp; the old probe compared peer->get against ngx_http_upstream_drizzle_get_peer and would always report a non-drizzle backend once the keepalive wrapper installs its own get function.
feature: fixed compilation issues with new nginx cores >= 1.11.6. the default_port declaration was removed in this commit: http://hg.nginx.org/nginx/rev/4dea01cf49e8 Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
PreviousNext