From: wessels <> Date: Wed, 26 May 1999 23:07:56 +0000 (+0000) Subject: file_open() is entirely blocking now -- there is no need for the X-Git-Tag: SQUID_3_0_PRE1~2169 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a94f598855923ee6e66f352d03b861f279ca0cd;p=thirdparty%2Fsquid.git file_open() is entirely blocking now -- there is no need for the callback function arguments. --- diff --git a/src/access_log.cc b/src/access_log.cc index 346e26bc1b..9acc98853c 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -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; diff --git a/src/disk.cc b/src/disk.cc index 78c8be106e..b6782ba2f2 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -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 @@ -35,32 +35,34 @@ #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; -} diff --git a/src/errorpage.cc b/src/errorpage.cc index fd6c610d11..e951a0434d 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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) diff --git a/src/mime.cc b/src/mime.cc index ec3226955c..26430fa595 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -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; diff --git a/src/protos.h b/src/protos.h index 82bd69ba8d..c6d3ed37ea 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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); diff --git a/src/send-announce.cc b/src/send-announce.cc index 15eeeee784..9822a3370f 100644 --- a/src/send-announce.cc +++ b/src/send-announce.cc @@ -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; diff --git a/src/store_log.cc b/src/store_log.cc index 8831107421..d1bbc1a469 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -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"); } diff --git a/src/tools.cc b/src/tools.cc index 2254daf9ff..58bba472f8 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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) { diff --git a/src/useragent.cc b/src/useragent.cc index eb6b6e459e..d21942bb3e 100644 --- a/src/useragent.cc +++ b/src/useragent.cc @@ -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 @@ -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) {