]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
storeDirWriteCleanLogs() could abort the procedure if file_open()
authorwessels <>
Fri, 1 Dec 2000 03:08:47 +0000 (03:08 +0000)
committerwessels <>
Fri, 1 Dec 2000 03:08:47 +0000 (03:08 +0000)
fails, leaking various structures including repl walkers.

src/fs/aufs/store_dir_aufs.cc
src/fs/coss/store_dir_coss.cc
src/fs/diskd/store_dir_diskd.cc
src/fs/ufs/store_dir_ufs.cc

index da1169045cf62c498e901f37e9f8149e06f1b4f3..999187f830ed3fab2a75a1e12e5dd3a9d691fe70 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_aufs.cc,v 1.17 2000/11/30 20:07:32 wessels Exp $
+ * $Id: store_dir_aufs.cc,v 1.18 2000/11/30 20:08:47 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -971,6 +971,11 @@ storeAufsDirWriteCleanStart(SwapDir * sd)
     struct stat sb;
     sd->log.clean.write = NULL;
     sd->log.clean.state = NULL;
+    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
+    if (state->fd < 0) {
+       xfree(state);
+       return -1;
+    }
     state->cur = xstrdup(storeAufsDirSwapLogFile(sd, NULL));
     state->new = xstrdup(storeAufsDirSwapLogFile(sd, ".clean"));
     state->cln = xstrdup(storeAufsDirSwapLogFile(sd, ".last-clean"));
@@ -979,9 +984,6 @@ storeAufsDirWriteCleanStart(SwapDir * sd)
     state->walker = sd->repl->WalkInit(sd->repl);
     unlink(state->new);
     unlink(state->cln);
-    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
-    if (state->fd < 0)
-       return -1;
     debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n",
        state->new, state->fd);
 #if HAVE_FCHMOD
index 29ab53e34911c0cdc309d9ad0d49944bcedfc8fa..1c1943e950832ec8d75d5e10dce30847af10df2e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.9 2000/11/02 18:34:48 wessels Exp $
+ * $Id: store_dir_coss.cc,v 1.10 2000/11/30 20:08:50 wessels Exp $
  *
  * DEBUG: section 81    Store COSS Directory Routines
  * AUTHOR: Eric Stern
@@ -467,6 +467,11 @@ storeCossDirWriteCleanStart(SwapDir * sd)
     CossInfo *cs = (CossInfo *) sd->fsdata;
     struct _clean_state *state = xcalloc(1, sizeof(*state));
     struct stat sb;
+    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
+    if (state->fd < 0) {
+       xfree(state);
+       return -1;
+    }
     sd->log.clean.write = NULL;
     sd->log.clean.state = NULL;
     state->cur = xstrdup(storeCossDirSwapLogFile(sd, NULL));
@@ -476,9 +481,6 @@ storeCossDirWriteCleanStart(SwapDir * sd)
     state->outbuf_offset = 0;
     unlink(state->new);
     unlink(state->cln);
-    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
-    if (state->fd < 0)
-       return -1;
     state->current = cs->index.tail;
     debug(20, 3) ("storeCOssDirWriteCleanLogs: opened %s, FD %d\n",
        state->new, state->fd);
index 427b309d91cc3b53e2f86a9d85b7fa74141cf675..c0b36eadba0f483905b92d5f25cac0cdf8950533 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_diskd.cc,v 1.25 2000/11/30 20:07:32 wessels Exp $
+ * $Id: store_dir_diskd.cc,v 1.26 2000/11/30 20:08:50 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -1162,6 +1162,11 @@ storeDiskdDirWriteCleanStart(SwapDir * sd)
     struct stat sb;
     sd->log.clean.write = NULL;
     sd->log.clean.state = NULL;
+    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
+    if (state->fd < 0) {
+       xfree(state);
+       return -1;
+    }
     state->cur = xstrdup(storeDiskdDirSwapLogFile(sd, NULL));
     state->new = xstrdup(storeDiskdDirSwapLogFile(sd, ".clean"));
     state->cln = xstrdup(storeDiskdDirSwapLogFile(sd, ".last-clean"));
index 945ff7e13ddf9a475ae6edde40ca27c236ee6339..cf80edace6a3362ef39b4b63517d76131ad07f89 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.15 2000/11/30 20:07:33 wessels Exp $
+ * $Id: store_dir_ufs.cc,v 1.16 2000/11/30 20:08:51 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -969,6 +969,11 @@ storeUfsDirWriteCleanStart(SwapDir * sd)
     struct stat sb;
     sd->log.clean.write = NULL;
     sd->log.clean.state = NULL;
+    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
+    if (state->fd < 0) {
+       xfree(state);
+       return -1;
+    }
     state->cur = xstrdup(storeUfsDirSwapLogFile(sd, NULL));
     state->new = xstrdup(storeUfsDirSwapLogFile(sd, ".clean"));
     state->cln = xstrdup(storeUfsDirSwapLogFile(sd, ".last-clean"));
@@ -977,9 +982,6 @@ storeUfsDirWriteCleanStart(SwapDir * sd)
     state->walker = sd->repl->WalkInit(sd->repl);
     unlink(state->new);
     unlink(state->cln);
-    state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
-    if (state->fd < 0)
-       return -1;              /* state not free'd - possible leak */
     debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n",
        state->new, state->fd);
 #if HAVE_FCHMOD