--------------------- PatchSet 8645 Date: 2006/09/16 19:17:19 Author: serassio Branch: nt Tag: (none) Log: Rollback to standard 2.6 aufs code Members: src/fs/aufs/aiops_win32.c:1.1.2.3->1.1.2.4 Index: squid/src/fs/aufs/aiops_win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/aiops_win32.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid/src/fs/aufs/aiops_win32.c 9 Sep 2006 15:06:14 -0000 1.1.2.3 +++ squid/src/fs/aufs/aiops_win32.c 16 Sep 2006 19:17:19 -0000 1.1.2.4 @@ -1,6 +1,5 @@ - /* - * $Id: aiops_win32.c,v 1.1.2.3 2006/09/09 15:06:14 serassio Exp $ + * $Id: aiops_win32.c,v 1.1.2.4 2006/09/16 19:17:19 serassio Exp $ * * DEBUG: section 43 Windows AIOPS * AUTHOR: Stewart Forster @@ -246,10 +245,7 @@ squidaio_fdhandler(int fd, void *data) { char junk[256]; - int x; - fde *F = &fd_table[done_fd_read]; - if ((x = FD_READ_METHOD(done_fd_read, junk, sizeof(junk))) > 0) - F->bytes_read += x; + FD_READ_METHOD(done_fd_read, junk, sizeof(junk)); commSetSelect(fd, COMM_SELECT_READ, squidaio_fdhandler, NULL, 0); } @@ -444,7 +440,6 @@ CloseHandle(cond); fatal("Can't release mutex\n"); } - Sleep(0); while (1) { DWORD rv; @@ -546,11 +541,8 @@ return 1; } if (!done_signalled) { - fde *F = &fd_table[done_fd]; - int x; done_signalled = 1; - if ((x = FD_WRITE_METHOD(done_fd, "!", 1)) > 0) - F->bytes_written += x; + FD_WRITE_METHOD(done_fd, "!", 1); } threadp->requests++; /* Relinquish the remainder of thread time slice to any other thread @@ -576,30 +568,42 @@ request->resultp->_data = request; /* Play some tricks with the request_queue2 queue */ request->next = NULL; - if (WaitForSingleObject(request_queue.mutex, 0) == WAIT_OBJECT_0) { - if (request_queue2.head) { - /* Grab blocked requests */ - *request_queue.tailp = request_queue2.head; - request_queue.tailp = request_queue2.tailp; - } - /* Enqueue request */ - *request_queue.tailp = request; - request_queue.tailp = &request->next; - if (!SetEvent(request_queue.cond)) - fatal("couldn't push queue\n"); - if (!ReleaseMutex(request_queue.mutex)) { - /* unexpected error */ - fatal("couldn't push queue\n"); + if (!request_queue2.head) { + if (WaitForSingleObject(request_queue.mutex, 0) == WAIT_OBJECT_0) { + /* Normal path */ + *request_queue.tailp = request; + request_queue.tailp = &request->next; + if (!SetEvent(request_queue.cond)) + fatal("couldn't push queue\n"); + if (!ReleaseMutex(request_queue.mutex)) { + /* unexpected error */ + fatal("couldn't push queue\n"); + } + } else { + /* Oops, the request queue is blocked, use request_queue2 */ + *request_queue2.tailp = request; + request_queue2.tailp = &request->next; } - if (request_queue2.head) { - /* Clear queue of blocked requests */ + } else { + /* Secondary path. We have blocked requests to deal with */ + /* add the request to the chain */ + *request_queue2.tailp = request; + if (WaitForSingleObject(request_queue.mutex, 0) == WAIT_OBJECT_0) { + /* Ok, the queue is no longer blocked */ + *request_queue.tailp = request_queue2.head; + request_queue.tailp = &request->next; + if (!SetEvent(request_queue.cond)) + fatal("couldn't push queue\n"); + if (!ReleaseMutex(request_queue.mutex)) { + /* unexpected error */ + fatal("couldn't push queue\n"); + } request_queue2.head = NULL; request_queue2.tailp = &request_queue2.head; + } else { + /* still blocked, bump the blocked request chain */ + request_queue2.tailp = &request->next; } - } else { - /* Oops, the request queue is blocked, use request_queue2 */ - *request_queue2.tailp = request; - request_queue2.tailp = &request->next; } if (request_queue2.head) { static int filter = 0; @@ -755,16 +759,12 @@ static void squidaio_do_read(squidaio_request_t * requestp) { -#ifdef _SQUID_MSWIN_ lseek(requestp->fd, requestp->offset, requestp->whence); if (!ReadFile((HANDLE) _get_osfhandle(requestp->fd), requestp->bufferp, requestp->buflen, (LPDWORD) & requestp->ret, NULL)) { WIN32_maperror(GetLastError()); requestp->ret = -1; } -#else - requestp->ret = pread(requestp->fd, requestp->bufferp, requestp->buflen, requestp->offset); -#endif requestp->err = errno; } @@ -792,15 +792,12 @@ static void squidaio_do_write(squidaio_request_t * requestp) { -#ifdef _SQUID_MSWIN_ + assert(requestp->offset >= 0); if (!WriteFile((HANDLE) _get_osfhandle(requestp->fd), requestp->bufferp, requestp->buflen, (LPDWORD) & requestp->ret, NULL)) { WIN32_maperror(GetLastError()); requestp->ret = -1; } -#else - requestp->ret = pwrite(requestp->fd, requestp->bufferp, requestp->buflen, requestp->offset); -#endif requestp->err = errno; } @@ -824,10 +821,8 @@ static void squidaio_do_close(squidaio_request_t * requestp) { - if ((requestp->ret = close(requestp->fd)) < 0) { + if ((requestp->ret = close(requestp->fd)) < 0) debug(43, 0) ("squidaio_do_close: FD %d, errno %d\n", requestp->fd, errno); - close(requestp->fd); - } requestp->err = errno; } @@ -943,6 +938,7 @@ fatal("couldn't push queue\n"); if (!ReleaseMutex(request_queue.mutex)) { /* unexpected error */ + fatal("couldn't push queue\n"); } request_queue2.head = NULL; request_queue2.tailp = &request_queue2.head; @@ -958,6 +954,7 @@ done_queue.tailp = &done_queue.head; if (!ReleaseMutex(done_queue.mutex)) { /* unexpected error */ + fatal("couldn't poll queue\n"); } *done_requests.tailp = requests; request_queue_len -= 1; @@ -982,10 +979,7 @@ if (request == NULL && !polled) { if (done_signalled) { char junk[256]; - fde *F = &fd_table[done_fd_read]; - int x; - if ((x = FD_READ_METHOD(done_fd_read, junk, sizeof(junk))) > 0) - F->bytes_read += x; + FD_READ_METHOD(done_fd_read, junk, sizeof(junk)); done_signalled = 0; } squidaio_poll_queues();