]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix NULL pointer access with asyncio when Squid starts up over the disk
authorwessels <>
Wed, 24 May 2006 00:24:41 +0000 (00:24 +0000)
committerwessels <>
Wed, 24 May 2006 00:24:41 +0000 (00:24 +0000)
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.

src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
src/DiskIO/DiskThreads/aiops.cc

index 8b333f134052a85f64705d86e9c6bcc176690fad..701631f84b24e765c7a3af3033ac418acfc3bdb7 100644 (file)
@@ -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;
 }
index fad9fa57631a6eeedca9261f4c7a64c4e3fa8dea..3938012f63e4d61986c32d8f7757192ebb9c0308 100644 (file)
@@ -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
index c8c72f906ac705b066a271ce7f4560c4d3bedea4..8507de608e8da19c4071b57c771a98a056b7aee3 100644 (file)
@@ -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 <slf@connect.com.au>
@@ -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();