Browse Source

Fix node corruption bug while cleaning uploads

When we clean a node, we ask nginx to free the memory. On some
platform or no load there were great chance the memory wasn't
reused for something else.
With high load and on FreeBSD, the memory seems to be reused
immediatly and we jump in the middle of f*****g nowhere, and
we crash.

Thanks to Vladimir Getmanshchuk for his bug report.

Signed-off-by: Brice Figureau <brice@daysofwonder.com>
tags/v0.6
Brice Figureau 16 years ago
parent
commit
3bb396e3dc
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      ngx_http_uploadprogress_module.c

+ 3
- 2
ngx_http_uploadprogress_module.c View File

@@ -798,7 +798,7 @@ ngx_clean_old_connections(ngx_event_t * ev)
798 798
     ngx_http_uploadprogress_ctx_t   *ctx;
799 799
     ngx_slab_pool_t                 *shpool;
800 800
     ngx_rbtree_node_t               *node;
801
-    ngx_http_uploadprogress_node_t  *up;
801
+    ngx_http_uploadprogress_node_t  *up, *upprev;
802 802
     time_t                           now = ngx_time();
803 803
     int                              count = 0;
804 804
 
@@ -821,6 +821,7 @@ ngx_clean_old_connections(ngx_event_t * ev)
821 821
         }
822 822
 
823 823
         up = (ngx_http_uploadprogress_node_t *) node;
824
+        upprev = up->prev;
824 825
 
825 826
         ngx_log_debug3(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
826 827
                        "uploadprogress clean: scanning %08XD (req done %ui) timeout at %T",
@@ -839,7 +840,7 @@ ngx_clean_old_connections(ngx_event_t * ev)
839 840
         }
840 841
         else
841 842
             count++;
842
-        node = (ngx_rbtree_node_t *) up->prev;
843
+        node = (ngx_rbtree_node_t *) upprev;
843 844
     }
844 845
 
845 846
     ngx_log_debug3(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,

Loading…
Cancel
Save