]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4999, r5003: detect duplicate "events" and "keepalive".
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 11 Feb 2013 14:58:25 +0000 (14:58 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 11 Feb 2013 14:58:25 +0000 (14:58 +0000)
*) Upstream keepalive: detect duplicate "keepalive" directive.  A
   failure to detect duplicate "keepalive" directive resulted in
   stack exhaustion.

*) Events: added check for duplicate "events" directive.

src/event/ngx_event.c
src/http/modules/ngx_http_upstream_keepalive_module.c

index 976bd646581caa3db7603e9d3cb818b00d2e4098..cbae0ee6ad79517743d3fa5728fc8eccb53613ae 100644 (file)
@@ -892,6 +892,10 @@ ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ngx_conf_t            pcf;
     ngx_event_module_t   *m;
 
+    if (*(void **) conf) {
+        return "is duplicate";
+    }
+
     /* count the number of the event modules and set up their indices */
 
     ngx_event_max_module = 0;
index d10e3d016cb071794520f5f55c48e8f2d0aa69b2..a2ad5aa8d952f401df615fd79edb8fa56cb35a27 100644 (file)
@@ -502,6 +502,10 @@ ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     kcf = ngx_http_conf_upstream_srv_conf(uscf,
                                           ngx_http_upstream_keepalive_module);
 
+    if (kcf->original_init_upstream) {
+        return "is duplicate";
+    }
+
     kcf->original_init_upstream = uscf->peer.init_upstream
                                   ? uscf->peer.init_upstream
                                   : ngx_http_upstream_init_round_robin;