]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
file_open() is entirely blocking now -- there is no need for the
authorwessels <>
Wed, 26 May 1999 23:07:56 +0000 (23:07 +0000)
committerwessels <>
Wed, 26 May 1999 23:07:56 +0000 (23:07 +0000)
callback function arguments.

src/access_log.cc
src/disk.cc
src/errorpage.cc
src/mime.cc
src/protos.h
src/send-announce.cc
src/store_log.cc
src/tools.cc
src/useragent.cc

index 346e26bc1b4dbe2d8672b3d979fffece50559263..9acc98853cbf4624b6e1789d79ea3012a2af2378 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: access_log.cc,v 1.50 1999/04/23 02:57:16 wessels Exp $
+ * $Id: access_log.cc,v 1.51 1999/05/26 17:07:56 wessels Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -216,7 +216,7 @@ accessLogOpen(const char *fname)
 {
     assert(fname);
     xstrncpy(LogfileName, fname, SQUID_MAXPATHLEN);
-    LogfileFD = file_open(LogfileName, O_WRONLY | O_CREAT, NULL, NULL, NULL);
+    LogfileFD = file_open(LogfileName, O_WRONLY | O_CREAT);
     if (LogfileFD == DISK_ERROR) {
        debug(50, 0) ("%s: %s\n", LogfileName, xstrerror());
        fatalf("Cannot open %s: %s", LogfileName, xstrerror());
@@ -323,7 +323,7 @@ accessLogRotate(void)
        rename(fname, to);
     }
     /* Reopen the log.  It may have been renamed "manually" */
-    LogfileFD = file_open(fname, O_WRONLY | O_CREAT, NULL, NULL, NULL);
+    LogfileFD = file_open(fname, O_WRONLY | O_CREAT);
     if (LogfileFD == DISK_ERROR) {
        debug(46, 0) ("accessLogRotate: Cannot open logfile: %s\n", fname);
        LogfileStatus = LOG_DISABLE;
index 78c8be106e0cec27e33a138e8f13f2e411ac09f3..b6782ba2f2794d1c09af98a63771047ecd3531eb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.cc,v 1.145 1999/05/04 19:22:24 wessels Exp $
+ * $Id: disk.cc,v 1.146 1999/05/26 17:07:57 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
 
 #include "squid.h"
 
-#define DISK_LINE_LEN  1024
-
-typedef struct open_ctrl_t {
-    FOCB *callback;
-    void *callback_data;
-    char *path;
-} open_ctrl_t;
-
 static PF diskHandleRead;
 static PF diskHandleWrite;
 
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_)
+static int
+diskWriteIsComplete(int fd)
+{
+    return fd_table[fd].disk.write_q ? 0 : 1;
+}
+#endif
+
 void
 disk_init(void)
 {
     (void) 0;
 }
 
-/* Open a disk file. Return a file descriptor */
+/*
+ * opens a disk file specified by 'path'.  This function always
+ * blocks!  There is no callback.
+ */
 int
-file_open(const char *path, int mode, FOCB * callback, void *callback_data, void *tag)
+file_open(const char *path, int mode)
 {
     int fd;
     if (mode & O_WRONLY)
        mode |= O_APPEND;
     mode |= SQUID_NONBLOCK;
-    /* Open file */
     errno = 0;
     fd = open(path, mode, 0644);
     Counter.syscalls.disk.opens++;
@@ -73,8 +75,6 @@ file_open(const char *path, int mode, FOCB * callback, void *callback_data, void
        commSetCloseOnExec(fd);
        fd_open(fd, FD_FILE, path);
     }
-    if (callback)
-       callback(callback_data, fd, errno);
     return fd;
 }
 
@@ -393,9 +393,3 @@ file_read(int fd, char *buf, int req_len, off_t offset, DRCB * handler, void *cl
     cbdataLock(client_data);
     diskHandleRead(fd, ctrl_dat);
 }
-
-int
-diskWriteIsComplete(int fd)
-{
-    return fd_table[fd].disk.write_q ? 0 : 1;
-}
index fd6c610d1189d949e28fb6d8f2803b3378e5d65c..e951a0434d66fb95fb54c740536ef1a983c59a84 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.149 1999/04/23 02:57:21 wessels Exp $
+ * $Id: errorpage.cc,v 1.150 1999/05/26 17:07:58 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -171,7 +171,7 @@ errorTryLoadText(const char *page_name, const char *dir)
     char *text;
 
     snprintf(path, sizeof(path), "%s/%s", dir, page_name);
-    fd = file_open(path, O_RDONLY, NULL, NULL, NULL);
+    fd = file_open(path, O_RDONLY);
     if (fd < 0 || fstat(fd, &sb) < 0) {
        debug(4, 0) ("errorTryLoadText: '%s': %s\n", path, xstrerror());
        if (fd >= 0)
index ec3226955c8fab9d8d7298d26a31d637e14adb8d..26430fa59574187a935ce739e77ebd9748726b36 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.88 1999/05/26 04:57:46 wessels Exp $
+ * $Id: mime.cc,v 1.89 1999/05/26 17:07:59 wessels Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -401,7 +401,7 @@ mimeLoadIconFile(const char *icon)
     if (storeGetPublic(url, METHOD_GET))
        return;
     snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon);
-    fd = file_open(path, O_RDONLY, NULL, NULL, NULL);
+    fd = file_open(path, O_RDONLY);
     if (fd < 0) {
        debug(25, 0) ("mimeLoadIconFile: %s: %s\n", path, xstrerror());
        return;
index 82bd69ba8d082d0dc91d28eaaf9d9b666f5de1e3..c6d3ed37eab2b37de7a884ed8ee39804ba65be8b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.334 1999/05/26 06:48:06 wessels Exp $
+ * $Id: protos.h,v 1.335 1999/05/26 17:08:00 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -209,13 +209,12 @@ extern void xassert(const char *, const char *, int);
 extern void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
 
 
-extern int file_open(const char *path, int mode, FOCB *, void *callback_data, void *tag);
+extern int file_open(const char *path, int mode);
 extern void file_close(int fd);
 extern void file_write(int, off_t, void *, int len, DWCB *, void *, FREE *);
 extern void file_write_mbuf(int fd, off_t, MemBuf mb, DWCB * handler, void *handler_data);
 extern void file_read(int, char *, int, off_t, DRCB *, void *);
 extern void disk_init(void);
-extern int diskWriteIsComplete(int);
 
 extern void dnsShutdown(void);
 extern void dnsInit(void);
index 15eeeee784f6b83d506a744e3a2ef3092f145806..9822a3370f1336f288ddac1df3eee43b8f1cace1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: send-announce.cc,v 1.55 1998/12/05 00:54:38 wessels Exp $
+ * $Id: send-announce.cc,v 1.56 1999/05/26 17:08:02 wessels Exp $
  *
  * DEBUG: section 27    Cache Announcer
  * AUTHOR: Duane Wessels
@@ -88,7 +88,7 @@ send_announce(const ipcache_addrs * ia, void *junk)
     strcat(sndbuf, tbuf);
     l = strlen(sndbuf);
     if ((file = Config.Announce.file) != NULL) {
-       fd = file_open(file, O_RDONLY, NULL, NULL, NULL);
+       fd = file_open(file, O_RDONLY);
        if (fd > -1 && (n = read(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) {
            fd_bytes(fd, n, FD_READ);
            l += n;
index 88311074210b520aef376f4c5a76c072cdc5eed0..d1bbc1a4694558c238bc2c0303683d80e8ca40c1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_log.cc,v 1.6 1998/07/22 20:54:02 wessels Exp $
+ * $Id: store_log.cc,v 1.7 1999/05/26 17:08:04 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager Logging Functions
  * AUTHOR: Duane Wessels
@@ -118,7 +118,7 @@ storeLogRotate(void)
        snprintf(to, MAXPATHLEN, "%s.%d", fname, 0);
        rename(fname, to);
     }
-    storelog_fd = file_open(fname, O_WRONLY | O_CREAT, NULL, NULL, NULL);
+    storelog_fd = file_open(fname, O_WRONLY | O_CREAT);
     if (storelog_fd < 0) {
        debug(50, 0) ("storeLogRotate: %s: %s\n", fname, xstrerror());
        debug(20, 1) ("Store logging disabled\n");
@@ -138,11 +138,7 @@ storeLogOpen(void)
     if (strcmp(Config.Log.store, "none") == 0)
        storelog_fd = -1;
     else
-       storelog_fd = file_open(Config.Log.store,
-           O_WRONLY | O_CREAT,
-           NULL,
-           NULL,
-           NULL);
+       storelog_fd = file_open(Config.Log.store, O_WRONLY | O_CREAT);
     if (storelog_fd < 0)
        debug(20, 1) ("Store logging disabled\n");
 }
index 2254daf9ff199a543f086e8ba7dd282a4604a4a3..58bba472f8cf6f24d681886a36dabd7711438502 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.180 1999/05/25 06:53:53 wessels Exp $
+ * $Id: tools.cc,v 1.181 1999/05/26 17:08:05 wessels Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -548,7 +548,7 @@ writePidFile(void)
        return;
     enter_suid();
     old_umask = umask(022);
-    fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC, NULL, NULL, NULL);
+    fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC);
     umask(old_umask);
     leave_suid();
     if (fd < 0) {
index eb6b6e459e4a648ea175fd39d0191255a3b9eeaf..d21942bb3e0e56e03a1fdd11d0af9ea16613b16b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: useragent.cc,v 1.16 1999/01/29 18:31:18 wessels Exp $
+ * $Id: useragent.cc,v 1.17 1999/05/26 17:08:06 wessels Exp $
  *
  * DEBUG: section 40    User-Agent logging
  * AUTHOR: Joe Ramey <ramey@csc.ti.com>
@@ -50,7 +50,7 @@ useragentOpenLog(void)
        cache_useragent_log = NULL;
     }
     if (fname && strcmp(fname, "none") != 0) {
-       log_fd = file_open(fname, O_WRONLY | O_CREAT | O_APPEND, NULL, NULL, NULL);
+       log_fd = file_open(fname, O_WRONLY | O_CREAT | O_APPEND);
        if (log_fd < 0) {
            debug(50, 0) ("useragentOpenLog: %s: %s\n", fname, xstrerror());
        } else if ((cache_useragent_log = fdopen(log_fd, "a")) == NULL) {