--------------------- PatchSet 1155 Date: 2005/01/01 19:56:22 Author: serassio Branch: nt Tag: (none) Log: Ran Astyle Members: src/DiskIO/WinAIO/WinAIODiskFile.cc:1.1.2.1->1.1.2.2 src/DiskIO/WinAIO/Winaio.cc:1.1.2.1->1.1.2.2 src/DiskIO/WinAIO/Winaio.h:1.1.2.1->1.1.2.2 Index: squid3/src/DiskIO/WinAIO/WinAIODiskFile.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/DiskIO/WinAIO/Attic/WinAIODiskFile.cc,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/DiskIO/WinAIO/WinAIODiskFile.cc 26 Dec 2004 09:23:30 -0000 1.1.2.1 +++ squid3/src/DiskIO/WinAIO/WinAIODiskFile.cc 1 Jan 2005 19:56:22 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: WinAIODiskFile.cc,v 1.1.2.1 2004/12/26 09:23:30 serassio Exp $ + * $Id: WinAIODiskFile.cc,v 1.1.2.2 2005/01/01 19:56:22 serassio Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -156,7 +156,7 @@ if (aio_read(&qe->aq_e_aiocb) < 0) { fatalf("Aiee! aio_read() returned error (%d) FIXME and wrap file_read !\n", errno); debug(79, 1) ("WARNING: aio_read() returned error: %s\n", xstrerror()); - } + } } Index: squid3/src/DiskIO/WinAIO/Winaio.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/DiskIO/WinAIO/Attic/Winaio.cc,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/DiskIO/WinAIO/Winaio.cc 26 Dec 2004 09:23:30 -0000 1.1.2.1 +++ squid3/src/DiskIO/WinAIO/Winaio.cc 1 Jan 2005 19:56:23 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: Winaio.cc,v 1.1.2.1 2004/12/26 09:23:30 serassio Exp $ + * $Id: Winaio.cc,v 1.1.2.2 2005/01/01 19:56:23 serassio Exp $ * * DEBUG: section 81 aio_xxx() POSIX emulation on WIN32 for COSS * AUTHOR: Guido Serassio @@ -37,60 +37,75 @@ #include "Winaio.h" #ifdef _SQUID_WIN32_ -VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode, - DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) -{ +VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode, + DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) +{ + struct aiocb *aiocbp = (struct aiocb *) lpOverlapped->hEvent; aiocbp->aio_sigevent.sigev_notify = dwErrorCode; aiocbp->aio_sigevent.sigev_signo = dwNumberOfBytesTransfered; debug(81,7) ("AIO operation complete: errorcode=%ld nbytes=%ld\n", dwErrorCode, dwNumberOfBytesTransfered); - xfree(lpOverlapped); -} + xfree(lpOverlapped); +} int aio_read(struct aiocb *aiocbp) { LPOVERLAPPED Overlapped; - BOOL IoOperationStatus; + BOOL IoOperationStatus; /* Allocate an overlapped structure. */ - Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); - if (!Overlapped) { - errno = ENOMEM; - return -1; - } + Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); + + if (!Overlapped) + { + errno = ENOMEM; + return -1; + } #if _FILE_OFFSET_BITS==64 #ifdef __GNUC__ Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL); + #else + Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000); -#endif + +#endif #else - Overlapped->Offset = aiocbp->aio_offset; + + Overlapped->Offset = aiocbp->aio_offset; + Overlapped->OffsetHigh = 0; + #endif + Overlapped->hEvent = aiocbp; + aiocbp->aio_sigevent.sigev_notify = EINPROGRESS; + aiocbp->aio_sigevent.sigev_signo = -1; IoOperationStatus = ReadFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes), - aiocbp->aio_buf, - aiocbp->aio_nbytes, - Overlapped, - IoCompletionRoutine); + aiocbp->aio_buf, + aiocbp->aio_nbytes, + Overlapped, + IoCompletionRoutine); /* Test to see if the I/O was queued successfully. */ - if (!IoOperationStatus) { - errno = GetLastError(); - debug(81,1) ("aio_read: GetLastError=%i\n", errno); - return -1; + if (!IoOperationStatus) + { + errno = GetLastError(); + debug(81,1) ("aio_read: GetLastError=%i\n", errno); + return -1; } - /* The I/O queued successfully. Go back into the + /* The I/O queued successfully. Go back into the alertable wait for I/O completion or for more I/O requests. */ return 0; @@ -100,40 +115,51 @@ int aio_read64(struct aiocb64 *aiocbp) { LPOVERLAPPED Overlapped; - BOOL IoOperationStatus; + BOOL IoOperationStatus; /* Allocate an overlapped structure. */ - Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); - if (!Overlapped) { - errno = ENOMEM; - return -1; - } + Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); + + if (!Overlapped) + { + errno = ENOMEM; + return -1; + } #ifdef __GNUC__ Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL); + #else + Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL); + #endif + Overlapped->hEvent = aiocbp; + aiocbp->aio_sigevent.sigev_notify = EINPROGRESS; + aiocbp->aio_sigevent.sigev_signo = -1; IoOperationStatus = ReadFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes), - aiocbp->aio_buf, - aiocbp->aio_nbytes, - Overlapped, - IoCompletionRoutine); + aiocbp->aio_buf, + aiocbp->aio_nbytes, + Overlapped, + IoCompletionRoutine); /* Test to see if the I/O was queued successfully. */ - if (!IoOperationStatus) { - errno = GetLastError(); - debug(81,1) ("aio_read: GetLastError=%i\n", errno); - return -1; + if (!IoOperationStatus) + { + errno = GetLastError(); + debug(81,1) ("aio_read: GetLastError=%i\n", errno); + return -1; } - /* The I/O queued successfully. Go back into the + /* The I/O queued successfully. Go back into the alertable wait for I/O completion or for more I/O requests. */ return 0; @@ -144,44 +170,59 @@ { LPOVERLAPPED Overlapped; - BOOL IoOperationStatus; + BOOL IoOperationStatus; /* Allocate an overlapped structure. */ - Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); - if (!Overlapped) { - errno = ENOMEM; - return -1; - } + Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); + + if (!Overlapped) + { + errno = ENOMEM; + return -1; + } + #if _FILE_OFFSET_BITS==64 #ifdef __GNUC__ Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL); + #else + Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000); + #endif #else - Overlapped->Offset = aiocbp->aio_offset; + + Overlapped->Offset = aiocbp->aio_offset; + Overlapped->OffsetHigh = 0; + #endif + Overlapped->hEvent = aiocbp; + aiocbp->aio_sigevent.sigev_notify = EINPROGRESS; + aiocbp->aio_sigevent.sigev_signo = -1; IoOperationStatus = WriteFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes), - aiocbp->aio_buf, - aiocbp->aio_nbytes, - Overlapped, - IoCompletionRoutine); - + aiocbp->aio_buf, + aiocbp->aio_nbytes, + Overlapped, + IoCompletionRoutine); + /* Test to see if the I/O was queued successfully. */ - if (!IoOperationStatus) { - errno = GetLastError(); - debug(81,1) ("aio_write: GetLastError=%i\n", errno); - return -1; + if (!IoOperationStatus) + { + errno = GetLastError(); + debug(81,1) ("aio_write: GetLastError=%i\n", errno); + return -1; } - /* The I/O queued successfully. Go back into the + /* The I/O queued successfully. Go back into the alertable wait for I/O completion or for more I/O requests. */ return 0; @@ -192,39 +233,51 @@ { LPOVERLAPPED Overlapped; - BOOL IoOperationStatus; + BOOL IoOperationStatus; /* Allocate an overlapped structure. */ - Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); - if (!Overlapped) { - errno = ENOMEM; - return -1; - } + Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED)); + + if (!Overlapped) + { + errno = ENOMEM; + return -1; + } + #ifdef __GNUC__ Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL); + #else + Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000); + Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000); + #endif + Overlapped->hEvent = aiocbp; + aiocbp->aio_sigevent.sigev_notify = EINPROGRESS; + aiocbp->aio_sigevent.sigev_signo = -1; IoOperationStatus = WriteFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes), - aiocbp->aio_buf, - aiocbp->aio_nbytes, - Overlapped, - IoCompletionRoutine); - + aiocbp->aio_buf, + aiocbp->aio_nbytes, + Overlapped, + IoCompletionRoutine); + /* Test to see if the I/O was queued successfully. */ - if (!IoOperationStatus) { - errno = GetLastError(); - debug(81,1) ("aio_write: GetLastError=%i\n", errno); - return -1; + if (!IoOperationStatus) + { + errno = GetLastError(); + debug(81,1) ("aio_write: GetLastError=%i\n", errno); + return -1; } - /* The I/O queued successfully. Go back into the + /* The I/O queued successfully. Go back into the alertable wait for I/O completion or for more I/O requests. */ return 0; @@ -234,7 +287,7 @@ ssize_t aio_return(struct aiocb * aiocbp) { - return aiocbp->aio_sigevent.sigev_signo; + return aiocbp->aio_sigevent.sigev_signo; } @@ -260,6 +313,7 @@ int aio_open(const char *path, int mode) + { HANDLE hndl; DWORD dwCreationDisposition; @@ -267,34 +321,39 @@ int fd; if (mode & O_WRONLY) - mode |= O_APPEND; + mode |= O_APPEND; + mode |= O_BINARY; + errno = 0; + if (mode & O_WRONLY) dwDesiredAccess = GENERIC_WRITE; else - dwDesiredAccess = (mode & O_RDONLY) ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE; + dwDesiredAccess = (mode & O_RDONLY) ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE; + if (mode & O_TRUNC) dwCreationDisposition = CREATE_ALWAYS; else - dwCreationDisposition = (mode & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING; + dwCreationDisposition = (mode & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING; - if ((hndl = CreateFile(path, /* file name */ - dwDesiredAccess, /* access mode */ - 0, /* share mode */ - NULL, /* SD */ - dwCreationDisposition, /* how to create */ - FILE_FLAG_OVERLAPPED, /* file attributes */ - NULL /* handle to template file */ - )) != INVALID_HANDLE_VALUE) { - statCounter.syscalls.disk.opens++; - fd = _open_osfhandle((long) hndl, 0); - commSetCloseOnExec(fd); - fd_open(fd, FD_FILE, path); + if ((hndl = CreateFile(path, /* file name */ + dwDesiredAccess, /* access mode */ + 0, /* share mode */ + NULL, /* SD */ + dwCreationDisposition, /* how to create */ + FILE_FLAG_OVERLAPPED, /* file attributes */ + NULL /* handle to template file */ + )) != INVALID_HANDLE_VALUE) { + statCounter.syscalls.disk.opens++; + fd = _open_osfhandle((long) hndl, 0); + commSetCloseOnExec(fd); + fd_open(fd, FD_FILE, path); } else { - errno = GetLastError(); - fd = DISK_ERROR; + errno = GetLastError(); + fd = DISK_ERROR; } + return fd; } @@ -305,4 +364,5 @@ fd_close(fd); statCounter.syscalls.disk.closes++; } + #endif Index: squid3/src/DiskIO/WinAIO/Winaio.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/DiskIO/WinAIO/Attic/Winaio.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/DiskIO/WinAIO/Winaio.h 26 Dec 2004 09:23:30 -0000 1.1.2.1 +++ squid3/src/DiskIO/WinAIO/Winaio.h 1 Jan 2005 19:56:23 -0000 1.1.2.2 @@ -14,43 +14,58 @@ void *sival_ptr; /* pointer value */ }; -struct sigevent { +struct sigevent +{ int sigev_notify; /* notification mode */ int sigev_signo; /* signal number */ union sigval sigev_value; /* signal value */ }; -struct aiocb64 { +struct aiocb64 +{ int aio_fildes; /* file descriptor */ void *aio_buf; /* buffer location */ size_t aio_nbytes; /* length of transfer */ off64_t aio_offset; /* file offset */ int aio_reqprio; /* request priority offset */ + struct sigevent aio_sigevent; /* signal number and offset */ int aio_lio_opcode; /* listio operation */ }; -struct aiocb { +struct aiocb +{ int aio_fildes; /* file descriptor */ void *aio_buf; /* buffer location */ size_t aio_nbytes; /* length of transfer */ #if (_FILE_OFFSET_BITS == 64) + off64_t aio_offset; /* file offset */ #else + off_t aio_offset; /* file offset */ #endif + int aio_reqprio; /* request priority offset */ + struct sigevent aio_sigevent; /* signal number and offset */ int aio_lio_opcode; /* listio operation */ }; int aio_read(struct aiocb *); + int aio_write(struct aiocb *); + ssize_t aio_return(struct aiocb *); + int aio_error(const struct aiocb *); + int aio_read64(struct aiocb64 *); + int aio_write64(struct aiocb64 *); + ssize_t aio_return64(struct aiocb64 *); + int aio_error64(const struct aiocb64 *); int aio_open(const char *, int); void aio_close(int);