mirror of
https://github.com/nginx/nginx.git
synced 2025-01-19 01:42:58 +08:00
nginx-0.0.1-2003-06-06-18:59:20 import
This commit is contained in:
parent
9cf783074f
commit
e4a2526e5c
@ -4,9 +4,9 @@
|
||||
|
||||
|
||||
extern ngx_module_t ngx_errlog_module;
|
||||
|
||||
extern ngx_module_t ngx_events_module;
|
||||
extern ngx_module_t ngx_event_module;
|
||||
|
||||
extern ngx_module_t ngx_select_module;
|
||||
#if (HAVE_POLL)
|
||||
extern ngx_module_t ngx_poll_module;
|
||||
@ -20,6 +20,9 @@ extern ngx_module_t ngx_devpoll_module;
|
||||
#if (HAVE_AIO)
|
||||
extern ngx_module_t ngx_aio_module;
|
||||
#endif
|
||||
#if (HAVE_IOCP)
|
||||
extern ngx_module_t ngx_iocp_module;
|
||||
#endif
|
||||
|
||||
|
||||
extern ngx_module_t ngx_http_module;
|
||||
@ -64,6 +67,9 @@ ngx_module_t *ngx_modules[] = {
|
||||
#if (HAVE_AIO)
|
||||
&ngx_aio_module,
|
||||
#endif
|
||||
#if (HAVE_IOCP)
|
||||
&ngx_iocp_module,
|
||||
#endif
|
||||
|
||||
/* http */
|
||||
|
||||
|
@ -1,28 +1,80 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002-2003 Igor Sysoev, http://sysoev.ru
|
||||
*/
|
||||
|
||||
|
||||
#include <ngx_config.h>
|
||||
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_log.h>
|
||||
#include <ngx_errno.h>
|
||||
#include <ngx_time.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_timer.h>
|
||||
|
||||
#include <ngx_iocp_module.h>
|
||||
|
||||
|
||||
int ngx_iocp_threads = 0;;
|
||||
typedef struct {
|
||||
int threads;
|
||||
} ngx_iocp_conf_t;
|
||||
|
||||
|
||||
static HANDLE iocp;
|
||||
static ngx_event_t *timer_queue;
|
||||
static int ngx_iocp_init(ngx_log_t *log);
|
||||
static void ngx_iocp_done(ngx_log_t *log);
|
||||
static int ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key);
|
||||
static int ngx_iocp_process_events(ngx_log_t *log);
|
||||
static void *ngx_iocp_create_conf(ngx_pool_t *pool);
|
||||
static char *ngx_iocp_init_conf(ngx_pool_t *pool, void *conf);
|
||||
|
||||
|
||||
int ngx_iocp_init(int max_connections, ngx_log_t *log)
|
||||
static ngx_str_t iocp_name = ngx_string("iocp");
|
||||
|
||||
static ngx_command_t ngx_iocp_commands[] = {
|
||||
|
||||
{ngx_string("iocp_threads"),
|
||||
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_num_slot,
|
||||
0,
|
||||
offsetof(ngx_iocp_conf_t, threads),
|
||||
NULL},
|
||||
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
|
||||
ngx_event_module_t ngx_iocp_module_ctx = {
|
||||
&iocp_name,
|
||||
ngx_iocp_create_conf, /* create configuration */
|
||||
ngx_iocp_init_conf, /* init configuration */
|
||||
|
||||
{
|
||||
ngx_iocp_add_event, /* add an event */
|
||||
NULL, /* delete an event */
|
||||
NULL, /* enable an event */
|
||||
NULL, /* disable an event */
|
||||
NULL, /* add an connection */
|
||||
NULL, /* delete an connection */
|
||||
ngx_iocp_process_events, /* process the events */
|
||||
ngx_iocp_init, /* init the events */
|
||||
ngx_iocp_done /* done the events */
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ngx_module_t ngx_iocp_module = {
|
||||
NGX_MODULE,
|
||||
&ngx_iocp_module_ctx, /* module context */
|
||||
ngx_iocp_commands, /* module directives */
|
||||
NGX_EVENT_MODULE, /* module type */
|
||||
NULL /* init module */
|
||||
};
|
||||
|
||||
|
||||
static HANDLE iocp;
|
||||
|
||||
|
||||
static int ngx_iocp_init(ngx_log_t *log)
|
||||
{
|
||||
iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
|
||||
NULL, 0, ngx_iocp_threads);
|
||||
ngx_iocp_conf_t *cf;
|
||||
|
||||
cf = ngx_event_get_conf(ngx_iocp_module);
|
||||
|
||||
iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, cf->threads);
|
||||
|
||||
if (iocp == NULL) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||
@ -30,12 +82,11 @@ int ngx_iocp_init(int max_connections, ngx_log_t *log)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
timer_queue = ngx_event_init_timer(log);
|
||||
if (timer_queue == NULL) {
|
||||
if (ngx_event_timer_init(log) == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_event_actions.process = ngx_iocp_process_events;
|
||||
ngx_event_actions = ngx_iocp_module_ctx.actions;
|
||||
|
||||
ngx_event_flags = NGX_HAVE_AIO_EVENT|NGX_HAVE_IOCP_EVENT;
|
||||
|
||||
@ -43,15 +94,26 @@ int ngx_iocp_init(int max_connections, ngx_log_t *log)
|
||||
}
|
||||
|
||||
|
||||
int ngx_iocp_add_event(ngx_event_t *ev)
|
||||
static void ngx_iocp_done(ngx_log_t *log)
|
||||
{
|
||||
if (CloseHandle(iocp) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||
"iocp CloseHandle() failed");
|
||||
}
|
||||
|
||||
ngx_event_timer_done(log);
|
||||
}
|
||||
|
||||
|
||||
static int ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
|
||||
{
|
||||
ngx_connection_t *c;
|
||||
|
||||
c = (ngx_connection_t *) ev->data;
|
||||
|
||||
ngx_log_debug(ev->log, "iocp: %d, %08x:%08x" _ c->fd _ ev _ &ev->ovlp);
|
||||
ngx_log_debug(ev->log, "iocp add: %d, %08x:%08x" _ c->fd _ key _ &ev->ovlp);
|
||||
|
||||
if (CreateIoCompletionPort((HANDLE) c->fd, iocp, (DWORD) ev, 0) == NULL) {
|
||||
if (CreateIoCompletionPort((HANDLE) c->fd, iocp, key, 0) == NULL) {
|
||||
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
|
||||
"CreateIoCompletionPort() failed");
|
||||
return NGX_ERROR;
|
||||
@ -61,17 +123,16 @@ int ngx_iocp_add_event(ngx_event_t *ev)
|
||||
}
|
||||
|
||||
|
||||
int ngx_iocp_process_events(ngx_log_t *log)
|
||||
static int ngx_iocp_process_events(ngx_log_t *log)
|
||||
{
|
||||
int rc;
|
||||
u_int key;
|
||||
size_t bytes;
|
||||
ngx_err_t err;
|
||||
ngx_msec_t timer, delta;
|
||||
ngx_event_t *ev, *e;
|
||||
ngx_event_t *ev;
|
||||
ngx_event_ovlp_t *ovlp;
|
||||
|
||||
ngx_log_debug(log, "iocp");
|
||||
|
||||
timer = ngx_event_find_timer();
|
||||
|
||||
if (timer) {
|
||||
@ -84,15 +145,12 @@ int ngx_iocp_process_events(ngx_log_t *log)
|
||||
|
||||
ngx_log_debug(log, "iocp timer: %d" _ timer);
|
||||
|
||||
#if 1
|
||||
rc = GetQueuedCompletionStatus(iocp, &bytes, (LPDWORD) &e,
|
||||
rc = GetQueuedCompletionStatus(iocp, &bytes, (LPDWORD) &key,
|
||||
(LPOVERLAPPED *) &ovlp, timer);
|
||||
ngx_log_debug(log, "iocp: %d, %d:%08x:%08x" _ rc _ bytes _ e _ ovlp);
|
||||
|
||||
ngx_log_debug(log, "iocp: %d, %d:%08x:%08x" _ rc _ bytes _ key _ ovlp);
|
||||
|
||||
if (rc == 0) {
|
||||
#else
|
||||
if (GetQueuedCompletionStatus(iocp, &bytes, (LPDWORD) &e,
|
||||
(LPOVERLAPPED *) &ovlp, timer) == 0) {
|
||||
#endif
|
||||
err = ngx_errno;
|
||||
|
||||
if (ovlp == NULL) {
|
||||
@ -118,16 +176,43 @@ int ngx_iocp_process_events(ngx_log_t *log)
|
||||
|
||||
ngx_log_debug(log, "iocp ev: %08x" _ ev);
|
||||
|
||||
if (ev == e) {
|
||||
/* it's not AcceptEx() completion */
|
||||
switch (key) {
|
||||
case NGX_IOCP_IO:
|
||||
ev->ready = 1;
|
||||
ev->available = bytes;
|
||||
break;
|
||||
|
||||
case NGX_IOCP_ACCEPT:
|
||||
break;
|
||||
}
|
||||
|
||||
ngx_log_debug(log, "iocp ev: %08x" _ ev->event_handler);
|
||||
ngx_log_debug(log, "iocp ev handler: %08x" _ ev->event_handler);
|
||||
|
||||
ev->event_handler(ev);
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *ngx_iocp_create_conf(ngx_pool_t *pool)
|
||||
{
|
||||
ngx_iocp_conf_t *cf;
|
||||
|
||||
ngx_test_null(cf, ngx_palloc(pool, sizeof(ngx_iocp_conf_t)),
|
||||
NGX_CONF_ERROR);
|
||||
|
||||
cf->threads = NGX_CONF_UNSET;
|
||||
|
||||
return cf;
|
||||
}
|
||||
|
||||
|
||||
static char *ngx_iocp_init_conf(ngx_pool_t *pool, void *conf)
|
||||
{
|
||||
ngx_iocp_conf_t *cf = conf;
|
||||
|
||||
ngx_conf_init_value(cf->threads, 0);
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
@ -6,11 +6,16 @@
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_kqueue_module.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int changes;
|
||||
int events;
|
||||
} ngx_kqueue_conf_t;
|
||||
|
||||
|
||||
static int ngx_kqueue_init(ngx_log_t *log);
|
||||
static void ngx_kqueue_done(ngx_log_t *log);
|
||||
static int ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags);
|
||||
@ -210,7 +215,7 @@ static int ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
|
||||
c = ev->data;
|
||||
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
ngx_log_debug(ev->log, "kqueue set event: %d: ft:%d f:%08x" _
|
||||
ngx_log_debug(ev->log, "kqueue set event: %d: ft:%d fl:%08x" _
|
||||
c->fd _ filter _ flags);
|
||||
#endif
|
||||
|
||||
@ -322,13 +327,13 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
if (event_list[i].ident > 0x8000000) {
|
||||
ngx_log_debug(log,
|
||||
"kevent: %08x: ft:%d f:%08x ff:%08x d:%d ud:%08x" _
|
||||
"kevent: %08x: ft:%d fl:%08x ff:%08x d:%d ud:%08x" _
|
||||
event_list[i].ident _ event_list[i].filter _
|
||||
event_list[i].flags _ event_list[i].fflags _
|
||||
event_list[i].data _ event_list[i].udata);
|
||||
} else {
|
||||
ngx_log_debug(log,
|
||||
"kevent: %d: ft:%d f:%08x ff:%08x d:%d ud:%08x" _
|
||||
"kevent: %d: ft:%d fl:%08x ff:%08x d:%d ud:%08x" _
|
||||
event_list[i].ident _ event_list[i].filter _
|
||||
event_list[i].flags _ event_list[i].fflags _
|
||||
event_list[i].data _ event_list[i].udata);
|
||||
|
@ -2,12 +2,6 @@
|
||||
#define _NGX_KQUEUE_MODULE_H_INCLUDED_
|
||||
|
||||
|
||||
typedef struct {
|
||||
int changes;
|
||||
int events;
|
||||
} ngx_kqueue_conf_t;
|
||||
|
||||
|
||||
extern int ngx_kqueue;
|
||||
extern ngx_module_t ngx_kqueue_module;
|
||||
extern ngx_event_module_t ngx_kqueue_module_ctx;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_connection.h>
|
||||
#include <ngx_event.h>
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <ngx_event.h>
|
||||
|
||||
|
||||
#define DEF_CONNECTIONS 1024
|
||||
#define DEF_CONNECTIONS 512
|
||||
|
||||
|
||||
extern ngx_module_t ngx_select_module;
|
||||
@ -367,15 +367,6 @@ static char *ngx_event_init_conf(ngx_pool_t *pool, void *conf)
|
||||
|
||||
#if (HAVE_KQUEUE)
|
||||
|
||||
#if 0
|
||||
if (ecf->connections != NGX_CONF_UNSET) {
|
||||
ecf->connections = (ngx_max_connections < DEF_CONNECTIONS) ?
|
||||
ngx_max_connections : DEF_CONNECTIONS;
|
||||
|
||||
} else if (ecf->connections > ngx_max_connections) {
|
||||
}
|
||||
#endif
|
||||
|
||||
ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS);
|
||||
ngx_conf_init_value(ecf->use, ngx_kqueue_module.ctx_index);
|
||||
|
||||
@ -393,6 +384,14 @@ static char *ngx_event_init_conf(ngx_pool_t *pool, void *conf)
|
||||
|
||||
#endif
|
||||
|
||||
#if (WIN32)
|
||||
/*
|
||||
* Winsock assignes a socket number according to 4 * N + M,
|
||||
* where M is the constant 32 (98SE), 88 (NT) or 100 (W2K).
|
||||
* So to find a connection we divide a socket number by 4.
|
||||
*/
|
||||
#endif
|
||||
|
||||
ngx_conf_init_value(ecf->timer_queues, 10);
|
||||
|
||||
return NGX_CONF_OK;
|
||||
|
@ -9,16 +9,14 @@
|
||||
#define NGX_INVALID_INDEX 0x80000000
|
||||
|
||||
|
||||
#if 0
|
||||
typedef struct ngx_event_s ngx_event_t;
|
||||
#endif
|
||||
|
||||
#if (HAVE_IOCP)
|
||||
|
||||
typedef struct {
|
||||
WSAOVERLAPPED ovlp;
|
||||
ngx_event_t *event;
|
||||
int error;
|
||||
} ngx_event_ovlp_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -81,6 +79,10 @@ struct ngx_event_s {
|
||||
|
||||
unsigned deferred_accept:1;
|
||||
|
||||
#if (WIN32)
|
||||
unsigned accept_context_updated:1;
|
||||
#endif
|
||||
|
||||
#if (HAVE_KQUEUE)
|
||||
unsigned eof:1;
|
||||
int error;
|
||||
@ -284,6 +286,13 @@ typedef struct {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if (HAVE_IOCP_EVENT)
|
||||
#define NGX_IOCP_ACCEPT 0
|
||||
#define NGX_IOCP_IO 1
|
||||
#endif
|
||||
|
||||
|
||||
#define ngx_del_timer ngx_event_del_timer
|
||||
|
||||
|
||||
|
@ -5,37 +5,36 @@
|
||||
#include <ngx_listen.h>
|
||||
|
||||
#include <ngx_event.h>
|
||||
#if 0
|
||||
#include <ngx_event_close.h>
|
||||
#include <ngx_iocp_module.h>
|
||||
|
||||
#include <ngx_event_acceptex.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void ngx_event_acceptex(ngx_event_t *ev)
|
||||
void ngx_event_acceptex(ngx_event_t *rev)
|
||||
{
|
||||
ngx_connection_t *c;
|
||||
|
||||
c = (ngx_connection_t *) ev->data;
|
||||
c = (ngx_connection_t *) rev->data;
|
||||
|
||||
if (ev->ovlp.error) {
|
||||
ngx_log_error(NGX_LOG_CRIT, ev->log, ev->ovlp.error,
|
||||
"AcceptEx() falied for %s", c->addr_text.data);
|
||||
ngx_log_debug(rev->log, "ADDR: %s" _ c->addr_text.data);
|
||||
|
||||
if (rev->ovlp.error) {
|
||||
ngx_log_error(NGX_LOG_CRIT, rev->log, rev->ovlp.error,
|
||||
"AcceptEx() failed for %s", c->addr_text.data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: can we do SO_UPDATE_ACCEPT_CONTEXT just before shutdown() ???
|
||||
or AcceptEx's context will be lost ??? */
|
||||
/* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */
|
||||
|
||||
/* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */
|
||||
if (setsockopt(c->fd, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
|
||||
(char *)&c->listening->fd, sizeof(ngx_socket_t)) == -1)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_CRIT, ev->log, ngx_socket_errno,
|
||||
"setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed for %s",
|
||||
c->addr_text.data);
|
||||
|
||||
/* non fatal - we can not only do lingering close */
|
||||
} else {
|
||||
accept_context_updated = 1;
|
||||
}
|
||||
|
||||
getacceptexsockaddrs(c->data, 0,
|
||||
@ -75,8 +74,7 @@ int ngx_event_post_acceptex(ngx_listen_t *ls, int n)
|
||||
|
||||
if (s == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, ls->log, ngx_socket_errno,
|
||||
ngx_socket_n " for AcceptEx(%s) falied",
|
||||
ls->addr_text.data);
|
||||
ngx_socket_n " for AcceptEx() post failed");
|
||||
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -132,7 +130,7 @@ int ngx_event_post_acceptex(ngx_listen_t *ls, int n)
|
||||
ngx_memcpy(c->log, ls->log, sizeof(ngx_log_t));
|
||||
rev->log = wev->log = c->log;
|
||||
|
||||
if (ngx_iocp_add_event(rev) == NGX_ERROR) {
|
||||
if (ngx_add_event(rev, 0, NGX_IOCP_IO) == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
if (ngx_file_append_mode(lcf->file.fd) == NGX_ERROR) {
|
||||
err = ngx_errno;
|
||||
len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||
ngx_file_appned_mode_n " \"%s\" failed (%d: ",
|
||||
ngx_file_append_mode_n " \"%s\" failed (%d: ",
|
||||
lcf->file.name.data, err);
|
||||
len += ngx_strerror_r(err, ngx_conf_errstr + len,
|
||||
sizeof(ngx_conf_errstr) - len - 1);
|
||||
|
@ -22,6 +22,11 @@
|
||||
#include <osreldate.h>
|
||||
|
||||
|
||||
#define QD_FMT "%qd"
|
||||
#define QX_FMT "%qx"
|
||||
#define OFF_FMT "%qd"
|
||||
|
||||
|
||||
#ifndef HAVE_SELECT
|
||||
#define HAVE_SELECT 1
|
||||
#endif
|
||||
|
@ -2,25 +2,20 @@
|
||||
#define _NGX_LINUX_CONFIG_H_INCLUDED_
|
||||
|
||||
|
||||
#define _GNU_SOURCE /* pread, pwrite, gethostname, bzero */
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define _LARGEFILE_SOURCE
|
||||
|
||||
|
||||
#define _XOPEN_SOURCE 500 /* pread, pwrite */
|
||||
#include <unistd.h>
|
||||
#undef _XOPEN_SOURCE 500
|
||||
|
||||
#include <stddef.h> /* offsetof */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#define __USE_BSD /* bzero */
|
||||
#include <string.h>
|
||||
#undef __USE_BSD
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
@ -39,6 +34,11 @@ typedef unsigned short u_short;
|
||||
typedef unsigned char u_char;
|
||||
|
||||
|
||||
#define QD_FMT "%qd"
|
||||
#define QX_FMT "%qx"
|
||||
#define OFF_FMT "%qd"
|
||||
|
||||
|
||||
#ifndef HAVE_SELECT
|
||||
#define HAVE_SELECT 1
|
||||
#endif
|
||||
|
@ -5,8 +5,8 @@
|
||||
#define SOLARIS 1
|
||||
|
||||
#define _REENTRANT
|
||||
#define _FILE_OFFSET_BITS 64 /* must be before sys/types.h */
|
||||
|
||||
#define _FILE_OFFSET_BITS 64 /* must be before sys/types.h */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stddef.h> /* offsetof */
|
||||
@ -27,6 +27,10 @@
|
||||
|
||||
typedef uint32_t u_int32_t;
|
||||
|
||||
#define QD_FMT "%lld"
|
||||
#define QX_FMT "%llx"
|
||||
#define OFF_FMT "%lld"
|
||||
|
||||
|
||||
#ifndef HAVE_SELECT
|
||||
#define HAVE_SELECT 1
|
||||
|
@ -12,20 +12,4 @@ typedef int ngx_fd_t;
|
||||
typedef struct stat ngx_file_info_t;
|
||||
|
||||
|
||||
|
||||
#ifdef SOLARIS
|
||||
|
||||
#define QD_FMT "%lld"
|
||||
#define QX_FMT "%llx"
|
||||
#define OFF_FMT "%lld"
|
||||
|
||||
#else
|
||||
|
||||
#define QD_FMT "%qd"
|
||||
#define QX_FMT "%qx"
|
||||
#define OFF_FMT "%qd"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _NGX_TYPES_H_INCLUDED_ */
|
||||
|
@ -26,20 +26,65 @@ static GUID tf_guid = WSAID_TRANSMITFILE;
|
||||
|
||||
int ngx_os_init(ngx_log_t *log)
|
||||
{
|
||||
DWORD bytes;
|
||||
SOCKET s;
|
||||
WSADATA wsd;
|
||||
u_int sp;
|
||||
DWORD bytes;
|
||||
SOCKET s;
|
||||
WSADATA wsd;
|
||||
OSVERSIONINFOEX osvi;
|
||||
|
||||
/* get Windows version */
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
|
||||
osviex = GetVersionEx((OSVERSIONINFO *) &osvi);
|
||||
|
||||
if (osviex == 0) {
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
if (GetVersionEx((OSVERSIONINFO *) &osvi) == 0)
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||
"GetVersionEx() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Windows 95 1400
|
||||
* Windows 98 1410
|
||||
* Windows ME 1490
|
||||
* Windows NT 3.51 2351
|
||||
* Windows NT 4.0 2400
|
||||
* Windows 2000 2500
|
||||
* Windows XP 2501
|
||||
* Windows 2003 2502
|
||||
*/
|
||||
|
||||
ngx_win32_version = osvi.dwPlatformId * 1000
|
||||
+ osvi.dwMajorVersion * 100
|
||||
+ osvi.dwMinorVersion;
|
||||
|
||||
if (osviex) {
|
||||
sp = osvi.wServicePackMajor * 100 + osvi.wServicePackMinor;
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, log, 0,
|
||||
"OS: %u build:%u, %s, SP:%u, suite:%x, type:%u",
|
||||
ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion,
|
||||
sp, osvi.wSuiteMask, osvi.wProductType);
|
||||
|
||||
} else {
|
||||
ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %u build:%u, %s",
|
||||
ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion);
|
||||
}
|
||||
|
||||
|
||||
/* init Winsock */
|
||||
|
||||
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||
"WSAStartup failed");
|
||||
"WSAStartup() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, log, 0, "max sockets: %d", wsd.iMaxSockets);
|
||||
|
||||
/* get AcceptEx(), GetAcceptExSockAddrs() and TransmitFile() addresses */
|
||||
|
||||
s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP, 0);
|
||||
|
@ -16,8 +16,6 @@ typedef unsigned __int64 off_t;
|
||||
typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t;
|
||||
|
||||
|
||||
|
||||
|
||||
#define QD_FMT "%I64d"
|
||||
#define QX_FMT "%I64x"
|
||||
#define OFF_FMT "%I64d"
|
||||
|
Loading…
Reference in New Issue
Block a user