亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? aiops_win32.c

?? 代理服務器 squid-2.6.STABLE16
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * $Id: aiops_win32.c,v 1.3 2006/09/23 10:16:40 serassio Exp $ * * DEBUG: section 43    Windows AIOPS * AUTHOR: Stewart Forster <slf@connect.com.au> * AUTHOR: Robert Collins <robertc@squid-cache.org> * AUTHOR: Guido Serassio <serassio@squid-cache.org> * * SQUID Web Proxy Cache          http://www.squid-cache.org/ * ---------------------------------------------------------- * *  Squid is the result of efforts by numerous individuals from *  the Internet community; see the CONTRIBUTORS file for full *  details.   Many organizations have provided support for Squid's *  development; see the SPONSORS file for full details.  Squid is *  Copyrighted (C) 2001 by the Regents of the University of *  California; see the COPYRIGHT file for full details.  Squid *  incorporates software developed and/or copyrighted by other *  sources; see the CREDITS file for full details. * *  This program is free software; you can redistribute it and/or modify *  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 <windows.h>#include "async_io.h"#include	<stdio.h>#include	<sys/types.h>#include	<sys/stat.h>#include	<fcntl.h>#include	<errno.h>#include	<dirent.h>#include	<signal.h>#define RIDICULOUS_LENGTH	4096#ifdef AUFS_IO_THREADSint squidaio_nthreads = AUFS_IO_THREADS;#elseint squidaio_nthreads = 0;#endifint squidaio_magic1 = 1;	/* dummy initializer value */int squidaio_magic2 = 1;	/* real value set in aiops.c */enum _squidaio_thread_status {    _THREAD_STARTING = 0,    _THREAD_WAITING,    _THREAD_BUSY,    _THREAD_FAILED,    _THREAD_DONE};typedef enum _squidaio_thread_status squidaio_thread_status;enum _squidaio_request_type {    _AIO_OP_NONE = 0,    _AIO_OP_OPEN,    _AIO_OP_READ,    _AIO_OP_WRITE,    _AIO_OP_CLOSE,    _AIO_OP_UNLINK,    _AIO_OP_TRUNCATE,    _AIO_OP_OPENDIR,    _AIO_OP_STAT};typedef enum _squidaio_request_type squidaio_request_type;typedef struct squidaio_request_t {    struct squidaio_request_t *next;    squidaio_request_type request_type;    int cancelled;    char *path;    int oflag;    mode_t mode;    int fd;    char *bufferp;    int buflen;    off_t offset;    int whence;    int ret;    int err;    struct stat *tmpstatp;    struct stat *statp;    squidaio_result_t *resultp;} squidaio_request_t;typedef struct squidaio_request_queue_t {    HANDLE mutex;    HANDLE cond;		/* See Event objects */    squidaio_request_t *volatile head;    squidaio_request_t *volatile *volatile tailp;    unsigned long requests;    unsigned long blocked;	/* main failed to lock the queue */} squidaio_request_queue_t;typedef struct squidaio_thread_t squidaio_thread_t;struct squidaio_thread_t {    squidaio_thread_t *next;    HANDLE thread;    DWORD dwThreadId;		/* thread ID */    squidaio_thread_status status;    struct squidaio_request_t *current_req;    unsigned long requests;    int volatile exit;};static void squidaio_queue_request(squidaio_request_t *);static void squidaio_cleanup_request(squidaio_request_t *);static DWORD WINAPI squidaio_thread_loop(LPVOID lpParam);static void squidaio_do_open(squidaio_request_t *);static void squidaio_do_read(squidaio_request_t *);static void squidaio_do_write(squidaio_request_t *);static void squidaio_do_close(squidaio_request_t *);static void squidaio_do_stat(squidaio_request_t *);static void squidaio_do_unlink(squidaio_request_t *);#if USE_TRUNCATEstatic void squidaio_do_truncate(squidaio_request_t *);#endif#if AIO_OPENDIRstatic void *squidaio_do_opendir(squidaio_request_t *);#endifstatic void squidaio_debug(squidaio_request_t *);static void squidaio_poll_queues(void);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	128static MemPool *squidaio_large_bufs = NULL;	/* 16K */static MemPool *squidaio_medium_bufs = NULL;	/* 8K */static MemPool *squidaio_small_bufs = NULL;	/* 4K */static MemPool *squidaio_tiny_bufs = NULL;	/* 2K */static MemPool *squidaio_micro_bufs = NULL;	/* 128K */static int request_queue_len = 0;static MemPool *squidaio_request_pool = NULL;static MemPool *squidaio_thread_pool = NULL;static squidaio_request_queue_t request_queue;static struct {    squidaio_request_t *head, **tailp;} request_queue2 = {    NULL, &request_queue2.head};static squidaio_request_queue_t done_queue;static struct {    squidaio_request_t *head, **tailp;} done_requests = {    NULL, &done_requests.head};static int done_fd = 0;static int done_fd_read = 0;static int done_signalled = 0;static HANDLE main_thread;static MemPool *squidaio_get_pool(int size){    MemPool *p;    if (size <= AIO_LARGE_BUFS) {	if (size <= AIO_MICRO_BUFS)	    p = squidaio_micro_bufs;	else if (size <= AIO_TINY_BUFS)	    p = squidaio_tiny_bufs;	else if (size <= AIO_SMALL_BUFS)	    p = squidaio_small_bufs;	else if (size <= AIO_MEDIUM_BUFS)	    p = squidaio_medium_bufs;	else	    p = squidaio_large_bufs;    } else	p = NULL;    return p;}void *squidaio_xmalloc(int size){    void *p;    MemPool *pool;    if ((pool = squidaio_get_pool(size)) != NULL) {	p = memPoolAlloc(pool);    } else	p = xmalloc(size);    return p;}static char *squidaio_xstrdup(const char *str){    char *p;    int len = strlen(str) + 1;    p = squidaio_xmalloc(len);    strncpy(p, str, len);    return p;}voidsquidaio_xfree(void *p, int size){    MemPool *pool;    if ((pool = squidaio_get_pool(size)) != NULL) {	memPoolFree(pool, p);    } else	xfree(p);}static voidsquidaio_xstrfree(char *str){    MemPool *pool;    int len = strlen(str) + 1;    if ((pool = squidaio_get_pool(len)) != NULL) {	memPoolFree(pool, str);    } else	xfree(str);}static voidsquidaio_fdhandler(int fd, void *data){    char junk[256];    FD_READ_METHOD(done_fd_read, junk, sizeof(junk));    commSetSelect(fd, COMM_SELECT_READ, squidaio_fdhandler, NULL, 0);}voidsquidaio_init(void){    int i;    int done_pipe[2];    squidaio_thread_t *threadp;    if (squidaio_initialised)	return;    if (!DuplicateHandle(GetCurrentProcess(),	/* pseudo handle, don't close */	    GetCurrentThread(),	/* pseudo handle to copy */	    GetCurrentProcess(),	/* pseudo handle, don't close */	    &main_thread,	    0,			/* required access */	    FALSE,		/* child process's don't inherit the handle */	    DUPLICATE_SAME_ACCESS)) {	/* spit errors */	fatal("couldn't get current thread handle\n");    }    /* Initialize request queue */    if ((request_queue.mutex = CreateMutex(NULL,	/* no inheritance */		FALSE,		/* start unowned (as per mutex_init) */		NULL)		/* no name */	) == NULL) {	fatal("failed to create mutex\n");    }    if ((request_queue.cond = CreateEvent(NULL,		/* no inheritance */		FALSE,		/* auto signal reset - which I think is pthreads like ? */		FALSE,		/* start non signaled */		NULL)		/* no name */	) == NULL) {	fatal("failed to create condition event variable.\n");    }    request_queue.head = NULL;    request_queue.tailp = &request_queue.head;    request_queue.requests = 0;    request_queue.blocked = 0;    /* Initialize done queue */    if ((done_queue.mutex = CreateMutex(NULL,	/* no inheritance */		FALSE,		/* start unowned (as per mutex_init) */		NULL)		/* no name */	) == NULL) {	fatal("failed to create mutex\n");    }    if ((done_queue.cond = CreateEvent(NULL,	/* no inheritance */		TRUE,		/* manually signaled - which I think is pthreads like ? */		FALSE,		/* start non signaled */		NULL)		/* no name */	) == NULL) {	fatal("failed to create condition event variable.\n");    }    done_queue.head = NULL;    done_queue.tailp = &done_queue.head;    done_queue.requests = 0;    done_queue.blocked = 0;    /* Initialize done pipe signal */    pipe(done_pipe);    done_fd = done_pipe[1];    done_fd_read = done_pipe[0];    fd_open(done_fd_read, FD_PIPE, "async-io completion event: main");    fd_open(done_fd, FD_PIPE, "async-io completion event: threads");    commSetNonBlocking(done_pipe[0]);    commSetNonBlocking(done_pipe[1]);    commSetCloseOnExec(done_pipe[0]);    commSetCloseOnExec(done_pipe[1]);    commSetSelect(done_pipe[0], COMM_SELECT_READ, squidaio_fdhandler, NULL, 0);    /* Create threads and get them to sit in their wait loop */    squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));    if (squidaio_nthreads == 0) {	int j = 16;	for (i = 0; i < n_asyncufs_dirs; i++) {	    squidaio_nthreads += j;	    j = j * 2 / 3;	    if (j < 4)		j = 4;	}#if USE_AUFSOPS	j = 6;	for (i = 0; i < n_coss_dirs; i++) {	    squidaio_nthreads += j;	    j = 3;	}#endif    }    if (squidaio_nthreads == 0)	squidaio_nthreads = 16;    squidaio_magic1 = squidaio_nthreads * MAGIC1_FACTOR;    squidaio_magic2 = squidaio_nthreads * MAGIC2_FACTOR;    for (i = 0; i < squidaio_nthreads; i++) {	threadp = memPoolAlloc(squidaio_thread_pool);	threadp->status = _THREAD_STARTING;	threadp->current_req = NULL;	threadp->requests = 0;	threadp->next = threads;	threads = threadp;	if ((threadp->thread = CreateThread(NULL,	/* no security attributes */		    0,		/* use default stack size */		    squidaio_thread_loop,	/* thread function */		    threadp,	/* argument to thread function */		    0,		/* use default creation flags */		    &(threadp->dwThreadId))	/* returns the thread identifier */	    ) == NULL) {	    fprintf(stderr, "Thread creation failed\n");	    threadp->status = _THREAD_FAILED;	    continue;	}	/* Set the new thread priority above parent process */	SetThreadPriority(threadp->thread, THREAD_PRIORITY_ABOVE_NORMAL);    }    /* Create request pool */    squidaio_request_pool = memPoolCreate("aio_request", sizeof(squidaio_request_t));    squidaio_large_bufs = memPoolCreate("squidaio_large_bufs", AIO_LARGE_BUFS);    squidaio_medium_bufs = memPoolCreate("squidaio_medium_bufs", AIO_MEDIUM_BUFS);    squidaio_small_bufs = memPoolCreate("squidaio_small_bufs", AIO_SMALL_BUFS);    squidaio_tiny_bufs = memPoolCreate("squidaio_tiny_bufs", AIO_TINY_BUFS);    squidaio_micro_bufs = memPoolCreate("squidaio_micro_bufs", AIO_MICRO_BUFS);    squidaio_initialised = 1;}voidsquidaio_shutdown(void){    squidaio_thread_t *threadp;    int i;    HANDLE *hthreads;    if (!squidaio_initialised)	return;    /* This is the same as in squidaio_sync */    do {	squidaio_poll_queues();    } while (request_queue_len > 0);    hthreads = (HANDLE *) xcalloc(squidaio_nthreads, sizeof(HANDLE));    threadp = threads;    for (i = 0; i < squidaio_nthreads; i++) {	threadp->exit = 1;	hthreads[i] = threadp->thread;	threadp = threadp->next;    }    ReleaseMutex(request_queue.mutex);    ResetEvent(request_queue.cond);    ReleaseMutex(done_queue.mutex);    ResetEvent(done_queue.cond);    Sleep(0);    WaitForMultipleObjects(squidaio_nthreads, hthreads, TRUE, 2000);    for (i = 0; i < squidaio_nthreads; i++) {	CloseHandle(hthreads[i]);    }    CloseHandle(main_thread);    xfree(hthreads);    fd_close(done_fd);    fd_close(done_fd_read);    close(done_fd);    close(done_fd_read);}static DWORD WINAPIsquidaio_thread_loop(LPVOID lpParam){    squidaio_thread_t *threadp = lpParam;    squidaio_request_t *request;    HANDLE cond;		/* local copy of the event queue because win32 event handles				 * don't atomically release the mutex as cond variables do. */    /* lock the thread info */    if (WAIT_FAILED == WaitForSingleObject(request_queue.mutex, INFINITE)) {	fatal("Can't get ownership of mutex\n");    }    /* duplicate the handle */    if (!DuplicateHandle(GetCurrentProcess(),	/* pseudo handle, don't close */	    request_queue.cond,	/* handle to copy */	    GetCurrentProcess(),	/* pseudo handle, don't close */	    &cond,	    0,			/* required access */	    FALSE,		/* child process's don't inherit the handle */	    DUPLICATE_SAME_ACCESS))	fatal("Can't duplicate mutex handle\n");    if (!ReleaseMutex(request_queue.mutex)) {	CloseHandle(cond);	fatal("Can't release mutex\n");    }    while (1) {	DWORD rv;	threadp->current_req = request = NULL;	request = NULL;	/* Get a request to process */	threadp->status = _THREAD_WAITING;	if (threadp->exit) {	    CloseHandle(request_queue.mutex);	    CloseHandle(cond);	    return 0;	}	rv = WaitForSingleObject(request_queue.mutex, INFINITE);	if (rv == WAIT_FAILED) {	    CloseHandle(cond);	    return 1;	}	while (!request_queue.head) {	    if (!ReleaseMutex(request_queue.mutex)) {		CloseHandle(cond);		threadp->status = _THREAD_FAILED;		return 1;	    }	    rv = WaitForSingleObject(cond, INFINITE);	    if (rv == WAIT_FAILED) {		CloseHandle(cond);		return 1;	    }	    rv = WaitForSingleObject(request_queue.mutex, INFINITE);	    if (rv == WAIT_FAILED) {		CloseHandle(cond);		return 1;	    }	}	request = request_queue.head;	if (request)	    request_queue.head = request->next;	if (!request_queue.head)	    request_queue.tailp = &request_queue.head;	if (!ReleaseMutex(request_queue.mutex)) {	    CloseHandle(cond);	    return 1;	}	/* process the request */	threadp->status = _THREAD_BUSY;	request->next = NULL;	threadp->current_req = request;	errno = 0;	if (!request->cancelled) {	    switch (request->request_type) {	    case _AIO_OP_OPEN:		squidaio_do_open(request);		break;	    case _AIO_OP_READ:		squidaio_do_read(request);		break;	    case _AIO_OP_WRITE:		squidaio_do_write(request);		break;	    case _AIO_OP_CLOSE:		squidaio_do_close(request);		break;	    case _AIO_OP_UNLINK:		squidaio_do_unlink(request);		break;#if USE_TRUNCATE	    case _AIO_OP_TRUNCATE:		squidaio_do_truncate(request);		break;#endif#if AIO_OPENDIR			/* Opendir not implemented yet */	    case _AIO_OP_OPENDIR:		squidaio_do_opendir(request);		break;#endif	    case _AIO_OP_STAT:		squidaio_do_stat(request);		break;	    default:		request->ret = -1;		request->err = EINVAL;		break;	    }	} else {		/* cancelled */	    request->ret = -1;	    request->err = EINTR;	}	threadp->status = _THREAD_DONE;	/* put the request in the done queue */	rv = WaitForSingleObject(done_queue.mutex, INFINITE);	if (rv == WAIT_FAILED) {	    CloseHandle(cond);	    return 1;	}	*done_queue.tailp = request;	done_queue.tailp = &request->next;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品人人做人人爽人人添| 欧美一区二区福利在线| 综合久久一区二区三区| 成人av第一页| 亚洲欧美另类小说视频| 欧美图区在线视频| 五月婷婷激情综合| 26uuu色噜噜精品一区| 成人午夜短视频| 伊人一区二区三区| 欧美久久久久久久久久| 国产在线视频一区二区三区| 国产精品丝袜在线| 欧美视频一区二区在线观看| 久久精品国产999大香线蕉| 国产欧美一区二区三区在线看蜜臀| 丁香桃色午夜亚洲一区二区三区| 亚洲色图.com| 欧美大度的电影原声| 国产成人午夜片在线观看高清观看| 国产精品久久久久久久久免费丝袜| 日本久久一区二区三区| 美国av一区二区| 国产精品私人自拍| 91精品国产91久久久久久一区二区 | 九一久久久久久| 国产精品美女视频| 日韩一区二区免费在线电影| 成人av影视在线观看| 日一区二区三区| 中文字幕在线不卡| 337p亚洲精品色噜噜噜| av电影在线观看一区| 蜜臀a∨国产成人精品| 国产精品初高中害羞小美女文 | 日韩欧美的一区| 不卡的电视剧免费网站有什么| 午夜精品久久久久影视| 国产精品久久久久影院| 日韩视频免费观看高清完整版| 99re成人精品视频| 极品少妇一区二区三区精品视频| 一区二区欧美在线观看| 欧美国产在线观看| 91精品国产综合久久香蕉的特点| 99久久免费国产| 国产一区二区三区视频在线播放| 亚洲bdsm女犯bdsm网站| 亚洲人成精品久久久久久| 久久免费美女视频| 91麻豆精品国产无毒不卡在线观看| jiyouzz国产精品久久| 精品亚洲成a人| 丝袜诱惑制服诱惑色一区在线观看 | 免费成人美女在线观看| 亚洲电影第三页| 亚洲欧美日韩国产另类专区 | 日本韩国欧美国产| 国产999精品久久| 国内精品久久久久影院一蜜桃| 亚洲国产精品一区二区久久恐怖片 | 亚洲国产精品激情在线观看| 久久网这里都是精品| 日韩一本二本av| 欧美精品第一页| 欧美喷水一区二区| 欧美日韩国产精选| 欧美系列日韩一区| 日本精品一区二区三区四区的功能| 成人久久久精品乱码一区二区三区| 国产成人综合在线观看| 国产在线国偷精品免费看| 看电视剧不卡顿的网站| 美女视频黄 久久| 免费成人在线视频观看| 久久精品国产久精国产| 韩国成人福利片在线播放| 激情五月婷婷综合| 国产一区二区视频在线| 国产精品99久久久久久似苏梦涵| 国产精品自在在线| 国产黄色精品视频| 成人精品gif动图一区| 91视频国产观看| 在线观看视频欧美| 欧美蜜桃一区二区三区| 日韩午夜激情视频| 久久久午夜精品理论片中文字幕| 国产午夜一区二区三区| 一区精品在线播放| 亚洲国产精品一区二区www| 午夜精品久久久久久久久| 青青草伊人久久| 国产精品综合网| 色哟哟日韩精品| 欧美日韩中文字幕精品| 精品久久久网站| 国产精品午夜免费| 亚洲精品日韩综合观看成人91| 一级女性全黄久久生活片免费| 亚洲成人av一区二区| 久久精品国产999大香线蕉| 国产成人精品一区二区三区四区| 91欧美激情一区二区三区成人| 欧美日韩国产精选| 欧美激情中文不卡| 亚洲国产一二三| 国内精品在线播放| 色吧成人激情小说| 日韩视频永久免费| 综合色中文字幕| 麻豆精品一二三| av不卡一区二区三区| 欧美精品一二三四| 日本一二三不卡| 日本vs亚洲vs韩国一区三区二区 | 亚洲免费在线播放| 麻豆国产91在线播放| www.激情成人| 日韩欧美一二三区| 一区二区三区在线观看国产| 久久国产精品色婷婷| 91福利区一区二区三区| 久久综合九色综合欧美98| 亚洲黄色av一区| 国产精品自拍av| 在线91免费看| 亚洲视频一区二区在线| 韩国在线一区二区| 欧美精品一二三区| 一区二区三区中文在线观看| 国产成人自拍网| 日韩三级高清在线| 亚洲综合色噜噜狠狠| 成人在线视频一区二区| 日韩欧美国产一区二区三区| 一区二区成人在线观看| 成人爱爱电影网址| 久久伊人中文字幕| 美腿丝袜一区二区三区| 欧美系列在线观看| 一区二区三区在线观看国产| 成人app软件下载大全免费| 久久综合久色欧美综合狠狠| 日韩成人dvd| 欧美理论片在线| 亚洲电影在线播放| 一本高清dvd不卡在线观看| 国产精品日韩精品欧美在线| 国产在线国偷精品产拍免费yy| 91精品国产一区二区三区| 亚洲图片欧美一区| 色系网站成人免费| 亚洲精品日韩专区silk| 色综合视频在线观看| 1024国产精品| 99精品一区二区三区| 国产精品高清亚洲| 成人av集中营| 中文字幕一区日韩精品欧美| 懂色一区二区三区免费观看| 国产人伦精品一区二区| 国产在线精品一区二区不卡了| 精品国产123| 国产一区二区日韩精品| 国产亚洲欧美激情| 国产精品综合在线视频| 日本一区二区动态图| hitomi一区二区三区精品| 国产精品初高中害羞小美女文| 91亚洲国产成人精品一区二区三| 日本一区二区视频在线观看| av一区二区久久| 一级特黄大欧美久久久| 精品视频1区2区3区| 天天色 色综合| 精品欧美一区二区在线观看| 精品一区二区三区的国产在线播放 | 亚洲va欧美va人人爽| 欧美电影一区二区| 美国毛片一区二区三区| 国产午夜精品久久久久久免费视| 成人精品在线视频观看| 亚洲免费在线电影| 欧美日韩高清影院| 久久99最新地址| 亚洲国产精品成人综合| 91免费视频网址| 男人操女人的视频在线观看欧美| 精品久久久久久亚洲综合网| 成人深夜视频在线观看| 艳妇臀荡乳欲伦亚洲一区| 欧美男人的天堂一二区| 国产精品1024| 亚洲国产色一区| 久久这里只有精品6| 日本乱码高清不卡字幕| 精品一区二区三区免费观看| 自拍偷拍亚洲激情| 欧美不卡在线视频|