From ddb43c58a94086dbf0f33c3e85590f8dfc044017 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Fri, 22 Jan 1999 04:13:00 +0000 Subject: [PATCH] From: Henrik Nordstrom * Changed async_io.c and aiops.c to use MemPool pools for their "request" structures. * Fix for a odd situation where I/O operations could get stuck in the queue if there was no new I/O activity. Symptoms seen was: 1. The shutdown code could trigger some assertions which seemed impossible. 2. Some times a number of files could be kept open until the next swapout. * Changed the log message shown when running low on I/O threads, and also changed logging of this message to only occur if out of threads for more than one second. * Moved some aiops.c log messages to lower priorities. * Removed that special low-priority queue for unlinks. I had some strange effects from it, and the number of queued unlinks fluctuaded a bit to much when under heavy load. If store maintaince is a problem then this should it be corrected at a higher level, and not by delaying the unlinks. * Minor preparations for making NUMTHREADS a squid.conf tunable. * moved memClean later in the shutdown procedure, to allow async-io to use MemPool.. --- src/disk.cc | 5 ++++- src/fd.cc | 18 +++++++++++++++++- src/main.cc | 13 +++++++++++-- src/protos.h | 7 ++++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/disk.cc b/src/disk.cc index 50b5de7933..0e6480c8b5 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,7 +1,7 @@ /* - * $Id: disk.cc,v 1.139 1999/01/13 23:24:11 wessels Exp $ + * $Id: disk.cc,v 1.140 1999/01/21 21:13:00 wessels Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -161,6 +161,7 @@ file_close(int fd) * leaking write state data by closing the descriptor */ assert(F->write_handler == NULL); + F->flags.closing = 1; #if USE_ASYNC_IO aioClose(fd); #else @@ -171,7 +172,9 @@ file_close(int fd) #endif debug(6, F->flags.close_request ? 2 : 5) ("file_close: FD %d, really closing\n", fd); +#if !USE_ASYNC_IO fd_close(fd); +#endif Counter.syscalls.disk.closes++; } diff --git a/src/fd.cc b/src/fd.cc index b1890f0bc2..caee0cbb94 100644 --- a/src/fd.cc +++ b/src/fd.cc @@ -1,6 +1,6 @@ /* - * $Id: fd.cc,v 1.34 1999/01/21 21:10:32 wessels Exp $ + * $Id: fd.cc,v 1.35 1999/01/21 21:13:01 wessels Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -90,11 +90,27 @@ fd_close(int fd) F->timeout = 0; } +#if USE_ASYNC_IO +void +fd_was_closed(int fd) +{ + fde *F = &fd_table[fd]; + if (F->flags.closing) + fd_close(fd); +} +#endif + void fd_open(int fd, unsigned int type, const char *desc) { fde *F = &fd_table[fd]; assert(fd >= 0); +#if USE_ASYNC_IO + if (F->flags.closing) { + /* Reuse of a closed FD before we have noticed it is closed */ + fd_close(fd); + } +#endif if (F->flags.open) { debug(51, 1) ("WARNING: Closing open FD %4d\n", fd); fd_close(fd); diff --git a/src/main.cc b/src/main.cc index 83dc43386a..bd01309cf4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.286 1999/01/19 02:24:28 wessels Exp $ + * $Id: main.cc,v 1.287 1999/01/21 21:13:02 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -747,11 +747,20 @@ SquidShutdown(void *unused) releaseServerSockets(); commCloseAllSockets(); unlinkdClose(); +#if USE_ASYNC_IO + aioSync(); /* flush pending object writes / unlinks */ +#endif storeDirWriteCleanLogs(0); PrintRusage(); dumpMallocStats(); +#if USE_ASYNC_IO + aioSync(); /* flush log writes */ +#endif storeLogClose(); accessLogClose(); +#if USE_ASYNC_IO + aioSync(); /* flush log close */ +#endif #if PURIFY || XMALLOC_TRACE configFreeMemory(); storeFreeMemory(); @@ -767,7 +776,6 @@ SquidShutdown(void *unused) mimeFreeMemory(); errorClean(); #endif - memClean(); #if !XMALLOC_TRACE if (opt_no_daemon) { file_close(0); @@ -777,6 +785,7 @@ SquidShutdown(void *unused) #endif fdDumpOpen(); fdFreeMemory(); + memClean(); #if XMALLOC_TRACE xmalloc_find_leaks(); debug(1, 0) ("Memory used after shutdown: %d\n", xmalloc_total); diff --git a/src/protos.h b/src/protos.h index 3b4ed7c876..935a18067d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.308 1999/01/19 23:18:00 wessels Exp $ + * $Id: protos.h,v 1.309 1999/01/21 21:13:04 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -75,6 +75,7 @@ extern int aio_stat(const char *, struct stat *, aio_result_t *); extern int aio_unlink(const char *, aio_result_t *); extern int aio_opendir(const char *, aio_result_t *); extern aio_result_t *aio_poll_done(void); +extern int aio_operations_pending(void); extern void aioCancel(int, void *); extern void aioOpen(const char *, int, mode_t, AIOCB *, void *, void *); @@ -84,6 +85,7 @@ extern void aioRead(int, int offset, char *, int size, AIOCB *, void *); extern void aioStat(char *, struct stat *, AIOCB *, void *, void *); extern void aioUnlink(const char *, AIOCB *, void *); extern void aioCheckCallbacks(void); +extern void aioSync(void); #endif extern int parseConfigFile(const char *file_name); @@ -218,6 +220,9 @@ extern void eventFreeMemory(void); extern int eventFind(EVH *, void *); extern void fd_close(int fd); +#if USE_ASYNC_IO +extern void fd_was_closed(int fd); +#endif extern void fd_open(int fd, unsigned int type, const char *); extern void fd_note(int fd, const char *); extern void fd_bytes(int fd, int len, unsigned int type); -- 2.47.3