]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DiskIO/DiskThreads/aiops_win32.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / DiskIO / DiskThreads / aiops_win32.cc
index dc799d12ca289111690424a55fb48ea06c6d4881..2182a523a7e835b36751f630de9b4d966cdfb36e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -23,7 +23,7 @@
 #include <fcntl.h>
 #include <dirent.h>
 
-#define RIDICULOUS_LENGTH      4096
+#define RIDICULOUS_LENGTH   4096
 
 enum _squidaio_thread_status {
     _THREAD_STARTING = 0,
@@ -63,7 +63,7 @@ typedef struct squidaio_request_queue_t {
     squidaio_request_t *volatile head;
     squidaio_request_t *volatile *volatile tailp;
     unsigned long requests;
-    unsigned long blocked;     /* main failed to lock the queue */
+    unsigned long blocked;  /* main failed to lock the queue */
 } squidaio_request_queue_t;
 
 typedef struct squidaio_thread_t squidaio_thread_t;
@@ -98,16 +98,16 @@ static squidaio_thread_t *threads = NULL;
 static int squidaio_initialised = 0;
 
 #define AIO_LARGE_BUFS  16384
-#define AIO_MEDIUM_BUFS        AIO_LARGE_BUFS >> 1
-#define AIO_SMALL_BUFS AIO_LARGE_BUFS >> 2
-#define AIO_TINY_BUFS  AIO_LARGE_BUFS >> 3
-#define AIO_MICRO_BUFS 128
+#define AIO_MEDIUM_BUFS AIO_LARGE_BUFS >> 1
+#define AIO_SMALL_BUFS  AIO_LARGE_BUFS >> 2
+#define AIO_TINY_BUFS   AIO_LARGE_BUFS >> 3
+#define AIO_MICRO_BUFS  128
 
-static MemAllocator *squidaio_large_bufs = NULL;       /* 16K */
-static MemAllocator *squidaio_medium_bufs = NULL;      /* 8K */
-static MemAllocator *squidaio_small_bufs = NULL;       /* 4K */
-static MemAllocator *squidaio_tiny_bufs = NULL;        /* 2K */
-static MemAllocator *squidaio_micro_bufs = NULL;       /* 128K */
+static MemAllocator *squidaio_large_bufs = NULL;    /* 16K */
+static MemAllocator *squidaio_medium_bufs = NULL;   /* 8K */
+static MemAllocator *squidaio_small_bufs = NULL;    /* 4K */
+static MemAllocator *squidaio_tiny_bufs = NULL; /* 2K */
+static MemAllocator *squidaio_micro_bufs = NULL;    /* 128K */
 
 static int request_queue_len = 0;
 static MemAllocator *squidaio_request_pool = NULL;
@@ -279,7 +279,7 @@ squidaio_init(void)
     /* Create threads and get them to sit in their wait loop */
     squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));
 
-    assert(NUMTHREADS);
+    assert(NUMTHREADS > 0);
 
     for (i = 0; i < NUMTHREADS; ++i) {
         threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
@@ -486,7 +486,7 @@ squidaio_thread_loop(LPVOID lpParam)
                 squidaio_do_unlink(request);
                 break;
 
-#if AIO_OPENDIR                        /* Opendir not implemented yet */
+#if AIO_OPENDIR         /* Opendir not implemented yet */
 
             case _AIO_OP_OPENDIR:
                 squidaio_do_opendir(request);
@@ -502,7 +502,7 @@ squidaio_thread_loop(LPVOID lpParam)
                 request->err = EINVAL;
                 break;
             }
-        } else {               /* cancelled */
+        } else {        /* cancelled */
             request->ret = -1;
             request->err = EINTR;
         }
@@ -527,12 +527,12 @@ squidaio_thread_loop(LPVOID lpParam)
         CommIO::NotifyIOCompleted();
         Sleep(0);
         ++ threadp->requests;
-    }                          /* while forever */
+    }               /* while forever */
 
     CloseHandle(cond);
 
     return 0;
-}                              /* squidaio_thread_loop */
+}               /* squidaio_thread_loop */
 
 static void
 squidaio_queue_request(squidaio_request_t * request)
@@ -582,13 +582,13 @@ squidaio_queue_request(squidaio_request_t * request)
     }
 
     if (request_queue2.head) {
-        static int filter = 0;
-        static int filter_limit = 8;
+        static uint64_t filter = 0;
+        static uint64_t filter_limit = 8196;
 
         if (++filter >= filter_limit) {
             filter_limit += filter;
             filter = 0;
-            debugs(43, DBG_IMPORTANT, "squidaio_queue_request: WARNING - Queue congestion");
+            debugs(43, DBG_IMPORTANT, "squidaio_queue_request: WARNING - Queue congestion (growing to " << filter_limit << ")");
         }
     }
 
@@ -632,7 +632,7 @@ squidaio_queue_request(squidaio_request_t * request)
         squidaio_sync();
         debugs(43, DBG_CRITICAL, "squidaio_queue_request: Synced");
     }
-}                              /* squidaio_queue_request */
+}               /* squidaio_queue_request */
 
 static void
 squidaio_cleanup_request(squidaio_request_t * requestp)
@@ -695,7 +695,7 @@ squidaio_cleanup_request(squidaio_request_t * requestp)
     }
 
     squidaio_request_pool->freeOne(requestp);
-}                              /* squidaio_cleanup_request */
+}               /* squidaio_cleanup_request */
 
 int
 squidaio_cancel(squidaio_result_t * resultp)
@@ -712,7 +712,7 @@ squidaio_cancel(squidaio_result_t * resultp)
     }
 
     return 1;
-}                              /* squidaio_cancel */
+}               /* squidaio_cancel */
 
 int
 squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resultp)
@@ -1045,7 +1045,7 @@ AIO_REPOLL:
         goto AIO_REPOLL;
 
     return resultp;
-}                              /* squidaio_poll_done */
+}               /* squidaio_poll_done */
 
 int
 squidaio_operations_pending(void)
@@ -1121,3 +1121,4 @@ squidaio_stats(StoreEntry * sentry)
         threadp = threadp->next;
     }
 }
+