Index: squid/src/fs/aufs/aiops.c diff -c squid/src/fs/aufs/aiops.c:1.12.2.2 squid/src/fs/aufs/aiops.c:1.12.2.6 *** squid/src/fs/aufs/aiops.c:1.12.2.2 Sat Nov 9 03:42:36 2002 --- squid/src/fs/aufs/aiops.c Wed Jan 8 17:55:35 2003 *************** *** 159,164 **** --- 159,167 ---- NULL, &done_requests.head }; + static int done_fd = 0; + static int done_fd_read = 0; + static int done_signalled = 0; static pthread_attr_t globattr; #if HAVE_SCHED_H static struct sched_param globsched; *************** *** 235,243 **** --- 238,255 ---- } static void + squidaio_fdhandler(int fd, void *data) + { + char junk[256]; + read(done_fd_read, junk, sizeof(junk)); + commSetSelect(fd, COMM_SELECT_READ, squidaio_fdhandler, NULL, 0); + } + + static void squidaio_init(void) { int i; + int done_pipe[2]; squidaio_thread_t *threadp; if (squidaio_initialised) *************** *** 281,286 **** --- 293,308 ---- done_queue.requests = 0; done_queue.blocked = 0; + /* Initialize done pipe signal */ + pipe(done_pipe); + done_fd = done_pipe[1]; + done_fd_read = done_pipe[0]; + fd_open(done_pipe[0], FD_PIPE, "async-io completetion event: main"); + fd_open(done_pipe[1], FD_PIPE, "async-io completetion event: threads"); + commSetNonBlocking(done_pipe[0]); + commSetNonBlocking(done_pipe[1]); + commSetSelect(done_pipe[0], COMM_SELECT_READ, squidaio_fdhandler, NULL, 0); + /* Create threads and get them to sit in their wait loop */ squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t)); for (i = 0; i < NUMTHREADS; i++) { *************** *** 401,406 **** --- 423,432 ---- *done_queue.tailp = request; done_queue.tailp = &request->next; pthread_mutex_unlock(&done_queue.mutex); + if (!done_signalled) { + done_signalled = 1; + write(done_fd, "!", 1); + } threadp->requests++; } /* while forever */ return NULL; *************** *** 801,819 **** } done_requests.tailp = &requests->next; } - #if HAVE_SCHED_H - /* Give up the CPU to allow the threads to do their work */ - /* - * For Andres thoughts about yield(), see - * http://www.squid-cache.org/mail-archive/squid-dev/200012/0001.html - */ - if (done_queue.head || request_queue.head) - #ifndef _SQUID_SOLARIS_ - sched_yield(); - #else - yield(); - #endif - #endif } squidaio_result_t * --- 827,832 ---- *************** *** 827,832 **** --- 840,850 ---- AIO_REPOLL: request = done_requests.head; if (request == NULL && !polled) { + if (done_signalled) { + char junk[256]; + read(done_fd_read, junk, sizeof(junk)); + done_signalled = 0; + } squidaio_poll_queues(); polled = 1; request = done_requests.head; Index: squid/src/fs/aufs/async_io.c diff -c squid/src/fs/aufs/async_io.c:1.10.2.4 squid/src/fs/aufs/async_io.c:1.10.2.5 *** squid/src/fs/aufs/async_io.c:1.10.2.4 Sun Nov 10 05:06:07 2002 --- squid/src/fs/aufs/async_io.c Fri Jan 3 18:19:42 2003 *************** *** 88,93 **** --- 88,94 ---- fd_close(fd); } + void aioInit(void) { *************** *** 97,103 **** cachemgrRegister("squidaio_counts", "Async IO Function Counters", aioStats, 0, 1); initialised = 1; - comm_quick_poll_required(); } void --- 98,103 ----