https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115067
Revision: 115067
Author: faidon
Date: 2012-04-26 21:36:27 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
Fix a segfault when more than 2 udplog listeners are configured.
Modified Paths:
--------------
trunk/debs/nginx/debian/changelog
trunk/debs/nginx/debian/patches/udplog.diff
trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c
Modified: trunk/debs/nginx/debian/changelog
===================================================================
--- trunk/debs/nginx/debian/changelog 2012-04-26 20:38:53 UTC (rev 115066)
+++ trunk/debs/nginx/debian/changelog 2012-04-26 21:36:27 UTC (rev 115067)
@@ -1,3 +1,9 @@
+nginx (0.7.65-5wmf1) lucid-wikimedia; urgency=low
+
+ * Fix a segfault when more than 2 udplog listeners are configured.
+
+ -- Faidon Liambotis <[email protected]> Thu, 26 Apr 2012 14:35:03 -0700
+
nginx (0.7.65-4wmf1) lucid-wikimedia; urgency=low
* Applying fix for overly long user agents
Modified: trunk/debs/nginx/debian/patches/udplog.diff
===================================================================
--- trunk/debs/nginx/debian/patches/udplog.diff 2012-04-26 20:38:53 UTC (rev
115066)
+++ trunk/debs/nginx/debian/patches/udplog.diff 2012-04-26 21:36:27 UTC (rev
115067)
@@ -109,7 +109,7 @@
+NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_udplog_module.c"
--- /dev/null
+++ b/modules/nginx-udplog/ngx_http_udplog_module.c
-@@ -0,0 +1,682 @@
+@@ -0,0 +1,705 @@
+
+/*
+ * Copyright (C) 2010 Valery Kholodkov
@@ -159,8 +159,8 @@
+} ngx_http_log_main_conf_t;
+
+typedef struct {
-+ ngx_udplog_addr_t peer_addr;
-+ ngx_udp_connection_t *udp_connection;
++ ngx_udplog_addr_t peer_addr;
++ ngx_udp_connection_t *udp_connection;
+} ngx_udp_endpoint_t;
+
+typedef struct {
@@ -525,6 +525,11 @@
+
+ uc = l->udp_connection;
+
++ if (uc == NULL) {
++ /* this should *never* happen! */
++ return NGX_ERROR;
++ }
++
+ if (uc->connection == NULL) {
+ if(ngx_udp_connect(uc) != NGX_OK) {
+ return NGX_ERROR;
@@ -621,22 +626,40 @@
+{
+ ngx_http_udplog_main_conf_t *umcf;
+ ngx_udp_endpoint_t *endpoint;
++ ngx_udp_endpoint_t **e;
+
++ /* allocate a new endpoint from the pool and initialize it */
++#if defined nginx_version && nginx_version >= 7003
++ endpoint = ngx_pnalloc(cf->pool, sizeof(ngx_udp_endpoint_t));
++#else
++ endpoint = ngx_palloc(cf->pool, sizeof(ngx_udp_endpoint_t));
++#endif
++ if (endpoint == NULL) {
++ return NULL;
++ }
++
++ endpoint->peer_addr = *peer_addr;
++
++ /* save the pointer to this endpoint to an array, so that it can be
++ * enumerated on the endpoint initialization phase.
++ *
++ * Note that we can't use an array directly, since it may be relocated at
++ * any point and hence all pointers to its elements readdressed
++ */
+ umcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_udplog_module);
+
+ if(umcf->endpoints == NULL) {
-+ umcf->endpoints = ngx_array_create(cf->pool, 2,
sizeof(ngx_udp_endpoint_t));
++ umcf->endpoints = ngx_array_create(cf->pool, 2,
sizeof(ngx_udp_endpoint_t *));
+ if (umcf->endpoints == NULL) {
+ return NULL;
+ }
+ }
-+
-+ endpoint = ngx_array_push(umcf->endpoints);
-+ if (endpoint == NULL) {
++ e = ngx_array_push(umcf->endpoints);
++ if (e == NULL) {
+ return NULL;
+ }
+
-+ endpoint->peer_addr = *peer_addr;
++ *e = endpoint;
+
+ return endpoint;
+}
@@ -726,7 +749,7 @@
+
+ log->endpoint = ngx_http_udplog_add_endpoint(cf, &u.addrs[0]);
+
-+ if(log->endpoint == NULL) {
++ if (log->endpoint == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
@@ -766,14 +789,14 @@
+ ngx_http_core_main_conf_t *cmcf;
+ ngx_http_udplog_main_conf_t *umcf;
+ ngx_http_handler_pt *h;
-+ ngx_udp_endpoint_t *e;
++ ngx_udp_endpoint_t **e;
+
+ umcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_udplog_module);
+
+ if(umcf->endpoints != NULL) {
+ e = umcf->endpoints->elts;
+ for(i = 0;i < umcf->endpoints->nelts;i++) {
-+ rc = ngx_udplog_init_endpoint(cf, e + i);
++ rc = ngx_udplog_init_endpoint(cf, e[i]);
+
+ if(rc != NGX_OK) {
+ return NGX_ERROR;
Modified: trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c
===================================================================
--- trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c
2012-04-26 20:38:53 UTC (rev 115066)
+++ trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c
2012-04-26 21:36:27 UTC (rev 115067)
@@ -47,8 +47,8 @@
} ngx_http_log_main_conf_t;
typedef struct {
- ngx_udplog_addr_t peer_addr;
- ngx_udp_connection_t *udp_connection;
+ ngx_udplog_addr_t peer_addr;
+ ngx_udp_connection_t *udp_connection;
} ngx_udp_endpoint_t;
typedef struct {
@@ -413,6 +413,11 @@
uc = l->udp_connection;
+ if (uc == NULL) {
+ /* this should *never* happen! */
+ return NGX_ERROR;
+ }
+
if (uc->connection == NULL) {
if(ngx_udp_connect(uc) != NGX_OK) {
return NGX_ERROR;
@@ -509,22 +514,40 @@
{
ngx_http_udplog_main_conf_t *umcf;
ngx_udp_endpoint_t *endpoint;
+ ngx_udp_endpoint_t **e;
+ /* allocate a new endpoint from the pool and initialize it */
+#if defined nginx_version && nginx_version >= 7003
+ endpoint = ngx_pnalloc(cf->pool, sizeof(ngx_udp_endpoint_t));
+#else
+ endpoint = ngx_palloc(cf->pool, sizeof(ngx_udp_endpoint_t));
+#endif
+ if (endpoint == NULL) {
+ return NULL;
+ }
+
+ endpoint->peer_addr = *peer_addr;
+
+ /* save the pointer to this endpoint to an array, so that it can be
+ * enumerated on the endpoint initialization phase.
+ *
+ * Note that we can't use an array directly, since it may be relocated at
+ * any point and hence all pointers to its elements readdressed
+ */
umcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_udplog_module);
if(umcf->endpoints == NULL) {
- umcf->endpoints = ngx_array_create(cf->pool, 2,
sizeof(ngx_udp_endpoint_t));
+ umcf->endpoints = ngx_array_create(cf->pool, 2,
sizeof(ngx_udp_endpoint_t *));
if (umcf->endpoints == NULL) {
return NULL;
}
}
-
- endpoint = ngx_array_push(umcf->endpoints);
- if (endpoint == NULL) {
+ e = ngx_array_push(umcf->endpoints);
+ if (e == NULL) {
return NULL;
}
- endpoint->peer_addr = *peer_addr;
+ *e = endpoint;
return endpoint;
}
@@ -614,7 +637,7 @@
log->endpoint = ngx_http_udplog_add_endpoint(cf, &u.addrs[0]);
- if(log->endpoint == NULL) {
+ if (log->endpoint == NULL) {
return NGX_CONF_ERROR;
}
@@ -654,14 +677,14 @@
ngx_http_core_main_conf_t *cmcf;
ngx_http_udplog_main_conf_t *umcf;
ngx_http_handler_pt *h;
- ngx_udp_endpoint_t *e;
+ ngx_udp_endpoint_t **e;
umcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_udplog_module);
if(umcf->endpoints != NULL) {
e = umcf->endpoints->elts;
for(i = 0;i < umcf->endpoints->nelts;i++) {
- rc = ngx_udplog_init_endpoint(cf, e + i);
+ rc = ngx_udplog_init_endpoint(cf, e[i]);
if(rc != NGX_OK) {
return NGX_ERROR;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs