]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
sigh. Okay, this might work better.
authorwessels <>
Tue, 19 Jan 1999 05:23:32 +0000 (05:23 +0000)
committerwessels <>
Tue, 19 Jan 1999 05:23:32 +0000 (05:23 +0000)
To "decouple" storeAbort calling into the server side (fwdAbort) and
wreaking havoc, lets have the storeAbort callback done as an event,
thus outside of comm_select loop.

Hopefully this means we don't need the gross "flags.delayed_comm_close"
and current_hdl_fd crap.

Also, since we moved the abort callback to an event, we might end up
doing a server read after the entry has been aborted, but before
the event is called.  Thus, the server modules need to check
for ENTRY_ABORTED before reading.

this commit also adds some (temp?) debugging to track open
disk FDs

15 files changed:
src/comm.cc
src/comm_select.cc
src/fd.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/protos.h
src/squid.h
src/stat.cc
src/store.cc
src/store_client.cc
src/store_swapin.cc
src/store_swapout.cc
src/structs.h
src/wais.cc

index 94a24668573294d8246927373d9f707df34013c9..b3aab7c3163dd722a50f13b8cd931c3c46b57ed0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.298 1999/01/12 23:22:28 wessels Exp $
+ * $Id: comm.cc,v 1.299 1999/01/18 22:23:32 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -573,7 +573,6 @@ comm_close(int fd)
 #if USE_ASYNC_IO
     int doaioclose = 1;
 #endif
-    extern int current_hdl_fd;
     debug(5, 5) ("comm_close: FD %d\n", fd);
     assert(fd >= 0);
     assert(fd < Squid_MaxFD);
@@ -582,10 +581,6 @@ comm_close(int fd)
        return;
     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->flags.open);
     assert(F->type != FD_FILE);
 #ifdef USE_ASYNC_IO
index 56009295afe314bcba47ea749e76cb4d00d5e107..005f9e4c59f57c3d458dd60c691282b630de32eb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_select.cc,v 1.28 1999/01/13 23:24:10 wessels Exp $
+ * $Id: comm_select.cc,v 1.29 1999/01/18 22:23:33 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -49,9 +49,6 @@
 #define FD_MASK_BYTES sizeof(fd_mask)
 #define FD_MASK_BITS (FD_MASK_BYTES*NBBY)
 
-/* GLOBAL */
-int current_hdl_fd = -1;
-
 /* STATIC */
 #if !HAVE_POLL
 static int examine_select(fd_set *, fd_set *);
@@ -362,12 +359,9 @@ comm_poll(int msec)
                debug(5, 6) ("comm_poll: FD %d ready for reading\n", fd);
                if ((hdl = F->read_handler)) {
                    F->read_handler = NULL;
-                   hdl(current_hdl_fd = fd, F->read_data);
-                   current_hdl_fd = -1;
+                   hdl(fd, F->read_data);
                    Counter.select_fds++;
                }
-               if (F->flags.delayed_comm_close)
-                   comm_close(fd);
                if (commCheckICPIncoming)
                    comm_poll_icp_incoming();
                if (commCheckHTTPIncoming)
@@ -377,12 +371,9 @@ comm_poll(int msec)
                debug(5, 5) ("comm_poll: FD %d ready for writing\n", fd);
                if ((hdl = F->write_handler)) {
                    F->write_handler = NULL;
-                   hdl(current_hdl_fd = fd, F->write_data);
-                   current_hdl_fd = -1;
+                   hdl(fd, F->write_data);
                    Counter.select_fds++;
                }
-               if (F->flags.delayed_comm_close)
-                   comm_close(fd);
                if (commCheckICPIncoming)
                    comm_poll_icp_incoming();
                if (commCheckHTTPIncoming)
@@ -672,12 +663,9 @@ comm_select(int msec)
                    hdl = F->read_handler;
                    F->read_handler = NULL;
                    commUpdateReadBits(fd, NULL);
-                   hdl(current_hdl_fd = fd, F->read_data);
-                   current_hdl_fd = -1;
+                   hdl(fd, F->read_data);
                    Counter.select_fds++;
                }
-               if (F->flags.delayed_comm_close)
-                   comm_close(fd);
                if (commCheckICPIncoming)
                    comm_select_icp_incoming();
                if (commCheckHTTPIncoming)
@@ -714,12 +702,9 @@ comm_select(int msec)
                    hdl = F->write_handler;
                    F->write_handler = NULL;
                    commUpdateWriteBits(fd, NULL);
-                   hdl(current_hdl_fd = fd, F->write_data);
-                   current_hdl_fd = -1;
+                   hdl(fd, F->write_data);
                    Counter.select_fds++;
                }
-               if (F->flags.delayed_comm_close)
-                   comm_close(fd);
                if (commCheckICPIncoming)
                    comm_select_icp_incoming();
                if (commCheckHTTPIncoming)
index f4d7cb0fd65b60fac068cdf6c625ef4fca0b93c5..3c7b4bb01d003e7f6d2fba82a95671472f704511 100644 (file)
--- a/src/fd.cc
+++ b/src/fd.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fd.cc,v 1.30 1999/01/12 23:37:41 wessels Exp $
+ * $Id: fd.cc,v 1.31 1999/01/18 22:23:34 wessels Exp $
  *
  * DEBUG: section 51    Filedescriptor Functions
  * AUTHOR: Duane Wessels
@@ -192,3 +192,15 @@ fdAdjustReserved(void)
        RESERVED_FD, new);
     RESERVED_FD = new;
 }
+
+void
+fdTouchFL(int fd, const char *file, int line)
+{
+       fde *F;
+       if (fd < 0)
+               return;
+       F = &fd_table[fd];
+       assert(F->flags.open);
+       F->last.file = file;
+       F->last.line = line;
+}
index 4697f0efa6eb19c6f9085c0529727acd94dbb4d1..bcc5a3b1ae0e2541bee778b69f9773178c663eda 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.265 1999/01/15 00:16:19 wessels Exp $
+ * $Id: ftp.cc,v 1.266 1999/01/18 22:23:35 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -836,6 +836,10 @@ ftpDataRead(int fd, void *data)
     delay_id delay_id = delayMostBytesAllowed(mem);
 #endif
     assert(fd == ftpState->data.fd);
+    if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
+        comm_close(fd);
+        return;
+    }
     errno = 0;
     read_sz = ftpState->data.size - ftpState->data.offset;
 #if DELAY_POOLS
index 19185975fd9f3878d61fb55d35bb0bc22b447cf5..d614b1df9741e3a2d6ec9f02185ed0ce89692052 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: gopher.cc,v 1.145 1999/01/15 06:11:43 wessels Exp $
+ * $Id: gopher.cc,v 1.146 1999/01/18 22:23:36 wessels Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -600,6 +600,10 @@ gopherReadReply(int fd, void *data)
 #if DELAY_POOLS
     delay_id delay_id = delayMostBytesAllowed(entry->mem_obj);
 #endif
+    if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
+        comm_close(fd);
+        return;
+    }
     errno = 0;
     buf = memAllocate(MEM_4K_BUF);
     read_sz = 4096 - 1;                /* leave room for termination */
index 1eb591b13204b38f87deb2ae4eb230b4ff1882fc..b21e9bcf08a248312934bd6ec31bb5ef46ba1d7f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.340 1999/01/15 06:11:44 wessels Exp $
+ * $Id: http.cc,v 1.341 1999/01/18 22:23:37 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -431,6 +431,10 @@ httpReadReply(int fd, void *data)
 #if DELAY_POOLS
     delay_id delay_id = delayMostBytesAllowed(entry->mem_obj);
 #endif
+    if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
+       comm_close(fd);
+       return;
+    }
     /* check if we want to defer reading */
     errno = 0;
     read_sz = SQUID_TCP_SO_RCVBUF;
index 0cb2061cfd0c3920255b6bc2a2e3ae9eb833865a..96308c431807ad45cd58f9e852df78111c45312f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.303 1999/01/15 06:11:45 wessels Exp $
+ * $Id: protos.h,v 1.304 1999/01/18 22:23:38 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -225,6 +225,7 @@ extern void fdFreeMemory(void);
 extern void fdDumpOpen(void);
 extern int fdNFree(void);
 extern void fdAdjustReserved(void);
+extern void fdTouchFL(int, const char *, int);
 
 extern fileMap *file_map_create(int);
 extern int file_map_allocate(fileMap *, int);
index af8f811e8810d65334db4020a207bad58ceacb1e..d679e1f18e4ce94ad902166d831d3c0a4ef03443 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.183 1999/01/11 21:55:41 wessels Exp $
+ * $Id: squid.h,v 1.184 1999/01/18 22:23:39 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -310,6 +310,8 @@ struct rusage {
 #define leakFree(p) p
 #endif
 
+#define fdTouch(f) fdTouchFL(f,__FILE__,__LINE__)
+
 #if defined(_SQUID_NEXT_) && !defined(S_ISDIR)
 #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
 #endif
index 41918f479d6dbc1dcf76f9219ac45e0a14cc3f3f..8d807ee0854add01cc0ffeaf0c1c6d4d7a75a5ce 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.307 1999/01/12 16:42:19 wessels Exp $
+ * $Id: stat.cc,v 1.308 1999/01/18 22:23:40 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -412,13 +412,15 @@ statFiledescriptors(StoreEntry * sentry)
        f = &fd_table[i];
        if (!f->flags.open)
            continue;
-       storeAppendPrintf(sentry, "%4d %-6.6s %4d %7d %7d %-21s %s\n",
+       storeAppendPrintf(sentry, "%4d %-6.6s %4d %7d %7d %-21s %20s:%-5d %s\n",
            i,
            fdTypeStr[f->type],
            f->timeout_handler ? (int) (f->timeout - squid_curtime) / 60 : 0,
            f->bytes_read,
            f->bytes_written,
            fdRemoteAddr(f),
+           f->last.line ? f->last.file : null_string,
+           f->last.line,
            f->desc);
     }
 }
index 097def9e4b209a87c0e619a08ffe2aa5b6a01e9f..c4c6acb06314d08825ab19504960192044475cb2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.482 1999/01/15 06:30:10 wessels Exp $
+ * $Id: store.cc,v 1.483 1999/01/18 22:23:42 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -594,8 +594,6 @@ void
 storeAbort(StoreEntry * e)
 {
     MemObject *mem = e->mem_obj;
-    STABH *callback;
-    void *data;
     assert(e->store_status == STORE_PENDING);
     assert(mem != NULL);
     debug(20, 6) ("storeAbort: %s\n", storeKeyText(e->key));
@@ -614,11 +612,13 @@ storeAbort(StoreEntry * e)
     mem->object_sz = mem->inmem_hi;
     /* Notify the server side */
     if (mem->abort.callback) {
-       callback = mem->abort.callback;
-       data = mem->abort.data;
+       eventAdd("mem->abort.callback",
+           mem->abort.callback,
+           mem->abort.data,
+           0.0,
+           0);
        mem->abort.callback = NULL;
        mem->abort.data = NULL;
-       callback(data);
     }
     /* Notify the client side */
     InvokeHandlers(e);
index bc569cd27116545382d591d18fe9264c23058381..888db189a84ceab8fe90904f538027fbe2a87506 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_client.cc,v 1.54 1999/01/13 05:56:08 wessels Exp $
+ * $Id: store_client.cc,v 1.55 1999/01/18 22:23:44 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager Client-Side Interface
  * AUTHOR: Duane Wessels
@@ -295,6 +295,7 @@ storeClientFileOpened(int fd, void *data)
        callback(sc->callback_data, sc->copy_buf, -1);
        return;
     }
+    fdTouch(fd);
     sc->swapin_fd = fd;
     storeClientFileRead(sc);
 }
@@ -307,6 +308,7 @@ storeClientFileRead(store_client * sc)
 #ifdef OPTIMISTIC_IO
     sc->flags.disk_io_pending = 1;
 #endif
+    fdTouch(sc->swapin_fd);
     if (mem->swap_hdr_sz == 0) {
        file_read(sc->swapin_fd,
            sc->copy_buf,
@@ -335,6 +337,7 @@ storeClientReadBody(int fd, const char *buf, int len, int flagnotused, void *dat
     store_client *sc = data;
     MemObject *mem = sc->entry->mem_obj;
     STCB *callback = sc->callback;
+    fdTouch(fd);
     assert(sc->flags.disk_io_pending);
     sc->flags.disk_io_pending = 0;
     assert(sc->callback != NULL);
@@ -356,6 +359,7 @@ storeClientReadHeader(int fd, const char *buf, int len, int flagnotused, void *d
     size_t body_sz;
     size_t copy_sz;
     tlv *tlv_list;
+    fdTouch(fd);
     assert(sc->flags.disk_io_pending);
     sc->flags.disk_io_pending = 0;
     assert(sc->callback != NULL);
@@ -366,6 +370,7 @@ storeClientReadHeader(int fd, const char *buf, int len, int flagnotused, void *d
        callback(sc->callback_data, sc->copy_buf, len);
        return;
     }
+    fdTouch(fd);
     tlv_list = storeSwapMetaUnpack(buf, &swap_hdr_sz);
     if (tlv_list == NULL) {
        debug(20, 1) ("storeClientReadHeader: failed to unpack meta data\n");
@@ -373,6 +378,7 @@ storeClientReadHeader(int fd, const char *buf, int len, int flagnotused, void *d
        callback(sc->callback_data, sc->copy_buf, -1);
        return;
     }
+    fdTouch(fd);
     /*
      * XXX Here we should check the meta data and make sure we got
      * the right object.
@@ -399,6 +405,7 @@ storeClientReadHeader(int fd, const char *buf, int len, int flagnotused, void *d
        callback(sc->callback_data, sc->copy_buf, copy_sz);
        return;
     }
+    fdTouch(fd);
     /*
      * we don't have what the client wants, but at least we now
      * know the swap header size.
@@ -444,6 +451,7 @@ storeUnregister(StoreEntry * e, void *data)
     *S = sc->next;
     mem->nclients--;
     sc->flags.disk_io_pending = 0;
+    fdTouch(sc->swapin_fd);
     if (e->store_status == STORE_OK && e->swap_status != SWAPOUT_DONE)
        storeCheckSwapOut(e);
     if (sc->swapin_fd > -1) {
index 13d5880199183aa175f08abde369b39f29f273f6..3d1223b2018d5695aec9361fe6c2f18baa11cbe9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_swapin.cc,v 1.14 1998/09/19 17:06:16 wessels Exp $
+ * $Id: store_swapin.cc,v 1.15 1999/01/18 22:23:44 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager Swapin Functions
  * AUTHOR: Duane Wessels
@@ -108,6 +108,7 @@ storeSwapInFileOpened(void *data, int fd, int errcode)
        xfree(ctrlp);
        return;
     }
+    fdTouch(fd);
     assert(mem != NULL);
     assert(e->mem_status == NOT_IN_MEMORY);
     assert(e->swap_status == SWAPOUT_WRITING || e->swap_status == SWAPOUT_DONE);
index 60e3a912df6a3febdd178deef4ef742cb9129c00..0342fdc3099f741349e6db93ca847a6a1b30c38c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_swapout.cc,v 1.42 1999/01/12 23:37:51 wessels Exp $
+ * $Id: store_swapout.cc,v 1.43 1999/01/18 22:23:45 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager Swapout Functions
  * AUTHOR: Duane Wessels
@@ -74,6 +74,7 @@ storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data)
     StoreEntry *e = ctrlp->e;
     MemObject *mem = e->mem_obj;
     debug(20, 3) ("storeSwapOutHandle: '%s', len=%d\n", storeKeyText(e->key), (int) len);
+    fdTouch(fdnotused);
     if (flag < 0) {
        debug(20, 1) ("storeSwapOutHandle: SwapOut failure (err code = %d).\n",
            flag);
@@ -92,6 +93,7 @@ storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data)
        storeSwapOutFileClose(e);
        return;
     }
+    fdTouch(fdnotused);
 #if USE_ASYNC_IO
     if (mem == NULL) {
        debug(20, 1) ("storeSwapOutHandle: mem == NULL : Cancelling swapout\n");
@@ -109,6 +111,7 @@ storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data)
        storeCheckSwapOut(e);
        return;
     }
+    fdTouch(fdnotused);
     /* swapping complete */
     debug(20, 5) ("storeSwapOutHandle: SwapOut complete: '%s' to %s.\n",
        storeUrl(e), storeSwapFullPath(e->swap_file_number, NULL));
@@ -119,6 +122,7 @@ storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data)
        storeLog(STORE_LOG_SWAPOUT, e);
        storeDirSwapLog(e, SWAP_LOG_ADD);
     }
+    fdTouch(fdnotused);
     /* Note, we don't otherwise call storeReleaseRequest() here because
      * storeCheckCachable() does it for is if necessary */
     storeSwapOutFileClose(e);
@@ -248,6 +252,7 @@ storeCheckSwapOut(StoreEntry * e)
     debug(20, 3) ("storeCheckSwapOut: swapping out %d bytes from %d\n",
        swap_buf_len, (int) mem->swapout.queue_offset);
     mem->swapout.queue_offset += swap_buf_len - hdr_len;
+    fdTouch(mem->swapout.fd);
     file_write(mem->swapout.fd,
        -1,
        swap_buf,
@@ -288,6 +293,7 @@ storeSwapOutFileOpened(void *data, int fd, int errcode)
     int swap_hdr_sz = 0;
     tlv *tlv_list;
     char *buf;
+    fdTouch(fd);
     if (fd == -2 && errcode == -2) {   /* Cancelled - Clean up */
        xfree(ctrlp->swapfilename);
        cbdataFree(ctrlp);
index 1b12556ede4c6a8a4b1f64e3d914a4969f8f2dc1..45a5d2cefec5682bf065d72ce0c3ead87b2ab735 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
- * $Id: structs.h,v 1.260 1999/01/15 06:11:46 wessels Exp $
+ * $Id: structs.h,v 1.261 1999/01/18 22:23:46 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -509,7 +509,6 @@ struct _fde {
 #ifdef OPTIMISTIC_IO
        unsigned int calling_io_handler:1;
 #endif
-       unsigned int delayed_comm_close:1;
     } flags;
     int bytes_read;
     int bytes_written;
@@ -533,6 +532,10 @@ struct _fde {
     DEFER *defer_check;                /* check if we should defer read */
     void *defer_data;
     CommWriteStateData *rwstate;       /* State data for comm_write */
+    struct {
+       const char *file;
+       int line;
+    } last;
 };
 
 struct _fileMap {
index 5a586c5add040e3422636cacb62b98d0ab291b06..4b6b565b97f3338667af32a5221a572bcc2af71c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.127 1999/01/15 06:11:47 wessels Exp $
+ * $Id: wais.cc,v 1.128 1999/01/18 22:23:48 wessels Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -91,6 +91,10 @@ waisReadReply(int fd, void *data)
 #if DELAY_POOLS
     delay_id delay_id = delayMostBytesAllowed(entry->mem_obj);
 #endif
+    if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
+        comm_close(fd);
+        return;
+    }
     errno = 0;
     read_sz = 4096;
 #if DELAY_POOLS