diff -ru squid-3.1.8-orig/src/helper.cc squid-3.1.8/src/helper.cc --- squid-3.1.8-orig/src/helper.cc 2010-10-05 10:27:40.000000000 +1000 +++ squid-3.1.8/src/helper.cc 2010-10-05 10:46:38.000000000 +1000 @@ -728,21 +728,6 @@ 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); @@ -770,6 +755,20 @@ } } + 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); } @@ -793,17 +792,6 @@ #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); @@ -831,6 +819,17 @@ } } + 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);