mirror of
https://github.com/nginx/nginx.git
synced 2024-12-18 15:47:47 +08:00
nginx-0.0.1-2003-05-16-19:27:48 import
This commit is contained in:
parent
6ddfbf0662
commit
bb4ec5c172
@ -38,6 +38,7 @@ ngx_pool_t *ngx_pool;
|
|||||||
|
|
||||||
|
|
||||||
int ngx_max_module;
|
int ngx_max_module;
|
||||||
|
void *ctx_conf;
|
||||||
|
|
||||||
int ngx_connection_counter;
|
int ngx_connection_counter;
|
||||||
|
|
||||||
@ -81,8 +82,14 @@ int main(int argc, char *const *argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngx_memzero(&conf, sizeof(ngx_conf_t));
|
ngx_memzero(&conf, sizeof(ngx_conf_t));
|
||||||
ngx_test_null(conf.args,
|
|
||||||
ngx_create_array(ngx_pool, 10, sizeof(ngx_str_t)), 1);
|
ngx_test_null(conf.args, ngx_create_array(ngx_pool, 10, sizeof(ngx_str_t)),
|
||||||
|
1);
|
||||||
|
|
||||||
|
ngx_test_null(conf.ctx,
|
||||||
|
ngx_pcalloc(ngx_pool, ngx_max_module * sizeof(void *)),
|
||||||
|
1);
|
||||||
|
|
||||||
conf.pool = ngx_pool;
|
conf.pool = ngx_pool;
|
||||||
conf.log = &ngx_log;
|
conf.log = &ngx_log;
|
||||||
conf.module_type = NGX_CORE_MODULE_TYPE;
|
conf.module_type = NGX_CORE_MODULE_TYPE;
|
||||||
|
@ -27,6 +27,8 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
|||||||
|
|
||||||
if (filename) {
|
if (filename) {
|
||||||
|
|
||||||
|
/* open configuration file */
|
||||||
|
|
||||||
fd = ngx_open_file(filename->data, NGX_FILE_RDONLY);
|
fd = ngx_open_file(filename->data, NGX_FILE_RDONLY);
|
||||||
if (fd == NGX_INVALID_FILE) {
|
if (fd == NGX_INVALID_FILE) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
|
||||||
@ -60,7 +62,8 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
|||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
rc = ngx_conf_read_token(cf);
|
rc = ngx_conf_read_token(cf);
|
||||||
|
|
||||||
/* NGX_OK, NGX_ERROR, NGX_CONF_FILE_DONE, NGX_CONF_BLOCK_DONE */
|
/* ngx_conf_read_token() returns NGX_OK, NGX_ERROR,
|
||||||
|
NGX_CONF_FILE_DONE or NGX_CONF_BLOCK_DONE */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ngx_log_debug(cf->log, "token %d" _ rc);
|
ngx_log_debug(cf->log, "token %d" _ rc);
|
||||||
@ -76,6 +79,8 @@ ngx_log_debug(cf->log, "token %d" _ rc);
|
|||||||
|
|
||||||
if (cf->handler) {
|
if (cf->handler) {
|
||||||
|
|
||||||
|
/* custom handler, i.e. used in http "types { ... }" directive */
|
||||||
|
|
||||||
rv = (*cf->handler)(cf, NULL, cf->handler_conf);
|
rv = (*cf->handler)(cf, NULL, cf->handler_conf);
|
||||||
if (rv == NGX_CONF_OK) {
|
if (rv == NGX_CONF_OK) {
|
||||||
continue;
|
continue;
|
||||||
@ -97,6 +102,9 @@ ngx_log_debug(cf->log, "token %d" _ rc);
|
|||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
for (i = 0; !found && ngx_modules[i]; i++) {
|
for (i = 0; !found && ngx_modules[i]; i++) {
|
||||||
|
|
||||||
|
/* look up the directive in the appropriate modules */
|
||||||
|
|
||||||
if (ngx_modules[i]->type != NGX_CONF_MODULE_TYPE
|
if (ngx_modules[i]->type != NGX_CONF_MODULE_TYPE
|
||||||
&& ngx_modules[i]->type != cf->module_type)
|
&& ngx_modules[i]->type != cf->module_type)
|
||||||
{
|
{
|
||||||
@ -116,6 +124,7 @@ ngx_log_debug(cf->log, "token %d" _ rc);
|
|||||||
#if 0
|
#if 0
|
||||||
ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
|
ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
|
||||||
#endif
|
#endif
|
||||||
|
/* is the directive's location right ? */
|
||||||
|
|
||||||
if ((cmd->type & cf->cmd_type) == 0) {
|
if ((cmd->type & cf->cmd_type) == 0) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
@ -127,6 +136,8 @@ ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* is the directive's argument count right ? */
|
||||||
|
|
||||||
if (!(cmd->type & NGX_CONF_ANY)
|
if (!(cmd->type & NGX_CONF_ANY)
|
||||||
&& ((cmd->type & NGX_CONF_FLAG && cf->args->nelts != 2)
|
&& ((cmd->type & NGX_CONF_FLAG && cf->args->nelts != 2)
|
||||||
|| (!(cmd->type & NGX_CONF_FLAG)
|
|| (!(cmd->type & NGX_CONF_FLAG)
|
||||||
@ -145,8 +156,14 @@ ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set up the directive's configuration context */
|
||||||
|
|
||||||
conf = NULL;
|
conf = NULL;
|
||||||
if (cf->ctx) {
|
|
||||||
|
if (cf->module_type == NGX_CORE_MODULE_TYPE) {
|
||||||
|
conf = &(((void **) cf->ctx)[ngx_modules[i]->index]);
|
||||||
|
|
||||||
|
} else if (cf->ctx) {
|
||||||
pconf = *(void **) ((char *) cf->ctx + cmd->conf);
|
pconf = *(void **) ((char *) cf->ctx + cmd->conf);
|
||||||
|
|
||||||
if (pconf) {
|
if (pconf) {
|
||||||
@ -197,7 +214,7 @@ ngx_log_debug(cf->log, "rv: %d" _ rv);
|
|||||||
cf->conf_file = prev;
|
cf->conf_file = prev;
|
||||||
|
|
||||||
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
||||||
ngx_log_error(NGX_LOG_ERR, cf->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
|
||||||
ngx_close_file_n " %s failed",
|
ngx_close_file_n " %s failed",
|
||||||
cf->conf_file->file.name.data);
|
cf->conf_file->file.name.data);
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
@ -450,6 +467,26 @@ char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
|
||||||
|
{
|
||||||
|
int num, len;
|
||||||
|
ngx_str_t *value;
|
||||||
|
|
||||||
|
value = (ngx_str_t *) cf->args->elts;
|
||||||
|
|
||||||
|
len = value[1].len;
|
||||||
|
|
||||||
|
num = ngx_atoi(value[1].data, len);
|
||||||
|
if (num == NGX_ERROR) {
|
||||||
|
return "invalid value";
|
||||||
|
}
|
||||||
|
|
||||||
|
*(int *) (conf + cmd->offset) = num;
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
|
char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
|
||||||
{
|
{
|
||||||
int size, len, scale;
|
int size, len, scale;
|
||||||
|
@ -17,18 +17,17 @@
|
|||||||
* AAAA number of agruments
|
* AAAA number of agruments
|
||||||
* FF command flags
|
* FF command flags
|
||||||
* TT command type, i.e. HTTP "location" or "server" command
|
* TT command type, i.e. HTTP "location" or "server" command
|
||||||
* 00
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NGX_CONF_NOARGS 0x0000000001
|
#define NGX_CONF_NOARGS 0x00000001
|
||||||
#define NGX_CONF_TAKE1 0x0000000002
|
#define NGX_CONF_TAKE1 0x00000002
|
||||||
#define NGX_CONF_TAKE2 0x0000000004
|
#define NGX_CONF_TAKE2 0x00000004
|
||||||
#define NGX_CONF_ARGS_NUMBER 0x000000ffff
|
#define NGX_CONF_ARGS_NUMBER 0x0000ffff
|
||||||
#define NGX_CONF_ANY 0x0000010000
|
#define NGX_CONF_ANY 0x00010000
|
||||||
#define NGX_CONF_BLOCK 0x0000020000
|
#define NGX_CONF_BLOCK 0x00020000
|
||||||
#define NGX_CONF_FLAG 0x0000040000
|
#define NGX_CONF_FLAG 0x00040000
|
||||||
|
|
||||||
#define NGX_MAIN_CONF 0x0001000000
|
#define NGX_MAIN_CONF 0x01000000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -61,8 +60,8 @@ struct ngx_command_s {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
|
||||||
void *ctx;
|
void *ctx;
|
||||||
|
int index;
|
||||||
ngx_command_t *commands;
|
ngx_command_t *commands;
|
||||||
int type;
|
int type;
|
||||||
int (*init_module)(ngx_pool_t *p);
|
int (*init_module)(ngx_pool_t *p);
|
||||||
@ -121,6 +120,7 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
|
|||||||
|
|
||||||
char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
||||||
char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
||||||
|
char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
||||||
char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
||||||
char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
||||||
char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
#include <ngx_conf_file.h>
|
#include <ngx_conf_file.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern ngx_module_t ngx_events_module;
|
||||||
|
extern ngx_module_t ngx_event_module;
|
||||||
|
|
||||||
|
|
||||||
extern ngx_module_t ngx_http_module;
|
extern ngx_module_t ngx_http_module;
|
||||||
extern ngx_module_t ngx_http_core_module;
|
extern ngx_module_t ngx_http_core_module;
|
||||||
|
|
||||||
@ -17,6 +21,13 @@ extern ngx_module_t ngx_http_proxy_module;
|
|||||||
|
|
||||||
ngx_module_t *ngx_modules[] = {
|
ngx_module_t *ngx_modules[] = {
|
||||||
|
|
||||||
|
/* events */
|
||||||
|
|
||||||
|
&ngx_events_module,
|
||||||
|
&ngx_event_module,
|
||||||
|
|
||||||
|
/* http */
|
||||||
|
|
||||||
&ngx_http_module,
|
&ngx_http_module,
|
||||||
|
|
||||||
&ngx_http_core_module,
|
&ngx_http_core_module,
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <ngx_connection.h>
|
#include <ngx_connection.h>
|
||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
#include <ngx_event_timer.h>
|
#include <ngx_event_timer.h>
|
||||||
|
#include <ngx_conf_file.h>
|
||||||
#include <ngx_kqueue_module.h>
|
#include <ngx_kqueue_module.h>
|
||||||
|
|
||||||
|
|
||||||
@ -18,6 +19,10 @@
|
|||||||
#define KQUEUE_NEVENTS 512
|
#define KQUEUE_NEVENTS 512
|
||||||
|
|
||||||
|
|
||||||
|
static int ngx_kqueue_changes;
|
||||||
|
static int ngx_kqueue_events;
|
||||||
|
|
||||||
|
|
||||||
/* should be per-thread if threads are used without thread pool */
|
/* should be per-thread if threads are used without thread pool */
|
||||||
#if 1
|
#if 1
|
||||||
int kq;
|
int kq;
|
||||||
@ -32,6 +37,37 @@ static ngx_event_t *timer_queue;
|
|||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_str_t kqueue_name = ngx_string("kqueue");
|
||||||
|
|
||||||
|
static ngx_command_t ngx_kqueue_commands[] = {
|
||||||
|
|
||||||
|
{ngx_string("kqueue_changes"),
|
||||||
|
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_conf_set_num_slot,
|
||||||
|
0,
|
||||||
|
addressof(ngx_kqueue_changes),
|
||||||
|
NULL},
|
||||||
|
|
||||||
|
{ngx_string("kqueue_events"),
|
||||||
|
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_conf_set_num_slot,
|
||||||
|
0,
|
||||||
|
addressof(ngx_kqueue_events),
|
||||||
|
NULL},
|
||||||
|
|
||||||
|
{ngx_string(""), 0, NULL, 0, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
ngx_module_t ngx_kqueue_module = {
|
||||||
|
&kqueue_name, /* module context */
|
||||||
|
0, /* module index */
|
||||||
|
ngx_kqueue_commands, /* module directives */
|
||||||
|
NGX_EVENT_MODULE_TYPE, /* module type */
|
||||||
|
NULL /* init module */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ngx_kqueue_init(int max_connections, ngx_log_t *log)
|
int ngx_kqueue_init(int max_connections, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
int change_size, event_size;
|
int change_size, event_size;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <ngx_listen.h>
|
#include <ngx_listen.h>
|
||||||
#include <ngx_connection.h>
|
#include <ngx_connection.h>
|
||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
|
#include <ngx_conf_file.h>
|
||||||
|
|
||||||
#include <ngx_select_module.h>
|
#include <ngx_select_module.h>
|
||||||
|
|
||||||
@ -34,6 +35,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
|
||||||
|
|
||||||
|
|
||||||
ngx_connection_t *ngx_connections;
|
ngx_connection_t *ngx_connections;
|
||||||
ngx_event_t *ngx_read_events, *ngx_write_events;
|
ngx_event_t *ngx_read_events, *ngx_write_events;
|
||||||
|
|
||||||
@ -68,6 +72,66 @@ static int (*ngx_event_init[]) (int max_connections, ngx_log_t *log) = {
|
|||||||
#endif /* USE_KQUEUE */
|
#endif /* USE_KQUEUE */
|
||||||
|
|
||||||
|
|
||||||
|
static int ngx_event_connections;
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_str_t events_name = ngx_string("events");
|
||||||
|
|
||||||
|
static ngx_command_t ngx_events_commands[] = {
|
||||||
|
|
||||||
|
{ngx_string("events"),
|
||||||
|
NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
||||||
|
ngx_events_block,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL},
|
||||||
|
|
||||||
|
{ngx_string(""), 0, NULL, 0, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ngx_module_t ngx_events_module = {
|
||||||
|
&events_name, /* module context */
|
||||||
|
0, /* module index */
|
||||||
|
ngx_events_commands, /* module directives */
|
||||||
|
NGX_CORE_MODULE_TYPE, /* module type */
|
||||||
|
NULL /* init module */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_command_t ngx_event_commands[] = {
|
||||||
|
|
||||||
|
{ngx_string("connections"),
|
||||||
|
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_conf_set_num_slot,
|
||||||
|
0,
|
||||||
|
addressof(ngx_event_connections),
|
||||||
|
NULL},
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
{ngx_string("type"),
|
||||||
|
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_event_set_type,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL},
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{ngx_string(""), 0, NULL, 0, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ngx_module_t ngx_event_module = {
|
||||||
|
NULL, /* module context */
|
||||||
|
0, /* module index */
|
||||||
|
ngx_events_commands, /* module directives */
|
||||||
|
NGX_EVENT_MODULE_TYPE, /* module type */
|
||||||
|
NULL /* init module */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
|
void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
int i, fd;
|
int i, fd;
|
||||||
@ -173,6 +237,7 @@ void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_worker(ngx_log_t *log)
|
void ngx_worker(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
@ -181,3 +246,44 @@ void ngx_worker(ngx_log_t *log)
|
|||||||
ngx_process_events(log);
|
ngx_process_events(log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *ngx_events_init(ngx_pool_t *pool)
|
||||||
|
{
|
||||||
|
ngx_event_connections = -1;
|
||||||
|
ngx_event_type = -1;
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *ngx_events_postconf(ngx_pool_t *pool)
|
||||||
|
{
|
||||||
|
if (ngx_event_connections == -1) {
|
||||||
|
ngx_event_connections = 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
|
||||||
|
{
|
||||||
|
char *rv;
|
||||||
|
ngx_conf_t pcf;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
*(ngx_events_conf_ctx_t **) conf = ctx;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pcf = *cf;
|
||||||
|
cf->module_type = NGX_EVENT_MODULE_TYPE;
|
||||||
|
cf->cmd_type = NGX_EVENT_CONF;
|
||||||
|
rv = ngx_conf_parse(cf, NULL);
|
||||||
|
*cf = pcf;
|
||||||
|
|
||||||
|
if (rv != NGX_CONF_OK)
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
@ -298,6 +298,12 @@ extern int ngx_event_flags;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define NGX_EVENT_MODULE_TYPE 0x544E5645 /* "EVNT" */
|
||||||
|
|
||||||
|
#define NGX_EVENT_CONF 0x00200000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ngx_event_accept(ngx_event_t *ev);
|
void ngx_event_accept(ngx_event_t *ev);
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ ngx_http_module_t ngx_http_index_module_ctx = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_index_module = {
|
ngx_module_t ngx_http_index_module = {
|
||||||
0, /* module index */
|
|
||||||
&ngx_http_index_module_ctx, /* module context */
|
&ngx_http_index_module_ctx, /* module context */
|
||||||
|
0, /* module index */
|
||||||
ngx_http_index_commands, /* module directives */
|
ngx_http_index_commands, /* module directives */
|
||||||
NGX_HTTP_MODULE_TYPE, /* module type */
|
NGX_HTTP_MODULE_TYPE, /* module type */
|
||||||
ngx_http_index_init /* init module */
|
ngx_http_index_init /* init module */
|
||||||
|
@ -53,15 +53,15 @@ static ngx_command_t ngx_http_commands[] = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_module = {
|
ngx_module_t ngx_http_module = {
|
||||||
0, /* module index */
|
|
||||||
&http_name, /* module context */
|
&http_name, /* module context */
|
||||||
|
0, /* module index */
|
||||||
ngx_http_commands, /* module directives */
|
ngx_http_commands, /* module directives */
|
||||||
NGX_CORE_MODULE_TYPE, /* module type */
|
NGX_CORE_MODULE_TYPE, /* module type */
|
||||||
NULL /* init module */
|
NULL /* init module */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
|
||||||
{
|
{
|
||||||
int i, s, l, p, a, n, start;
|
int i, s, l, p, a, n, start;
|
||||||
int port_found, addr_found, virtual_names;
|
int port_found, addr_found, virtual_names;
|
||||||
@ -70,7 +70,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
ngx_array_t in_ports;
|
ngx_array_t in_ports;
|
||||||
ngx_listen_t *ls;
|
ngx_listen_t *ls;
|
||||||
ngx_http_module_t *module;
|
ngx_http_module_t *module;
|
||||||
ngx_conf_t prev;
|
ngx_conf_t pcf;
|
||||||
ngx_http_conf_ctx_t *ctx;
|
ngx_http_conf_ctx_t *ctx;
|
||||||
ngx_http_in_port_t *in_port, *inport;
|
ngx_http_in_port_t *in_port, *inport;
|
||||||
ngx_http_in_addr_t *in_addr, *inaddr;
|
ngx_http_in_addr_t *in_addr, *inaddr;
|
||||||
@ -85,6 +85,8 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
|
||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
|
*(ngx_http_conf_ctx_t **) conf = ctx;
|
||||||
|
|
||||||
ngx_http_max_module = 0;
|
ngx_http_max_module = 0;
|
||||||
for (i = 0; ngx_modules[i]; i++) {
|
for (i = 0; ngx_modules[i]; i++) {
|
||||||
if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
|
if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
|
||||||
@ -96,7 +98,20 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
module->index = ngx_http_max_module++;
|
module->index = ngx_http_max_module++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* null loc_conf */
|
/* TODO: http main_conf */
|
||||||
|
|
||||||
|
ngx_test_null(ctx->main_conf,
|
||||||
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
||||||
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
|
/* TODO: http srv_conf */
|
||||||
|
|
||||||
|
ngx_test_null(ctx->srv_conf,
|
||||||
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
||||||
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
|
/* http null loc_conf */
|
||||||
|
|
||||||
ngx_test_null(ctx->loc_conf,
|
ngx_test_null(ctx->loc_conf,
|
||||||
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
@ -115,12 +130,12 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = *cf;
|
pcf = *cf;
|
||||||
cf->ctx = ctx;
|
cf->ctx = ctx;
|
||||||
cf->module_type = NGX_HTTP_MODULE_TYPE;
|
cf->module_type = NGX_HTTP_MODULE_TYPE;
|
||||||
cf->cmd_type = NGX_HTTP_MAIN_CONF;
|
cf->cmd_type = NGX_HTTP_MAIN_CONF;
|
||||||
rv = ngx_conf_parse(cf, NULL);
|
rv = ngx_conf_parse(cf, NULL);
|
||||||
*cf = prev;
|
*cf = pcf;
|
||||||
|
|
||||||
if (rv != NGX_CONF_OK)
|
if (rv != NGX_CONF_OK)
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
void **main_conf;
|
||||||
void **srv_conf;
|
void **srv_conf;
|
||||||
void **loc_conf;
|
void **loc_conf;
|
||||||
} ngx_http_conf_ctx_t;
|
} ngx_http_conf_ctx_t;
|
||||||
@ -38,20 +39,19 @@ typedef struct {
|
|||||||
#define NGX_HTTP_LOC_CONF 0x8000000
|
#define NGX_HTTP_LOC_CONF 0x8000000
|
||||||
|
|
||||||
|
|
||||||
|
#define NGX_HTTP_MAIN_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, main_conf)
|
||||||
#define NGX_HTTP_SRV_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, srv_conf)
|
#define NGX_HTTP_SRV_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, srv_conf)
|
||||||
#define NGX_HTTP_LOC_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, loc_conf)
|
#define NGX_HTTP_LOC_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, loc_conf)
|
||||||
|
|
||||||
|
|
||||||
#define ngx_http_get_module_srv_conf(r, module) r->srv_conf[module.index]
|
#define ngx_http_get_module_main_conf(r, ctx) r->main_conf[ctx.index]
|
||||||
#define ngx_http_get_module_loc_conf(r, module) r->loc_conf[module.index]
|
#define ngx_http_get_module_srv_conf(r, ctx) r->srv_conf[ctx.index]
|
||||||
|
#define ngx_http_get_module_loc_conf(r, ctx) r->loc_conf[ctx.index]
|
||||||
|
|
||||||
|
|
||||||
int ngx_http_config_modules(ngx_pool_t *pool, ngx_module_t **modules);
|
int ngx_http_config_modules(ngx_pool_t *pool, ngx_module_t **modules);
|
||||||
|
|
||||||
|
|
||||||
extern ngx_module_t ngx_http_module;
|
|
||||||
|
|
||||||
|
|
||||||
extern int (*ngx_http_top_header_filter) (ngx_http_request_t *r);
|
extern int (*ngx_http_top_header_filter) (ngx_http_request_t *r);
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ static ngx_command_t ngx_http_core_commands[] = {
|
|||||||
{ngx_string("client_header_buffer_size"),
|
{ngx_string("client_header_buffer_size"),
|
||||||
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
||||||
ngx_conf_set_size_slot,
|
ngx_conf_set_size_slot,
|
||||||
0,
|
NGX_HTTP_MAIN_CONF_OFFSET,
|
||||||
addressof(ngx_http_client_header_buffer_size),
|
offsetof(ngx_http_core_main_conf_t, client_header_buffer_size),
|
||||||
NULL},
|
NULL},
|
||||||
|
|
||||||
{ngx_string("large_client_header"),
|
{ngx_string("large_client_header"),
|
||||||
@ -157,8 +157,8 @@ ngx_http_module_t ngx_http_core_module_ctx = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_core_module = {
|
ngx_module_t ngx_http_core_module = {
|
||||||
0, /* module index */
|
|
||||||
&ngx_http_core_module_ctx, /* module context */
|
&ngx_http_core_module_ctx, /* module context */
|
||||||
|
0, /* module index */
|
||||||
ngx_http_core_commands, /* module directives */
|
ngx_http_core_commands, /* module directives */
|
||||||
NGX_HTTP_MODULE_TYPE, /* module type */
|
NGX_HTTP_MODULE_TYPE, /* module type */
|
||||||
ngx_http_core_init /* init module */
|
ngx_http_core_init /* init module */
|
||||||
@ -615,7 +615,7 @@ static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
char *rv;
|
char *rv;
|
||||||
ngx_http_module_t *module;
|
ngx_http_module_t *module;
|
||||||
ngx_conf_t pcf;
|
ngx_conf_t pcf;
|
||||||
ngx_http_conf_ctx_t *ctx, *pctx;
|
ngx_http_conf_ctx_t *ctx, *tctx, *pctx;
|
||||||
ngx_http_core_srv_conf_t *scf;
|
ngx_http_core_srv_conf_t *scf;
|
||||||
ngx_http_core_loc_conf_t **plcf;
|
ngx_http_core_loc_conf_t **plcf;
|
||||||
|
|
||||||
@ -623,12 +623,17 @@ static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
|
|||||||
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
|
||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
/* server config */
|
tctx = (ngx_http_conf_ctx_t *) cf->ctx;
|
||||||
|
ctx->main_conf = tctx->main_conf;
|
||||||
|
|
||||||
|
/* server configuration */
|
||||||
|
|
||||||
ngx_test_null(ctx->srv_conf,
|
ngx_test_null(ctx->srv_conf,
|
||||||
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
/* server location config */
|
/* server location configuration */
|
||||||
|
|
||||||
ngx_test_null(ctx->loc_conf,
|
ngx_test_null(ctx->loc_conf,
|
||||||
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
|
@ -17,6 +17,12 @@ typedef struct {
|
|||||||
} ngx_http_listen_t;
|
} ngx_http_listen_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int request_pool_size;
|
||||||
|
int client_header_buffer_size;
|
||||||
|
} ngx_http_core_main_conf_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_array_t locations; /* array of ngx_http_core_loc_conf_t */
|
ngx_array_t locations; /* array of ngx_http_core_loc_conf_t */
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ ngx_http_module_t ngx_http_header_filter_module_ctx = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_header_filter_module = {
|
ngx_module_t ngx_http_header_filter_module = {
|
||||||
0, /* module index */
|
|
||||||
&ngx_http_header_filter_module_ctx, /* module context */
|
&ngx_http_header_filter_module_ctx, /* module context */
|
||||||
|
0, /* module index */
|
||||||
NULL, /* module directives */
|
NULL, /* module directives */
|
||||||
NGX_HTTP_MODULE_TYPE, /* module type */
|
NGX_HTTP_MODULE_TYPE, /* module type */
|
||||||
ngx_http_header_filter_init /* init module */
|
ngx_http_header_filter_init /* init module */
|
||||||
|
@ -45,8 +45,8 @@ static ngx_http_module_t ngx_http_output_filter_module_ctx = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_output_filter_module = {
|
ngx_module_t ngx_http_output_filter_module = {
|
||||||
0, /* module index */
|
|
||||||
&ngx_http_output_filter_module_ctx, /* module context */
|
&ngx_http_output_filter_module_ctx, /* module context */
|
||||||
|
0, /* module index */
|
||||||
ngx_http_output_filter_commands, /* module directives */
|
ngx_http_output_filter_commands, /* module directives */
|
||||||
NGX_HTTP_MODULE_TYPE, /* module type */
|
NGX_HTTP_MODULE_TYPE, /* module type */
|
||||||
NULL /* init module */
|
NULL /* init module */
|
||||||
|
@ -44,8 +44,8 @@ ngx_http_module_t ngx_http_write_filter_module_ctx = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_write_filter_module = {
|
ngx_module_t ngx_http_write_filter_module = {
|
||||||
0, /* module index */
|
|
||||||
&ngx_http_write_filter_module_ctx, /* module context */
|
&ngx_http_write_filter_module_ctx, /* module context */
|
||||||
|
0, /* module index */
|
||||||
ngx_http_write_filter_commands, /* module directives */
|
ngx_http_write_filter_commands, /* module directives */
|
||||||
NGX_HTTP_MODULE_TYPE, /* module type */
|
NGX_HTTP_MODULE_TYPE, /* module type */
|
||||||
ngx_http_write_filter_init /* init module */
|
ngx_http_write_filter_init /* init module */
|
||||||
|
Loading…
Reference in New Issue
Block a user