httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <b...@wstoddard.com>
Subject [PATCH] mod_mem_cache/PQ segfault
Date Mon, 17 Jun 2002 22:38:33 GMT
This seems to fix the segfault but I do not have a high degree of confidence in the fix.
Some explanation...

1. Moved posn = q->get(d) to -after- cache_pq_pop() because cache_pq_pop() can change the
position of the entry to be deleted in the queue. When this happens, you end up leaving
the wrong entry in the queue and wacking a good entry

2. cache_pq_pop() does not seem to be updating the objects with their correct position in
the queue.

Bill

Index: cache_pqueue.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_pqueue.c,v
retrieving revision 1.2
diff -u -r1.2 cache_pqueue.c
--- cache_pqueue.c 13 Jun 2002 14:40:11 -0000 1.2
+++ cache_pqueue.c 17 Jun 2002 22:30:19 -0000
@@ -177,8 +177,8 @@
     long pri_popped;
     long pri_removed;

-    posn  = q->get(d);
     popped = cache_pq_pop(q);
+    posn  = q->get(d);

     if (!popped)
         return APR_EGENERAL;
@@ -220,11 +220,11 @@
             break;
         }
         q->d[i] = q->d[j];
-        q->set(d, i);
+        q->set(q->d[i], i);
         i = j;
     }
     q->d[i] = tmp;
-    q->set(d, i);
+    q->set(q->d[i], i);
     return d;
 }



Mime
View raw message