/*
- * $Id: aiops_win32.cc,v 1.5 2007/08/16 23:32:28 hno Exp $
+ * $Id$
*
* DEBUG: section 43 Windows AIOPS
* AUTHOR: Stewart Forster <slf@connect.com.au>
* 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 "squid_windows.h"
+#include "DiskIO/DiskThreads/CommIO.h"
#include "DiskThreads.h"
+#include "SquidTime.h"
+#include "Store.h"
#include <stdio.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <signal.h>
-#include "CommIO.h"
-#include "SquidTime.h"
-#include "Store.h"
#define RIDICULOUS_LENGTH 4096
};
typedef enum _squidaio_thread_status squidaio_thread_status;
-typedef struct squidaio_request_t
-{
+typedef struct squidaio_request_t {
struct squidaio_request_t *next;
squidaio_request_type request_type;
squidaio_result_t *resultp;
} squidaio_request_t;
-typedef struct squidaio_request_queue_t
-{
+typedef struct squidaio_request_queue_t {
HANDLE mutex;
HANDLE cond; /* See Event objects */
squidaio_request_t *volatile head;
typedef struct squidaio_thread_t squidaio_thread_t;
-struct squidaio_thread_t
-{
+struct squidaio_thread_t {
squidaio_thread_t *next;
HANDLE thread;
DWORD dwThreadId; /* thread ID */
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
static MemAllocator *squidaio_thread_pool = NULL;
static squidaio_request_queue_t request_queue;
-static struct
-{
+static struct {
squidaio_request_t *head, **tailp;
}
request_queue2 = {
- NULL, &request_queue2.head
- };
+ NULL, &request_queue2.head
+};
static squidaio_request_queue_t done_queue;
-static struct
-{
+static struct {
squidaio_request_t *head, **tailp;
}
done_requests = {
- NULL, &done_requests.head
- };
+ NULL, &done_requests.head
+};
static HANDLE main_thread;
assert(NUMTHREADS);
- for (i = 0; i < NUMTHREADS; i++) {
+ for (i = 0; i < NUMTHREADS; ++i) {
threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
threadp->status = _THREAD_STARTING;
threadp->current_req = NULL;
threadp = threads;
- for (i = 0; i < NUMTHREADS; i++) {
+ for (i = 0; i < NUMTHREADS; ++i) {
threadp->exit = 1;
hthreads[i] = threadp->thread;
threadp = threadp->next;
WaitForMultipleObjects(NUMTHREADS, hthreads, TRUE, 2000);
- for (i = 0; i < NUMTHREADS; i++) {
+ for (i = 0; i < NUMTHREADS; ++i) {
CloseHandle(hthreads[i]);
}
CommIO::NotifyIOCompleted();
Sleep(0);
- threadp->requests++;
+ ++ threadp->requests;
} /* while forever */
CloseHandle(cond);
if (++filter >= filter_limit) {
filter_limit += filter;
filter = 0;
- debugs(43, 1, "squidaio_queue_request: WARNING - Queue congestion");
+ debugs(43, DBG_IMPORTANT, "squidaio_queue_request: WARNING - Queue congestion");
}
}
if (squid_curtime >= (last_warn + 15) &&
squid_curtime >= (high_start + 5)) {
- debugs(43, 1, "squidaio_queue_request: WARNING - Disk I/O overloading");
+ debugs(43, DBG_IMPORTANT, "squidaio_queue_request: WARNING - Disk I/O overloading");
if (squid_curtime >= (high_start + 15))
- debugs(43, 1, "squidaio_queue_request: Queue Length: current=" <<
+ debugs(43, DBG_IMPORTANT, "squidaio_queue_request: Queue Length: current=" <<
request_queue_len << ", high=" << queue_high <<
", low=" << queue_low << ", duration=" <<
(long int) (squid_curtime - high_start));
/* Warn if seriously overloaded */
if (request_queue_len > RIDICULOUS_LENGTH) {
- debugs(43, 0, "squidaio_queue_request: Async request queue growing uncontrollably!");
- debugs(43, 0, "squidaio_queue_request: Syncing pending I/O operations.. (blocking)");
+ debugs(43, DBG_CRITICAL, "squidaio_queue_request: Async request queue growing uncontrollably!");
+ debugs(43, DBG_CRITICAL, "squidaio_queue_request: Syncing pending I/O operations.. (blocking)");
squidaio_sync();
- debugs(43, 0, "squidaio_queue_request: Synced");
+ debugs(43, DBG_CRITICAL, "squidaio_queue_request: Synced");
}
} /* squidaio_queue_request */
case _AIO_OP_STAT:
if (!cancelled && requestp->ret == 0)
-
- xmemcpy(requestp->statp, requestp->tmpstatp, sizeof(struct stat));
+ memcpy(requestp->statp, requestp->tmpstatp, sizeof(struct stat));
squidaio_xfree(requestp->tmpstatp, sizeof(struct stat));
squidaio_request_pool->free(requestp);
} /* squidaio_cleanup_request */
-
int
squidaio_cancel(squidaio_result_t * resultp)
{
return 1;
} /* squidaio_cancel */
-
int
squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resultp)
{
return 0;
}
-
static void
squidaio_do_open(squidaio_request_t * requestp)
{
requestp->err = errno;
}
-
int
squidaio_read(int fd, char *bufp, size_t bufs, off_t offset, int whence, squidaio_result_t * resultp)
{
return 0;
}
-
static void
squidaio_do_read(squidaio_request_t * requestp)
{
requestp->err = errno;
}
-
int
squidaio_write(int fd, char *bufp, size_t bufs, off_t offset, int whence, squidaio_result_t * resultp)
{
return 0;
}
-
static void
squidaio_do_write(squidaio_request_t * requestp)
{
requestp->err = errno;
}
-
int
squidaio_close(int fd, squidaio_result_t * resultp)
{
return 0;
}
-
static void
squidaio_do_close(squidaio_request_t * requestp)
{
- if((requestp->ret = close(requestp->fd)) < 0) {
- debugs(43, 0, "squidaio_do_close: FD " << requestp->fd << ", errno " << errno);
+ if ((requestp->ret = close(requestp->fd)) < 0) {
+ debugs(43, DBG_CRITICAL, "squidaio_do_close: FD " << requestp->fd << ", errno " << errno);
close(requestp->fd);
}
requestp->err = errno;
}
-
int
squidaio_stat(const char *path, struct stat *sb, squidaio_result_t * resultp)
return 0;
}
-
static void
squidaio_do_stat(squidaio_request_t * requestp)
{
requestp->err = errno;
}
-
int
squidaio_unlink(const char *path, squidaio_result_t * resultp)
{
return 0;
}
-
static void
squidaio_do_unlink(squidaio_request_t * requestp)
{
threadp = threads;
- for (i = 0; i < NUMTHREADS; i++) {
+ for (i = 0; i < NUMTHREADS; ++i) {
storeAppendPrintf(sentry, "%i\t0x%lx\t%ld\n", i + 1, threadp->dwThreadId, threadp->requests);
threadp = threadp->next;
}