From 60c0b5a2f6ff82312d82f6619f418cc8fb4e232f Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 12 Jan 1999 23:42:15 +0000 Subject: [PATCH] changed struct _fde->open to _fde->flags.open to save a few bytes --- src/comm.cc | 14 +++++++------- src/comm_select.cc | 4 ++-- src/disk.cc | 6 +++--- src/dns.cc | 4 ++-- src/enums.h | 7 +------ src/fd.cc | 34 +++++++++++++++++++++------------- src/stat.cc | 4 ++-- src/structs.h | 5 +++-- 8 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/comm.cc b/src/comm.cc index 0176d1a83e..04e30007fb 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -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; diff --git a/src/comm_select.cc b/src/comm_select.cc index e06c9ca0e7..4aca400901 100644 --- a/src/comm_select.cc +++ b/src/comm_select.cc @@ -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; diff --git a/src/disk.cc b/src/disk.cc index 24d30683bf..fba5918517 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -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; diff --git a/src/dns.cc b/src/dns.cc index 1e888a511c..6a5f3d5c41 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -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) diff --git a/src/enums.h b/src/enums.h index 77038c113e..c209a0be50 100644 --- a/src/enums.h +++ b/src/enums.h @@ -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, diff --git a/src/fd.cc b/src/fd.cc index b0e6fb7e72..be6c81c2d8 100644 --- 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; diff --git a/src/stat.cc b/src/stat.cc index 154fa10cf1..41918f479d 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -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, diff --git a/src/structs.h b/src/structs.h index 2adb8eb5ce..ab077c35b1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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; -- 2.47.3