]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
more compiler fixes
authorwessels <>
Wed, 2 Apr 1997 12:22:14 +0000 (12:22 +0000)
committerwessels <>
Wed, 2 Apr 1997 12:22:14 +0000 (12:22 +0000)
src/squid.h
src/store.cc
src/store_dir.cc

index 795d3eab3cfbaefd68b92c9343be2c6174f8d4da..849c34a76a977a160013b5a9fbc4c040f1e370e3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.102 1997/04/02 04:39:58 wessels Exp $
+ * $Id: squid.h,v 1.103 1997/04/02 05:22:14 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -233,7 +233,7 @@ typedef struct _aclCheck_t aclCheck_t;
 typedef struct _request request_t;
 typedef struct _MemObject MemObject;
 typedef struct _cachemgr_passwd cachemgr_passwd;
-typedef struct _filemap fileMap;
+typedef struct _fileMap fileMap;
 
 /* 32 bit integer compatability hack */
 #if SIZEOF_INT == 4
index 8b34f77342f7f2a8f764e466c822f2b55f6067fa..5aac7d34a033250cb478b13a51138ffc436c23f3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.216 1997/04/02 04:39:59 wessels Exp $
+ * $Id: store.cc,v 1.217 1997/04/02 05:22:15 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -317,7 +317,6 @@ static int swapfileno = 0;
 static int store_swap_size = 0;        /* kilobytes !! */
 static int store_swap_high = 0;
 static int store_swap_low = 0;
-static int swaplog_fd = -1;
 static int storelog_fd = -1;
 
 /* key temp buffer */
@@ -496,30 +495,6 @@ storeSetMemStatus(StoreEntry * e, mem_status_t status)
 
 /* -------------------------------------------------------------------------- */
 
-#ifdef OLD_CODE
-static char *
-time_describe(time_t t)
-{
-    LOCAL_ARRAY(char, buf, 128);
-    if (t < 60) {
-       sprintf(buf, "%ds", (int) t);
-    } else if (t < 3600) {
-       sprintf(buf, "%dm", (int) t / 60);
-    } else if (t < 86400) {
-       sprintf(buf, "%dh", (int) t / 3600);
-    } else if (t < 604800) {
-       sprintf(buf, "%dD", (int) t / 86400);
-    } else if (t < 2592000) {
-       sprintf(buf, "%dW", (int) t / 604800);
-    } else if (t < 31536000) {
-       sprintf(buf, "%dM", (int) t / 2592000);
-    } else {
-       sprintf(buf, "%dY", (int) t / 31536000);
-    }
-    return buf;
-}
-#endif
-
 static void
 storeLog(int tag, const StoreEntry * e)
 {
@@ -1234,26 +1209,6 @@ storeSwapInStartComplete(void *data, int fd)
     xfree(ctrlp);
 }
 
-static void
-storeSwapLog(const StoreEntry * e)
-{
-    LOCAL_ARRAY(char, logmsg, MAX_URL << 1);
-    /* Note this printf format appears in storeWriteCleanLog() too */
-    sprintf(logmsg, "%08x %08x %08x %08x %9d %s\n",
-       (int) e->swap_file_number,
-       (int) e->timestamp,
-       (int) e->expires,
-       (int) e->lastmod,
-       e->object_len,
-       e->url);
-    file_write(swaplog_fd,
-       xstrdup(logmsg),
-       strlen(logmsg),
-       NULL,
-       NULL,
-       xfree);
-}
-
 static void
 storeSwapOutHandle(int fd, int flag, StoreEntry * e)
 {
@@ -2509,16 +2464,7 @@ storeInit(void)
     if (ncache_dirs < 1)
        fatal("No cache_dir's specified in config file");
     dir_created = storeVerifySwapDirs();
-    if (Config.Log.swap)
-       xstrncpy(swaplog_file, Config.Log.swap, SQUID_MAXPATHLEN);
-    else
-       sprintf(swaplog_file, "%s/log", storeSwapDir(0));
-    swaplog_fd = file_open(swaplog_file, NULL, O_WRONLY | O_CREAT, NULL, NULL);
-    debug(20, 3, "swaplog_fd %d is now '%s'\n", swaplog_fd, swaplog_file);
-    if (swaplog_fd < 0) {
-       sprintf(tmp_error_buf, "Cannot open swap logfile: %s", swaplog_file);
-       fatal(tmp_error_buf);
-    }
+
     if (!opt_zap_disk_store)
        storeStartRebuildFromDisk();
     else
index 280cb746d600fcd431483287387ea36645c10ca5..f31f319640f2d0a0b122fb3d8e59562bd0b2a2a9 100644 (file)
@@ -195,3 +195,63 @@ storeSwapDir(int dirn)
        fatal_dump("storeSwapDir: bad index");
     return SwapDirs[dirn].path;
 }
+
+void
+storeDirSwapLog(const StoreEntry * e)
+{
+    LOCAL_ARRAY(char, logmsg, MAX_URL << 1);
+    int dirn;
+    if (e->swap_file_number < 0)
+       fatal_dump("storeDirSwapLog: swap_file_number < 0");
+    dirn = e->swap_file_number >> SWAP_DIR_SHIFT;
+    /* Note this printf format appears in storeWriteCleanLog() too */
+    sprintf(logmsg, "%08x %08x %08x %08x %9d %s\n",
+        (int) e->swap_file_number,
+        (int) e->timestamp,
+        (int) e->expires,
+        (int) e->lastmod,
+        e->object_len,
+        e->url);
+    file_write(SwapDirs[dirn].swaplog_fd,
+        xstrdup(logmsg),
+        strlen(logmsg),
+        NULL,
+        NULL,
+        xfree);
+}
+
+static char *
+storeDirSwapLogFile(int dirn)
+{
+    LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN);
+    LOCAL_ARRAY(char, digit, 32);
+    if (Config.Log.swap) {
+       xstrncpy(path, Config.Log.swap, SQUID_MAXPATHLEN - 64);
+       strcat(path, ".");
+       sprintf(digit, "%02d", dirn);
+       strncat(path, digit, 32);
+    } else {
+       xstrncpy(path, storeSwapDir(dirn), SQUID_MAXPATHLEN - 64);
+       strcat(path, "/log");
+    }
+    return path;
+}
+
+void
+storeDirOpenSwapLogs(void)
+{
+    int i;
+    int fd;
+    char *path;
+    SwapDir *SD;
+    for (i = 0; i < ncache_dirs; i++) {
+       SD = &SwapDirs[i];
+       path = storeDirSwapLogFile(i);
+       fd = file_open(path, NULL, O_WRONLY | O_CREAT, NULL, NULL);
+       if (fd < 0) {
+           debug(50, 1, "%s: %s\n", path, xstrerror());
+           fatal("storeDirOpenSwapLogs: Failed to open swap log.");
+       }
+       SD->swaplog_fd = fd;
+    }
+}