From: wessels <> Date: Wed, 24 May 2006 00:24:41 +0000 (+0000) Subject: Fix NULL pointer access with asyncio when Squid starts up over the disk X-Git-Tag: SQUID_3_0_PRE4~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e65c313fd9eb710ddca93cb5f092299db0edd7eb;p=thirdparty%2Fsquid.git Fix NULL pointer access with asyncio when Squid starts up over the disk space limit. We used to call squidaio_init() from DiskThreadsDiskFile::operator new. But this only gets called when opening a file. If the first transaction is to unlink a file, squidaio will be uninitialized. I didn't see any other good places to call squidaio_init(). For now I am calling it from within the squidaio module itself at the start of each open, unlink/truncate, and stat call. --- diff --git a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc index 8b333f1340..701631f84b 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskThreadsDiskFile.cc,v 1.5 2005/04/01 21:11:28 serassio Exp $ + * $Id: DiskThreadsDiskFile.cc,v 1.6 2006/05/23 18:24:41 wessels Exp $ * * DEBUG: section 79 Disk IO Routines * AUTHOR: Robert Collins @@ -51,7 +51,11 @@ DiskThreadsDiskFile::operator new (size_t) { CBDATA_INIT_TYPE(DiskThreadsDiskFile); DiskThreadsDiskFile *result = cbdataAlloc(DiskThreadsDiskFile); - squidaio_init(); + /* + * We used to call squidaio_init() here, but if the first transaction + * is to unlink a file (e.g., if Squid starts up over the disk space + * limit) then "squidaio" won't be initialized yet. + */ return result; } diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc index fad9fa5763..3938012f63 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskThreadsIOStrategy.cc,v 1.4 2005/09/25 21:02:32 hno Exp $ + * $Id: DiskThreadsIOStrategy.cc,v 1.5 2006/05/23 18:24:41 wessels Exp $ * * DEBUG: section 79 Squid-side Disk I/O functions. * AUTHOR: Robert Collins @@ -56,6 +56,12 @@ DiskThreadsIOStrategy::init(void) aioStats, 0, 1); initialised = true; + + /* + * We'd like to call squidaio_init() here, but the configuration + * hasn't been parsed yet and we don't know how many cache_dirs + * there are, which means we don't know how many threads to start. + */ } void diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index c8c72f906a..8507de608e 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -1,5 +1,5 @@ /* - * $Id: aiops.cc,v 1.8 2006/05/15 13:39:57 hno Exp $ + * $Id: aiops.cc,v 1.9 2006/05/23 18:24:41 wessels Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -685,6 +685,7 @@ squidaio_cancel(squidaio_result_t * resultp) int squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resultp) { + squidaio_init(); squidaio_request_t *requestp; requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); @@ -831,6 +832,7 @@ int squidaio_stat(const char *path, struct stat *sb, squidaio_result_t * resultp) { + squidaio_init(); squidaio_request_t *requestp; requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); @@ -867,6 +869,7 @@ squidaio_do_stat(squidaio_request_t * requestp) int squidaio_truncate(const char *path, off_t length, squidaio_result_t * resultp) { + squidaio_init(); squidaio_request_t *requestp; requestp = (squidaio_request_t *)squidaio_request_pool->alloc(); @@ -901,6 +904,7 @@ squidaio_do_truncate(squidaio_request_t * requestp) int squidaio_unlink(const char *path, squidaio_result_t * resultp) { + squidaio_init(); squidaio_request_t *requestp; requestp = (squidaio_request_t *)squidaio_request_pool->alloc();