]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 8 Oct 2010 03:42:54 +0000 (21:42 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 8 Oct 2010 03:42:54 +0000 (21:42 -0600)
Bug 3056: comm.cc "!fd_table[fd].closing()" assertion from helperServerFree when a helper crashes while processing requests

reshuffle helperServerFree so it first unregisters the failed helper
and starts new ones if needed before it calls the callbacks on any
pending requests. If not those ends up resheduling the request on
this same crashed and partially shut down helper.

src/helper.cc

index 269fb3d0a769071d78d176b920daea802e9d7888..d503de31fa9a27b921428e0f6bd8cfaa8b2827e4 100644 (file)
@@ -720,21 +720,6 @@ helperServerFree(int fd, void *data)
         srv->writebuf = NULL;
     }
 
-    for (i = 0; i < concurrency; i++) {
-        if ((r = srv->requests[i])) {
-            void *cbdata;
-
-            if (cbdataReferenceValidDone(r->data, &cbdata))
-                r->callback(cbdata, NULL);
-
-            helperRequestFree(r);
-
-            srv->requests[i] = NULL;
-        }
-    }
-
-    safe_free(srv->requests);
-
     if (srv->wfd != srv->rfd && srv->wfd != -1)
         comm_close(srv->wfd);
 
@@ -762,6 +747,20 @@ helperServerFree(int fd, void *data)
         }
     }
 
+    for (i = 0; i < concurrency; i++) {
+        if ((r = srv->requests[i])) {
+            void *cbdata;
+
+            if (cbdataReferenceValidDone(r->data, &cbdata))
+                r->callback(cbdata, NULL);
+
+            helperRequestFree(r);
+
+            srv->requests[i] = NULL;
+        }
+    }
+    safe_free(srv->requests);
+
     cbdataReferenceDone(srv->parent);
     cbdataFree(srv);
 }
@@ -785,17 +784,6 @@ helperStatefulServerFree(int fd, void *data)
 
 #endif
 
-    if ((r = srv->request)) {
-        void *cbdata;
-
-        if (cbdataReferenceValidDone(r->data, &cbdata))
-            r->callback(cbdata, srv, NULL);
-
-        helperStatefulRequestFree(r);
-
-        srv->request = NULL;
-    }
-
     /* TODO: walk the local queue of requests and carry them all out */
     if (srv->wfd != srv->rfd && srv->wfd != -1)
         comm_close(srv->wfd);
@@ -823,6 +811,17 @@ helperStatefulServerFree(int fd, void *data)
         }
     }
 
+    if ((r = srv->request)) {
+        void *cbdata;
+
+        if (cbdataReferenceValidDone(r->data, &cbdata))
+            r->callback(cbdata, srv, NULL);
+
+        helperStatefulRequestFree(r);
+
+        srv->request = NULL;
+    }
+
     if (srv->data != NULL)
         hlp->datapool->free(srv->data);