]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DiskIO/AIO/aio_win32.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / DiskIO / AIO / aio_win32.cc
index f1f95d2a2fa8838122f74a9cba0c2cbf3d052533..606d2473da3fe8a27b9dc1c32ee12df2fa122eaf 100644 (file)
@@ -1,7 +1,5 @@
 
 /*
- * $Id: aio_win32.cc,v 1.3 2007/04/28 22:26:40 hno Exp $
- *
  * DEBUG: section 81    aio_xxx() POSIX emulation on Windows
  * AUTHOR: Guido Serassio <serassio@squid-cache.org>
  *
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
 
 #include "squid.h"
 #include "comm.h"
-#include "aio_win32.h"
+#include "DiskIO/AIO/aio_win32.h"
+#include "fd.h"
+#include "StatCounters.h"
+#include "win32.h"
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
-#ifdef _SQUID_WIN32_
+#if _SQUID_WINDOWS_
 VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode,
                                   DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
 {
@@ -50,7 +55,6 @@ VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode,
     xfree(lpOverlapped);
 }
 
-
 int aio_read(struct aiocb *aiocbp)
 {
     LPOVERLAPPED Overlapped;
@@ -59,8 +63,7 @@ int aio_read(struct aiocb *aiocbp)
     /* Allocate an overlapped structure. */
     Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED));
 
-    if (!Overlapped)
-    {
+    if (!Overlapped) {
         errno = ENOMEM;
         return -1;
     }
@@ -99,20 +102,18 @@ int aio_read(struct aiocb *aiocbp)
                                    IoCompletionRoutine);
 
     /* Test to see if the I/O was queued successfully. */
-    if (!IoOperationStatus)
-    {
+    if (!IoOperationStatus) {
         errno = GetLastError();
-        debugs(81,1, "aio_read: GetLastError=" << errno  );
+        debugs(81, DBG_IMPORTANT, "aio_read: GetLastError=" << errno  );
         return -1;
     }
 
     /* The I/O queued successfully. Go back into the
-       alertable wait for I/O completion or for 
+       alertable wait for I/O completion or for
        more I/O requests. */
     return 0;
 }
 
-
 int aio_read64(struct aiocb64 *aiocbp)
 {
     LPOVERLAPPED Overlapped;
@@ -121,8 +122,7 @@ int aio_read64(struct aiocb64 *aiocbp)
     /* Allocate an overlapped structure. */
     Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED));
 
-    if (!Overlapped)
-    {
+    if (!Overlapped) {
         errno = ENOMEM;
         return -1;
     }
@@ -153,20 +153,18 @@ int aio_read64(struct aiocb64 *aiocbp)
                                    IoCompletionRoutine);
 
     /* Test to see if the I/O was queued successfully. */
-    if (!IoOperationStatus)
-    {
+    if (!IoOperationStatus) {
         errno = GetLastError();
-        debugs(81, 1, "aio_read: GetLastError=" << errno  );
+        debugs(81, DBG_IMPORTANT, "aio_read: GetLastError=" << errno  );
         return -1;
     }
 
     /* The I/O queued successfully. Go back into the
-       alertable wait for I/O completion or for 
+       alertable wait for I/O completion or for
        more I/O requests. */
     return 0;
 }
 
-
 int aio_write(struct aiocb *aiocbp)
 {
     LPOVERLAPPED Overlapped;
@@ -175,8 +173,7 @@ int aio_write(struct aiocb *aiocbp)
     /* Allocate an overlapped structure. */
     Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED));
 
-    if (!Overlapped)
-    {
+    if (!Overlapped) {
         errno = ENOMEM;
         return -1;
     }
@@ -215,20 +212,18 @@ int aio_write(struct aiocb *aiocbp)
                                     IoCompletionRoutine);
 
     /* Test to see if the I/O was queued successfully. */
-    if (!IoOperationStatus)
-    {
+    if (!IoOperationStatus) {
         errno = GetLastError();
-        debugs(81, 1, "aio_write: GetLastError=" << errno  );
+        debugs(81, DBG_IMPORTANT, "aio_write: GetLastError=" << errno  );
         return -1;
     }
 
     /* The I/O queued successfully. Go back into the
-       alertable wait for I/O completion or for 
+       alertable wait for I/O completion or for
        more I/O requests. */
     return 0;
 }
 
-
 int aio_write64(struct aiocb64 *aiocbp)
 {
     LPOVERLAPPED Overlapped;
@@ -237,8 +232,7 @@ int aio_write64(struct aiocb64 *aiocbp)
     /* Allocate an overlapped structure. */
     Overlapped = (LPOVERLAPPED) xcalloc(1, sizeof(OVERLAPPED));
 
-    if (!Overlapped)
-    {
+    if (!Overlapped) {
         errno = ENOMEM;
         return -1;
     }
@@ -269,32 +263,28 @@ int aio_write64(struct aiocb64 *aiocbp)
                                     IoCompletionRoutine);
 
     /* Test to see if the I/O was queued successfully. */
-    if (!IoOperationStatus)
-    {
+    if (!IoOperationStatus) {
         errno = GetLastError();
-        debugs(81, 1, "aio_write: GetLastError=" << errno  );
+        debugs(81, DBG_IMPORTANT, "aio_write: GetLastError=" << errno  );
         return -1;
     }
 
     /* The I/O queued successfully. Go back into the
-       alertable wait for I/O completion or for 
+       alertable wait for I/O completion or for
        more I/O requests. */
     return 0;
 }
 
-
 int aio_error(const struct aiocb * aiocbp)
 {
     return aiocbp->aio_sigevent.sigev_notify;
 }
 
-
 int aio_error64(const struct aiocb64 * aiocbp)
 {
     return aiocbp->aio_sigevent.sigev_notify;
 }
 
-
 int aio_open(const char *path, int mode)
 {
     HANDLE hndl;
@@ -327,7 +317,7 @@ int aio_open(const char *path, int mode)
                            FILE_FLAG_OVERLAPPED,       /* file attributes         */
                            NULL                                    /* handle to template file */
                           )) != INVALID_HANDLE_VALUE) {
-        statCounter.syscalls.disk.opens++;
+        ++ statCounter.syscalls.disk.opens;
         fd = _open_osfhandle((long) hndl, 0);
         commSetCloseOnExec(fd);
         fd_open(fd, FD_FILE, path);
@@ -339,24 +329,21 @@ int aio_open(const char *path, int mode)
     return fd;
 }
 
-
 void aio_close(int fd)
 {
     CloseHandle((HANDLE)_get_osfhandle(fd));
     fd_close(fd);
-    statCounter.syscalls.disk.closes++;
+    ++ statCounter.syscalls.disk.closes;
 }
 
-
 ssize_t aio_return(struct aiocb * aiocbp)
 {
     return aiocbp->aio_sigevent.sigev_signo;
 }
 
-
 ssize_t aio_return64(struct aiocb64 * aiocbp)
 
 {
     return aiocbp->aio_sigevent.sigev_signo;
 }
-#endif /* _SQUID_WIN32_ */
+#endif /* _SQUID_WINDOWS_ */