2002-08-16 23:27:03 +08:00
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_string.h>
|
2002-09-02 22:48:24 +08:00
|
|
|
#include <ngx_socket.h>
|
2002-08-20 22:48:28 +08:00
|
|
|
#include <ngx_listen.h>
|
2002-08-16 23:27:03 +08:00
|
|
|
#include <ngx_http.h>
|
2002-09-11 23:18:33 +08:00
|
|
|
#include <ngx_http_config.h>
|
2002-08-16 23:27:03 +08:00
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
extern ngx_array_t *ngx_listening_sockets;
|
2002-08-16 23:27:03 +08:00
|
|
|
|
|
|
|
/* STUB */
|
|
|
|
|
|
|
|
static struct sockaddr_in addr;
|
|
|
|
static char addr_text[22];
|
|
|
|
|
|
|
|
static ngx_http_server_t ngx_http_server;
|
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
int ngx_http_init(ngx_pool_t *pool, ngx_log_t *log)
|
2002-08-16 23:27:03 +08:00
|
|
|
{
|
|
|
|
ngx_listen_t *ls;
|
|
|
|
|
2002-09-16 23:01:44 +08:00
|
|
|
ngx_http_server.connection_pool_size = 16384;
|
2002-09-02 22:48:24 +08:00
|
|
|
ngx_http_server.request_pool_size = 16384;
|
2002-08-30 00:59:54 +08:00
|
|
|
ngx_http_server.header_timeout = 20000;
|
2002-09-02 22:48:24 +08:00
|
|
|
ngx_http_server.header_buffer_size = 1024;
|
|
|
|
ngx_http_server.discarded_buffer_size = 1500;
|
|
|
|
|
2002-09-16 23:01:44 +08:00
|
|
|
ngx_http_server.lingering_timeout = 5000;
|
|
|
|
ngx_http_server.lingering_time = 30;
|
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
#if (WIN32)
|
|
|
|
ngx_http_server.doc_root = "html";
|
|
|
|
#else
|
2002-10-05 01:58:04 +08:00
|
|
|
ngx_http_server.doc_root = "/home/is/dox/";
|
2002-12-03 00:09:40 +08:00
|
|
|
ngx_http_server.doc_root = "/home/is/work/xml/site-1.0.0/html";
|
2002-08-20 22:48:28 +08:00
|
|
|
#endif
|
|
|
|
ngx_http_server.doc_root_len = strlen(ngx_http_server.doc_root) + 1;
|
|
|
|
|
2002-09-02 22:48:24 +08:00
|
|
|
|
2002-09-11 23:18:33 +08:00
|
|
|
ngx_http_config_modules(pool, ngx_http_modules);
|
|
|
|
|
|
|
|
/* STUB */
|
|
|
|
ngx_http_output_filter_set_stub(pool, ngx_http_modules);
|
|
|
|
ngx_http_write_filter_set_stub(pool, ngx_http_modules);
|
|
|
|
ngx_http_index_set_stub(pool, ngx_http_modules);
|
2002-08-16 23:27:03 +08:00
|
|
|
|
2002-09-11 23:18:33 +08:00
|
|
|
ngx_http_init_modules(pool, ngx_http_modules);
|
|
|
|
ngx_http_init_filters(pool, ngx_http_modules);
|
2002-09-02 22:48:24 +08:00
|
|
|
|
2002-08-16 23:27:03 +08:00
|
|
|
ls = ngx_push_array(ngx_listening_sockets);
|
2002-08-20 22:48:28 +08:00
|
|
|
ngx_memzero(ls, sizeof(ngx_listen_t));
|
2002-08-16 23:27:03 +08:00
|
|
|
|
|
|
|
addr.sin_family = AF_INET;
|
2002-08-20 22:48:28 +08:00
|
|
|
addr.sin_addr.s_addr = inet_addr("0.0.0.0");
|
2002-08-16 23:27:03 +08:00
|
|
|
addr.sin_port = htons(8000);
|
|
|
|
|
|
|
|
ngx_snprintf(ngx_cpystrn(addr_text, inet_ntoa(addr.sin_addr), 16),
|
|
|
|
7, ":%d", ntohs(addr.sin_port));
|
|
|
|
|
|
|
|
ls->family = AF_INET;
|
|
|
|
ls->type = SOCK_STREAM;
|
2002-08-20 22:48:28 +08:00
|
|
|
ls->protocol = IPPROTO_IP;
|
2002-08-26 23:18:19 +08:00
|
|
|
#if (NGX_OVERLAPPED)
|
|
|
|
ls->flags = WSA_FLAG_OVERLAPPED;
|
|
|
|
#endif
|
|
|
|
ls->sockaddr = (struct sockaddr *) &addr;
|
|
|
|
ls->socklen = sizeof(struct sockaddr_in);
|
|
|
|
ls->addr = offsetof(struct sockaddr_in, sin_addr);
|
2002-08-20 22:48:28 +08:00
|
|
|
ls->addr_text = addr_text;
|
2002-08-26 23:18:19 +08:00
|
|
|
ls->addr_textlen = INET_ADDRSTRLEN;
|
2002-08-16 23:27:03 +08:00
|
|
|
ls->backlog = -1;
|
2002-08-26 23:18:19 +08:00
|
|
|
ls->post_accept_timeout = 10000;
|
2002-08-16 23:27:03 +08:00
|
|
|
ls->nonblocking = 1;
|
|
|
|
|
2002-08-20 22:48:28 +08:00
|
|
|
ls->handler = ngx_http_init_connection;
|
|
|
|
ls->server = &ngx_http_server;
|
|
|
|
ls->log = log;
|
|
|
|
|
2002-09-02 22:48:24 +08:00
|
|
|
|
2002-08-16 23:27:03 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* */
|