]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
changed struct _fde->open to _fde->flags.open to save a few bytes
authorwessels <>
Tue, 12 Jan 1999 23:42:15 +0000 (23:42 +0000)
committerwessels <>
Tue, 12 Jan 1999 23:42:15 +0000 (23:42 +0000)
src/comm.cc
src/comm_select.cc
src/disk.cc
src/dns.cc
src/enums.h
src/fd.cc
src/stat.cc
src/structs.h

index 0176d1a83ef348667e00d74f7eb9a638d65465ff..04e30007fb1a444d879c0902532e58227cd06592 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.296 1999/01/11 22:46:16 wessels Exp $
+ * $Id: comm.cc,v 1.297 1999/01/12 16:42:15 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -107,7 +107,7 @@ comm_local_port(int fd)
     fde *F = &fd_table[fd];
 
     /* If the fd is closed already, just return */
-    if (!F->open) {
+    if (!F->flags.open) {
        debug(5, 0) ("comm_local_port: FD %d has been closed.\n", fd);
        return 0;
     }
@@ -398,7 +398,7 @@ commSetTimeout(int fd, int timeout, PF * handler, void *data)
     assert(fd >= 0);
     assert(fd < Squid_MaxFD);
     F = &fd_table[fd];
-    assert(F->open);
+    assert(F->flags.open);
     if (timeout < 0) {
        F->timeout_handler = NULL;
        F->timeout_data = NULL;
@@ -580,13 +580,13 @@ comm_close(int fd)
     F = &fd_table[fd];
     if (F->flags.closing)
        return;
-    if (shutting_down && (!F->open || F->type == FD_FILE))
+    if (shutting_down && (!F->flags.open || F->type == FD_FILE))
        return;
     if (fd == current_hdl_fd) {
        F->flags.delayed_comm_close = 1;
        return;
     }
-    assert(F->open);
+    assert(F->flags.open);
     assert(F->type != FD_FILE);
 #ifdef USE_ASYNC_IO
     if (F->flags.nolinger && F->flags.nonblocking)
@@ -653,7 +653,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t
 {
     fde *F = &fd_table[fd];
     assert(fd >= 0);
-    assert(F->open == FD_OPEN);
+    assert(F->flags.open);
     debug(5, 5) ("commSetSelect: FD %d type %d\n", fd, type);
     if (type & COMM_SELECT_READ) {
        F->read_handler = handler;
@@ -916,7 +916,7 @@ commCloseAllSockets(void)
     PF *callback;
     for (fd = 0; fd <= Biggest_FD; fd++) {
        F = &fd_table[fd];
-       if (F->open != FD_OPEN)
+       if (!F->flags.open)
            continue;
        if (F->type != FD_SOCKET)
            continue;
index e06c9ca0e7bb8e482f64199185e5d76fb043ba20..4aca4009017151df9008eb0ee57fe406dff95790 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_select.cc,v 1.25 1999/01/11 19:40:29 wessels Exp $
+ * $Id: comm_select.cc,v 1.26 1999/01/12 16:42:15 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -825,7 +825,7 @@ checkTimeouts(void)
     PF *callback;
     for (fd = 0; fd <= Biggest_FD; fd++) {
        F = &fd_table[fd];
-       if (F->open != FD_OPEN)
+       if (!F->flags.open)
            continue;
        if (F->timeout == 0)
            continue;
index 24d30683bf17021912925d6625eefa69039baa6a..fba591851740301d7415c4fdfd053cf8dce5a182 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: disk.cc,v 1.137 1998/12/05 00:54:21 wessels Exp $
+ * $Id: disk.cc,v 1.138 1999/01/12 16:42:16 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -137,7 +137,7 @@ file_close(int fd)
 #else
     assert(fd >= 0);
 #endif
-    assert(F->open);
+    assert(F->flags.open);
     if ((callback = F->read_handler)) {
        F->read_handler = NULL;
        callback(-1, F->read_data);
@@ -399,7 +399,7 @@ file_write(int fd,
     dwrite_q *wq = NULL;
     fde *F = &fd_table[fd];
     assert(fd >= 0);
-    assert(F->open);
+    assert(F->flags.open);
     /* if we got here. Caller is eligible to write. */
     wq = xcalloc(1, sizeof(dwrite_q));
     wq->file_offset = file_offset;
index 1e888a511c55e32478a7568355c51914c04d703b..6a5f3d5c410483cade9626388938e8151af01a04 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns.cc,v 1.72 1998/11/12 06:28:03 wessels Exp $
+ * $Id: dns.cc,v 1.73 1999/01/12 16:42:17 wessels Exp $
  *
  * DEBUG: section 34    Dnsserver interface
  * AUTHOR: Harvest Derived
@@ -54,7 +54,7 @@ dnsInit(void)
     if (dnsservers == NULL)
        dnsservers = helperCreate("dnsserver");
     dnsservers->n_to_start = Config.dnsChildren;
-    dnsservers->ipc_type = IPC_TCP_SOCKET;
+    dnsservers->ipc_type = IPC_FIFO;
     assert(dnsservers->cmdline == NULL);
     wordlistAdd(&dnsservers->cmdline, Config.Program.dnsserver);
     if (Config.onoff.res_defnames)
index 77038c113e7fa505fac3e77346a3c68163e09221..c209a0be50c4d07b14c55d9eba7d25b643b123c1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.142 1999/01/11 23:29:41 wessels Exp $
+ * $Id: enums.h,v 1.143 1999/01/12 16:42:17 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -132,11 +132,6 @@ enum {
     FD_WRITE
 };
 
-enum {
-    FD_CLOSE,
-    FD_OPEN
-};
-
 enum {
     FQDN_CACHED,
     FQDN_NEGATIVE_CACHED,
index b0e6fb7e721ded23f1ef2597c824a1368cf012cb..be6c81c2d81e61cd817b95b8667259afb76c5c7b 100644 (file)
--- a/src/fd.cc
+++ b/src/fd.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fd.cc,v 1.28 1998/10/01 22:28:28 wessels Exp $
+ * $Id: fd.cc,v 1.29 1999/01/12 16:42:18 wessels Exp $
  *
  * DEBUG: section 51    Filedescriptor Functions
  * AUTHOR: Duane Wessels
@@ -45,24 +45,30 @@ const char *fdTypeStr[] =
     "Unknown"
 };
 
-static void fdUpdateBiggest(int fd, unsigned int status);
+static void fdUpdateBiggest(int fd, int);
 
 static void
-fdUpdateBiggest(int fd, unsigned int status)
+fdUpdateBiggest(int fd, int opening)
 {
     if (fd < Biggest_FD)
        return;
     assert(fd < Squid_MaxFD);
     if (fd > Biggest_FD) {
-       if (status != FD_OPEN)
-           debug(51, 1) ("fdUpdateBiggest: status != FD_OPEN\n");
+       /*
+        * assert that we are not closing a FD bigger than
+        * our known biggest FD
+        */
+       assert(opening);
        Biggest_FD = fd;
        return;
     }
     /* if we are here, then fd == Biggest_FD */
-    if (status != FD_CLOSE)
-       debug(51, 1) ("fdUpdateBiggest: status != FD_CLOSE\n");
-    while (fd_table[Biggest_FD].open != FD_OPEN)
+    /*
+     * assert that we are closing the biggest FD; we can't be
+     * re-opening it
+     */
+    assert(!opening);
+    while (!fd_table[Biggest_FD].flags.open)
        Biggest_FD--;
 }
 
@@ -75,7 +81,8 @@ fd_close(int fd)
        assert(F->write_handler == NULL);
     }
     debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc);
-    fdUpdateBiggest(fd, F->open = FD_CLOSE);
+    F->flags.open = 0;
+    fdUpdateBiggest(fd, 0);
     Number_FD--;
     if (F->type == FD_FILE)
        open_disk_fd--;
@@ -90,14 +97,15 @@ fd_open(int fd, unsigned int type, const char *desc)
 {
     fde *F = &fd_table[fd];
     assert(fd >= 0);
-    if (F->open != 0) {
+    if (!F->flags.open) {
        debug(51, 1) ("WARNING: Closing open FD %4d\n", fd);
        fd_close(fd);
     }
-    assert(F->open == 0);
+    assert(!F->flags.open);
     debug(51, 3) ("fd_open FD %d %s\n", fd, desc);
     F->type = type;
-    fdUpdateBiggest(fd, F->open = FD_OPEN);
+    F->flags.open = 1;
+    fdUpdateBiggest(fd, 1);
     if (desc)
        xstrncpy(F->desc, desc, FD_DESC_SZ);
     Number_FD++;
@@ -138,7 +146,7 @@ fdDumpOpen(void)
     fde *F;
     for (i = 0; i < Squid_MaxFD; i++) {
        F = &fd_table[i];
-       if (!F->open)
+       if (!F->flags.open)
            continue;
        if (i == fileno(debug_log))
            continue;
index 154fa10cf1c43549436e3f55c4829329a08a1466..41918f479d6dbc1dcf76f9219ac45e0a14cc3f3f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.306 1999/01/11 19:42:22 wessels Exp $
+ * $Id: stat.cc,v 1.307 1999/01/12 16:42:19 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -410,7 +410,7 @@ statFiledescriptors(StoreEntry * sentry)
     storeAppendPrintf(sentry, "---- ------ ---- ------- ------- --------------------- ------------------------------\n");
     for (i = 0; i < Squid_MaxFD; i++) {
        f = &fd_table[i];
-       if (!f->open)
+       if (!f->flags.open)
            continue;
        storeAppendPrintf(sentry, "%4d %-6.6s %4d %7d %7d %-21s %s\n",
            i,
index 2adb8eb5cedbab92e35ba6f7267d3c9cff6d258e..ab077c35b15d3a1870593b6e5d82b2fdade16d24 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: structs.h,v 1.256 1999/01/11 22:23:08 wessels Exp $
+ * $Id: structs.h,v 1.257 1999/01/12 16:42:20 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -491,12 +491,13 @@ struct _ETag {
 
 struct _fde {
     unsigned int type;
-    unsigned int open;
+    unsigned int mode;         /* FD_READ|FD_WRITE */
     u_short local_port;
     u_short remote_port;
     char ipaddr[16];           /* dotted decimal address of peer */
     char desc[FD_DESC_SZ];
     struct {
+       unsigned int open:1;
        unsigned int close_request:1;
        unsigned int write_daemon:1;
        unsigned int closing:1;