2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
2003-10-10 11:10:50 -04:00
|
|
|
#include <ngx_event.h>
|
2003-01-09 02:36:00 -03:00
|
|
|
#include <ngx_http.h>
|
2003-05-27 08:18:54 -04:00
|
|
|
#include <nginx.h>
|
2003-10-29 05:30:44 -03:00
|
|
|
#if __FreeBSD__
|
|
|
|
#include <ngx_freebsd_init.h>
|
|
|
|
#endif
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
static void ngx_http_phase_event_handler(ngx_event_t *rev);
|
|
|
|
static void ngx_http_run_phases(ngx_http_request_t *r);
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
|
|
|
|
static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
|
|
|
|
static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
|
|
|
|
static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
|
2003-05-19 12:39:14 -04:00
|
|
|
void *parent, void *child);
|
2003-07-20 17:15:59 -04:00
|
|
|
static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf);
|
|
|
|
static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
|
2003-04-08 11:40:10 -04:00
|
|
|
void *parent, void *child);
|
2003-03-20 12:09:44 -04:00
|
|
|
|
2003-07-04 11:10:33 -04:00
|
|
|
static int ngx_http_core_init(ngx_cycle_t *cycle);
|
2003-05-27 08:18:54 -04:00
|
|
|
static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy);
|
2003-05-29 09:02:09 -04:00
|
|
|
static int ngx_cmp_locations(const void *first, const void *second);
|
2003-03-20 12:09:44 -04:00
|
|
|
static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
2003-07-20 17:15:59 -04:00
|
|
|
void *dummy);
|
2003-05-27 08:18:54 -04:00
|
|
|
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
2003-05-30 10:27:59 -04:00
|
|
|
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
|
2003-05-27 08:18:54 -04:00
|
|
|
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
2003-05-29 09:02:09 -04:00
|
|
|
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
|
2003-07-20 17:15:59 -04:00
|
|
|
void *conf);
|
|
|
|
static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-10-29 05:30:44 -03:00
|
|
|
static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data);
|
|
|
|
|
|
|
|
static ngx_conf_post_t ngx_http_lowat_post = { ngx_http_lowat_check } ;
|
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
static ngx_command_t ngx_http_core_commands[] = {
|
|
|
|
|
|
|
|
{ngx_string("server"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
|
|
|
ngx_server_block,
|
|
|
|
0,
|
2003-05-15 11:42:53 -04:00
|
|
|
0,
|
2003-05-29 09:02:09 -04:00
|
|
|
NULL},
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-23 07:53:01 -04:00
|
|
|
{ngx_string("connection_pool_size"),
|
2003-06-11 11:28:34 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
2003-05-23 07:53:01 -04:00
|
|
|
ngx_conf_set_size_slot,
|
2003-06-11 11:28:34 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_srv_conf_t, connection_pool_size),
|
2003-05-15 11:42:53 -04:00
|
|
|
NULL},
|
2003-03-04 03:33:48 -03:00
|
|
|
|
2003-05-23 07:53:01 -04:00
|
|
|
{ngx_string("post_accept_timeout"),
|
2003-06-11 11:28:34 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
2003-05-23 07:53:01 -04:00
|
|
|
ngx_conf_set_msec_slot,
|
2003-06-11 11:28:34 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_srv_conf_t, post_accept_timeout),
|
2003-05-15 11:42:53 -04:00
|
|
|
NULL},
|
2003-03-04 03:33:48 -03:00
|
|
|
|
|
|
|
{ngx_string("request_pool_size"),
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
2003-03-04 03:33:48 -03:00
|
|
|
ngx_conf_set_size_slot,
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_srv_conf_t, request_pool_size),
|
2003-05-15 11:42:53 -04:00
|
|
|
NULL},
|
2003-03-04 03:33:48 -03:00
|
|
|
|
|
|
|
{ngx_string("client_header_timeout"),
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
2003-05-06 13:03:16 -04:00
|
|
|
ngx_conf_set_msec_slot,
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_srv_conf_t, client_header_timeout),
|
2003-05-15 11:42:53 -04:00
|
|
|
NULL},
|
2003-03-04 03:33:48 -03:00
|
|
|
|
|
|
|
{ngx_string("client_header_buffer_size"),
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
2003-03-04 03:33:48 -03:00
|
|
|
ngx_conf_set_size_slot,
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_srv_conf_t, client_header_buffer_size),
|
2003-05-15 11:42:53 -04:00
|
|
|
NULL},
|
2003-03-04 03:33:48 -03:00
|
|
|
|
|
|
|
{ngx_string("large_client_header"),
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
2003-03-04 03:33:48 -03:00
|
|
|
ngx_conf_set_flag_slot,
|
2003-05-23 07:53:01 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_srv_conf_t, large_client_header),
|
2003-05-15 11:42:53 -04:00
|
|
|
NULL},
|
2003-03-04 03:33:48 -03:00
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
{ngx_string("location"),
|
|
|
|
NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE1,
|
|
|
|
ngx_location_block,
|
2003-04-08 11:40:10 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
0,
|
|
|
|
NULL},
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-01-28 12:56:37 -03:00
|
|
|
{ngx_string("listen"),
|
2003-06-02 11:24:30 -04:00
|
|
|
#if 0
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
2003-06-02 11:24:30 -04:00
|
|
|
#else
|
|
|
|
NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
|
|
|
#endif
|
2003-01-28 12:56:37 -03:00
|
|
|
ngx_set_listen,
|
2003-04-08 11:40:10 -04:00
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
0,
|
|
|
|
NULL},
|
2003-01-28 12:56:37 -03:00
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
{ngx_string("server_name"),
|
2003-06-02 11:24:30 -04:00
|
|
|
NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
|
2003-05-29 09:02:09 -04:00
|
|
|
ngx_set_server_name,
|
|
|
|
NGX_HTTP_SRV_CONF_OFFSET,
|
|
|
|
0,
|
|
|
|
NULL},
|
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
{ngx_string("types"),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF
|
|
|
|
|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
2003-05-14 13:13:13 -04:00
|
|
|
ngx_types_block,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
0,
|
|
|
|
NULL},
|
2003-05-14 13:13:13 -04:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
{ngx_string("default_type"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_conf_set_str_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_loc_conf_t, default_type),
|
|
|
|
NULL},
|
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
{ngx_string("root"),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
2003-01-09 02:36:00 -03:00
|
|
|
ngx_conf_set_str_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
offsetof(ngx_http_core_loc_conf_t, doc_root),
|
|
|
|
NULL},
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-10-27 18:01:00 -03:00
|
|
|
{ngx_string("client_body_timeout"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_conf_set_msec_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_loc_conf_t, client_body_timeout),
|
|
|
|
NULL},
|
|
|
|
|
2003-10-22 04:05:29 -03:00
|
|
|
{ngx_string("sendfile"),
|
2003-10-28 12:45:41 -03:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
2003-10-22 04:05:29 -03:00
|
|
|
ngx_conf_set_flag_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_loc_conf_t, sendfile),
|
|
|
|
NULL},
|
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
{ngx_string("send_timeout"),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
2003-05-06 13:03:16 -04:00
|
|
|
ngx_conf_set_msec_slot,
|
2003-01-09 02:36:00 -03:00
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
offsetof(ngx_http_core_loc_conf_t, send_timeout),
|
|
|
|
NULL},
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-10-29 05:30:44 -03:00
|
|
|
{ngx_string("send_lowat"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_conf_set_size_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_loc_conf_t, send_lowat),
|
|
|
|
&ngx_http_lowat_post},
|
|
|
|
|
2003-05-21 09:28:21 -04:00
|
|
|
{ngx_string("keepalive_timeout"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_conf_set_msec_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_loc_conf_t, keepalive_timeout),
|
|
|
|
NULL},
|
|
|
|
|
2003-03-11 16:38:13 -04:00
|
|
|
{ngx_string("lingering_time"),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
2003-05-06 13:03:16 -04:00
|
|
|
ngx_conf_set_msec_slot,
|
2003-03-11 16:38:13 -04:00
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
offsetof(ngx_http_core_loc_conf_t, lingering_time),
|
|
|
|
NULL},
|
2003-03-11 16:38:13 -04:00
|
|
|
|
|
|
|
{ngx_string("lingering_timeout"),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
2003-05-06 13:03:16 -04:00
|
|
|
ngx_conf_set_msec_slot,
|
2003-03-11 16:38:13 -04:00
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
2003-05-15 11:42:53 -04:00
|
|
|
offsetof(ngx_http_core_loc_conf_t, lingering_timeout),
|
|
|
|
NULL},
|
2003-03-11 16:38:13 -04:00
|
|
|
|
2003-10-24 03:53:41 -03:00
|
|
|
{ngx_string("msie_padding"),
|
2003-10-28 12:45:41 -03:00
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
2003-10-24 03:53:41 -03:00
|
|
|
ngx_conf_set_flag_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_core_loc_conf_t, msie_padding),
|
|
|
|
NULL},
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
{ngx_string("error_log"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_set_error_log,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
0,
|
|
|
|
NULL},
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_null_command
|
2003-01-09 02:36:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ngx_http_module_t ngx_http_core_module_ctx = {
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_http_core_create_main_conf, /* create main configuration */
|
|
|
|
ngx_http_core_init_main_conf, /* init main configuration */
|
|
|
|
|
|
|
|
ngx_http_core_create_srv_conf, /* create server configuration */
|
|
|
|
ngx_http_core_merge_srv_conf, /* merge server configuration */
|
2003-03-20 12:09:44 -04:00
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_http_core_create_loc_conf, /* create location configuration */
|
|
|
|
ngx_http_core_merge_loc_conf /* merge location configuration */
|
2003-01-09 02:36:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ngx_module_t ngx_http_core_module = {
|
2003-05-27 08:18:54 -04:00
|
|
|
NGX_MODULE,
|
2003-01-09 02:36:00 -03:00
|
|
|
&ngx_http_core_module_ctx, /* module context */
|
|
|
|
ngx_http_core_commands, /* module directives */
|
2003-05-27 08:18:54 -04:00
|
|
|
NGX_HTTP_MODULE, /* module type */
|
2003-07-02 10:41:17 -04:00
|
|
|
ngx_http_core_init, /* init module */
|
2003-07-04 11:10:33 -04:00
|
|
|
NULL /* init child */
|
2003-01-09 02:36:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-05-15 11:42:53 -04:00
|
|
|
void ngx_http_handler(ngx_http_request_t *r)
|
|
|
|
{
|
2003-10-10 11:10:50 -04:00
|
|
|
ngx_http_log_ctx_t *lcx;
|
2003-05-15 11:42:53 -04:00
|
|
|
|
|
|
|
r->connection->unexpected_eof = 0;
|
|
|
|
|
2003-06-02 11:24:30 -04:00
|
|
|
lcx = r->connection->log->data;
|
|
|
|
lcx->action = NULL;
|
|
|
|
|
2003-10-21 13:49:56 -03:00
|
|
|
switch (r->headers_in.connection_type) {
|
|
|
|
case 0:
|
|
|
|
if (r->http_version > NGX_HTTP_VERSION_10) {
|
|
|
|
r->keepalive = 1;
|
|
|
|
} else {
|
2003-10-21 04:47:21 -03:00
|
|
|
r->keepalive = 0;
|
|
|
|
}
|
2003-10-21 13:49:56 -03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NGX_HTTP_CONNECTION_CLOSE:
|
|
|
|
r->keepalive = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NGX_HTTP_CONNECTION_KEEP_ALIVE:
|
|
|
|
r->keepalive = 1;
|
|
|
|
break;
|
2003-10-21 04:47:21 -03:00
|
|
|
}
|
|
|
|
|
2003-10-27 05:53:49 -03:00
|
|
|
#if 0
|
2003-10-22 13:38:26 -03:00
|
|
|
/* TEST STUB */ r->http_version = NGX_HTTP_VERSION_10;
|
2003-10-21 04:47:21 -03:00
|
|
|
/* TEST STUB */ r->keepalive = 0;
|
|
|
|
#endif
|
2003-05-15 11:42:53 -04:00
|
|
|
|
|
|
|
if (r->headers_in.content_length_n > 0) {
|
|
|
|
r->lingering_close = 1;
|
2003-10-21 04:47:21 -03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
r->lingering_close = 0;
|
2003-05-15 11:42:53 -04:00
|
|
|
}
|
|
|
|
|
2003-10-21 04:47:21 -03:00
|
|
|
#if 0
|
2003-05-15 11:42:53 -04:00
|
|
|
/* TEST STUB */ r->lingering_close = 1;
|
2003-10-21 04:47:21 -03:00
|
|
|
#endif
|
2003-05-15 11:42:53 -04:00
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
r->connection->write->event_handler = ngx_http_phase_event_handler;
|
|
|
|
|
|
|
|
ngx_http_run_phases(r);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ngx_http_phase_event_handler(ngx_event_t *ev)
|
|
|
|
{
|
|
|
|
ngx_connection_t *c;
|
|
|
|
ngx_http_request_t *r;
|
|
|
|
|
|
|
|
c = ev->data;
|
|
|
|
r = c->data;
|
|
|
|
|
2003-10-12 13:49:16 -03:00
|
|
|
ngx_log_debug(ev->log, "phase event handler");
|
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
ngx_http_run_phases(r);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ngx_http_run_phases(ngx_http_request_t *r)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
ngx_http_handler_pt *h;
|
|
|
|
ngx_http_core_main_conf_t *cmcf;
|
|
|
|
|
|
|
|
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
|
|
|
|
|
|
|
rc = NGX_DECLINED;
|
|
|
|
|
|
|
|
for (/* void */; r->phase < NGX_HTTP_LAST_PHASE; r->phase++) {
|
|
|
|
|
|
|
|
h = cmcf->phases[r->phase].handlers.elts;
|
|
|
|
for (r->phase_handler = cmcf->phases[r->phase].handlers.nelts - 1;
|
|
|
|
r->phase_handler >= 0;
|
|
|
|
r->phase_handler--)
|
|
|
|
{
|
|
|
|
rc = h[r->phase_handler](r);
|
|
|
|
|
2003-10-21 04:47:21 -03:00
|
|
|
if (rc == NGX_DONE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
if (rc == NGX_DECLINED) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == NGX_AGAIN) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
|
|
ngx_http_finalize_request(r, rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmcf->phases[r->phase].post_handler) {
|
|
|
|
rc = cmcf->phases[r->phase].post_handler(r);
|
2003-05-15 11:42:53 -04:00
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
if (rc == NGX_AGAIN) {
|
|
|
|
return;
|
|
|
|
}
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
|
|
|
ngx_http_finalize_request(r, rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
if (r->content_handler) {
|
|
|
|
r->connection->write->event_handler = ngx_http_writer;
|
|
|
|
rc = r->content_handler(r);
|
|
|
|
ngx_http_finalize_request(r, rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ngx_http_find_location_config(ngx_http_request_t *r)
|
|
|
|
{
|
2003-10-21 13:49:56 -03:00
|
|
|
int i, rc;
|
|
|
|
ngx_http_core_loc_conf_t *clcf, **clcfp;
|
|
|
|
ngx_http_core_srv_conf_t *cscf;
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
clcfp = cscf->locations.elts;
|
|
|
|
for (i = 0; i < cscf->locations.nelts; i++) {
|
2003-04-08 11:40:10 -04:00
|
|
|
#if 0
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_log_debug(r->connection->log, "trans: %s" _ clcfp[i]->name.data);
|
2003-04-08 11:40:10 -04:00
|
|
|
#endif
|
2003-07-20 17:15:59 -04:00
|
|
|
if (r->uri.len < clcfp[i]->name.len) {
|
|
|
|
continue;
|
|
|
|
}
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
rc = ngx_strncmp(r->uri.data, clcfp[i]->name.data,
|
|
|
|
clcfp[i]->name.len);
|
2003-05-29 09:02:09 -04:00
|
|
|
|
|
|
|
ngx_log_debug(r->connection->log, "rc: %d" _ rc);
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
if (rc < 0) {
|
|
|
|
break;
|
|
|
|
}
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
if (rc == 0) {
|
|
|
|
r->loc_conf = clcfp[i]->loc_conf;
|
|
|
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
|
|
r->connection->log->file = clcf->err_log->file;
|
|
|
|
r->connection->log->log_level = clcf->err_log->log_level;
|
|
|
|
}
|
2003-04-08 11:40:10 -04:00
|
|
|
}
|
|
|
|
|
2003-10-22 04:05:29 -03:00
|
|
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-10-22 04:05:29 -03:00
|
|
|
if (!(ngx_io.flags & NGX_IO_SENDFILE) || !clcf->sendfile) {
|
|
|
|
r->sendfile = 0;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-10-22 04:05:29 -03:00
|
|
|
} else {
|
|
|
|
r->sendfile = 1;
|
|
|
|
}
|
2003-10-21 13:49:56 -03:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
if (clcf->handler) {
|
2003-10-16 17:19:16 -03:00
|
|
|
/*
|
|
|
|
* if the location already has content handler then skip
|
|
|
|
* the translation phase
|
|
|
|
*/
|
2003-10-12 13:49:16 -03:00
|
|
|
|
2003-10-16 17:19:16 -03:00
|
|
|
r->content_handler = clcf->handler;
|
|
|
|
r->phase++;
|
2003-01-09 02:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ngx_http_send_header(ngx_http_request_t *r)
|
|
|
|
{
|
2003-10-27 05:53:49 -03:00
|
|
|
if (r->main) {
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
return (*ngx_http_top_header_filter)(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ngx_http_redirect(ngx_http_request_t *r, int redirect)
|
|
|
|
{
|
|
|
|
/* STUB */
|
|
|
|
|
|
|
|
/* log request */
|
|
|
|
|
2003-05-13 12:02:32 -04:00
|
|
|
ngx_http_close_request(r, 0);
|
|
|
|
return NGX_OK;
|
2003-01-09 02:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
int ngx_http_error(ngx_http_request_t *r, int error)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
|
|
|
/* STUB */
|
|
|
|
ngx_log_debug(r->connection->log, "http error: %d" _ error);
|
|
|
|
|
|
|
|
/* log request */
|
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_http_special_response_handler(r, error);
|
2003-05-13 12:02:32 -04:00
|
|
|
ngx_http_close_request(r, 0);
|
|
|
|
return NGX_OK;
|
2003-01-09 02:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
int ngx_http_internal_redirect(ngx_http_request_t *r,
|
|
|
|
ngx_str_t *uri, ngx_str_t *args)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
2003-05-29 09:02:09 -04:00
|
|
|
int i;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
ngx_log_debug(r->connection->log, "internal redirect: '%s'" _ uri->data);
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
r->uri.len = uri->len;
|
|
|
|
r->uri.data = uri->data;
|
|
|
|
|
|
|
|
if (args) {
|
|
|
|
r->args.len = args->len;
|
|
|
|
r->args.data = args->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
r->exten.len = 0;
|
|
|
|
r->exten.data = NULL;
|
|
|
|
|
|
|
|
for (i = uri->len - 1; i > 1; i--) {
|
|
|
|
if (uri->data[i] == '.' && uri->data[i - 1] != '/') {
|
|
|
|
r->exten.len = uri->len - i - 1;
|
|
|
|
|
|
|
|
if (r->exten.len > 0) {
|
|
|
|
ngx_test_null(r->exten.data,
|
|
|
|
ngx_palloc(r->pool, r->exten.len + 1),
|
|
|
|
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
|
|
|
|
|
|
ngx_cpystrn(r->exten.data, &uri->data[i + 1], r->exten.len + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else if (uri->data[i] == '/') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-10-12 13:49:16 -03:00
|
|
|
/* clear the modules contexts */
|
|
|
|
ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
|
|
|
|
|
|
|
|
r->phase = 0;
|
|
|
|
r->phase_handler = 0;
|
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
ngx_http_handler(r);
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-10-21 04:47:21 -03:00
|
|
|
return NGX_DONE;
|
2003-01-09 02:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-12 13:49:16 -03:00
|
|
|
#if 1 /* STUB: test the delay http handler */
|
|
|
|
|
|
|
|
int ngx_http_delay_handler(ngx_http_request_t *r)
|
|
|
|
{
|
|
|
|
static int on;
|
|
|
|
|
|
|
|
if (on++ == 0) {
|
|
|
|
ngx_log_debug(r->connection->log, "SET http delay");
|
|
|
|
ngx_add_timer(r->connection->write, 10000);
|
|
|
|
return NGX_AGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
r->connection->write->timedout = 0;
|
|
|
|
ngx_log_debug(r->connection->log, "RESET http delay");
|
|
|
|
return NGX_DECLINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-07-04 11:10:33 -04:00
|
|
|
static int ngx_http_core_init(ngx_cycle_t *cycle)
|
2003-03-20 12:09:44 -04:00
|
|
|
{
|
2003-10-16 17:19:16 -03:00
|
|
|
#if 0
|
2003-07-02 14:51:41 -04:00
|
|
|
ngx_http_handler_pt *h;
|
2003-10-16 17:19:16 -03:00
|
|
|
#endif
|
2003-07-02 14:51:41 -04:00
|
|
|
ngx_http_conf_ctx_t *ctx;
|
|
|
|
ngx_http_core_main_conf_t *cmcf;
|
|
|
|
|
|
|
|
ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
|
|
|
|
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
2003-03-20 12:09:44 -04:00
|
|
|
|
2003-10-12 13:49:16 -03:00
|
|
|
#if 0
|
|
|
|
ngx_test_null(h, ngx_push_array(
|
|
|
|
&cmcf->phases[NGX_HTTP_TRANSLATE_PHASE].handlers),
|
|
|
|
NGX_ERROR);
|
|
|
|
*h = ngx_http_delay_handler;
|
|
|
|
#endif
|
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
2003-05-20 11:37:55 -04:00
|
|
|
int m;
|
2003-05-19 12:39:14 -04:00
|
|
|
char *rv;
|
|
|
|
ngx_http_module_t *module;
|
|
|
|
ngx_conf_t pcf;
|
|
|
|
ngx_http_conf_ctx_t *ctx, *hctx, *pctx;
|
|
|
|
ngx_http_core_main_conf_t *cmcf;
|
|
|
|
ngx_http_core_srv_conf_t *cscf, **cscfp;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
ngx_test_null(ctx,
|
|
|
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
hctx = (ngx_http_conf_ctx_t *) cf->ctx;
|
|
|
|
ctx->main_conf = hctx->main_conf;
|
2003-05-16 11:27:48 -04:00
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
/* the server{}'s srv_conf */
|
2003-05-16 11:27:48 -04:00
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
ngx_test_null(ctx->srv_conf,
|
|
|
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
/* the server{}'s loc_conf */
|
2003-05-16 11:27:48 -04:00
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
ngx_test_null(ctx->loc_conf,
|
|
|
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-05-20 11:37:55 -04:00
|
|
|
for (m = 0; ngx_modules[m]; m++) {
|
2003-05-27 08:18:54 -04:00
|
|
|
if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
|
2003-01-09 02:36:00 -03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
module = ngx_modules[m]->ctx;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
if (module->create_srv_conf) {
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_test_null(ctx->srv_conf[ngx_modules[m]->ctx_index],
|
2003-07-20 17:15:59 -04:00
|
|
|
module->create_srv_conf(cf),
|
2003-01-09 02:36:00 -03:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (module->create_loc_conf) {
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_test_null(ctx->loc_conf[ngx_modules[m]->ctx_index],
|
2003-07-20 17:15:59 -04:00
|
|
|
module->create_loc_conf(cf),
|
2003-01-09 02:36:00 -03:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
/* create links of the srv_conf's */
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
|
2003-05-19 12:39:14 -04:00
|
|
|
cscf->ctx = ctx;
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_test_null(cscfp, ngx_push_array(&cmcf->servers), NGX_CONF_ERROR);
|
|
|
|
*cscfp = cscf;
|
|
|
|
|
|
|
|
/* parse inside server{} */
|
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
pcf = *cf;
|
|
|
|
pctx = cf->ctx;
|
2003-01-09 02:36:00 -03:00
|
|
|
cf->ctx = ctx;
|
2003-05-14 13:13:13 -04:00
|
|
|
cf->cmd_type = NGX_HTTP_SRV_CONF;
|
2003-01-09 02:36:00 -03:00
|
|
|
rv = ngx_conf_parse(cf, NULL);
|
2003-05-14 13:13:13 -04:00
|
|
|
*cf = pcf;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
if (rv != NGX_CONF_OK) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_qsort(cscf->locations.elts, cscf->locations.nelts,
|
|
|
|
sizeof(void *), ngx_cmp_locations);
|
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
return rv;
|
2003-01-09 02:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
static int ngx_cmp_locations(const void *first, const void *second)
|
|
|
|
{
|
|
|
|
ngx_http_core_loc_conf_t *one = *(ngx_http_core_loc_conf_t **) first;
|
|
|
|
ngx_http_core_loc_conf_t *two = *(ngx_http_core_loc_conf_t **) second;
|
|
|
|
|
|
|
|
return ngx_strcmp(one->name.data, two->name.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
2003-05-27 08:18:54 -04:00
|
|
|
int m;
|
2003-01-09 02:36:00 -03:00
|
|
|
char *rv;
|
|
|
|
ngx_str_t *location;
|
|
|
|
ngx_http_module_t *module;
|
2003-05-14 13:13:13 -04:00
|
|
|
ngx_conf_t pcf;
|
|
|
|
ngx_http_conf_ctx_t *ctx, *pctx;
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_http_core_srv_conf_t *cscf;
|
|
|
|
ngx_http_core_loc_conf_t *clcf, **clcfp;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
ngx_test_null(ctx,
|
|
|
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
pctx = (ngx_http_conf_ctx_t *) cf->ctx;
|
2003-05-19 12:39:14 -04:00
|
|
|
ctx->main_conf = pctx->main_conf;
|
2003-05-14 13:13:13 -04:00
|
|
|
ctx->srv_conf = pctx->srv_conf;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
ngx_test_null(ctx->loc_conf,
|
|
|
|
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
for (m = 0; ngx_modules[m]; m++) {
|
|
|
|
if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
|
2003-01-09 02:36:00 -03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
module = ngx_modules[m]->ctx;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
if (module->create_loc_conf) {
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_test_null(ctx->loc_conf[ngx_modules[m]->ctx_index],
|
2003-07-20 17:15:59 -04:00
|
|
|
module->create_loc_conf(cf),
|
2003-01-09 02:36:00 -03:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
|
2003-01-09 02:36:00 -03:00
|
|
|
location = (ngx_str_t *) cf->args->elts;
|
2003-05-19 12:39:14 -04:00
|
|
|
clcf->name.len = location[1].len;
|
|
|
|
clcf->name.data = location[1].data;
|
|
|
|
clcf->loc_conf = ctx->loc_conf;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_test_null(clcfp, ngx_push_array(&cscf->locations), NGX_CONF_ERROR);
|
|
|
|
*clcfp = clcf;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
pcf = *cf;
|
2003-01-09 02:36:00 -03:00
|
|
|
cf->ctx = ctx;
|
2003-05-14 13:13:13 -04:00
|
|
|
cf->cmd_type = NGX_HTTP_LOC_CONF;
|
2003-01-09 02:36:00 -03:00
|
|
|
rv = ngx_conf_parse(cf, NULL);
|
2003-05-14 13:13:13 -04:00
|
|
|
*cf = pcf;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-30 10:27:59 -04:00
|
|
|
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
2003-05-14 13:13:13 -04:00
|
|
|
{
|
2003-05-30 10:27:59 -04:00
|
|
|
char *rv;
|
|
|
|
ngx_conf_t pcf;
|
|
|
|
|
|
|
|
pcf = *cf;
|
|
|
|
cf->handler = ngx_set_type;
|
|
|
|
cf->handler_conf = conf;
|
|
|
|
rv = ngx_conf_parse(cf, NULL);
|
|
|
|
*cf = pcf;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
|
|
|
{
|
|
|
|
ngx_http_core_loc_conf_t *lcf = conf;
|
2003-05-14 13:13:13 -04:00
|
|
|
|
|
|
|
int i, key;
|
|
|
|
ngx_str_t *args;
|
|
|
|
ngx_http_type_t *t;
|
|
|
|
|
|
|
|
if (lcf->types == NULL) {
|
|
|
|
ngx_test_null(lcf->types,
|
|
|
|
ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME
|
|
|
|
* sizeof(ngx_array_t)),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
|
|
|
for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
|
|
|
|
ngx_init_array(lcf->types[i], cf->pool, 5, sizeof(ngx_http_type_t),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
args = (ngx_str_t *) cf->args->elts;
|
|
|
|
|
|
|
|
for (i = 1; i < cf->args->nelts; i++) {
|
|
|
|
ngx_http_types_hash_key(key, args[i]);
|
|
|
|
|
|
|
|
ngx_test_null(t, ngx_push_array(&lcf->types[key]), NGX_CONF_ERROR);
|
|
|
|
t->exten.len = args[i].len;
|
|
|
|
t->exten.data = args[i].data;
|
|
|
|
t->type.len = args[0].len;
|
|
|
|
t->type.data = args[0].data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static void *ngx_http_core_create_main_conf(ngx_conf_t *cf)
|
2003-05-19 12:39:14 -04:00
|
|
|
{
|
|
|
|
ngx_http_core_main_conf_t *cmcf;
|
|
|
|
|
|
|
|
ngx_test_null(cmcf,
|
2003-10-10 11:10:50 -04:00
|
|
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_init_array(cmcf->servers, cf->pool,
|
|
|
|
5, sizeof(ngx_http_core_srv_conf_t *),
|
2003-05-19 12:39:14 -04:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
|
|
|
return cmcf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf)
|
2003-05-19 12:39:14 -04:00
|
|
|
{
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_http_core_main_conf_t *cmcf = conf;
|
2003-05-19 12:39:14 -04:00
|
|
|
|
2003-06-11 11:28:34 -04:00
|
|
|
/* TODO: remove it if no directives */
|
2003-05-19 12:39:14 -04:00
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_http_core_srv_conf_t *cscf;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_test_null(cscf,
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)),
|
2003-01-09 02:36:00 -03:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_init_array(cscf->locations, cf->pool,
|
|
|
|
5, sizeof(void *), NGX_CONF_ERROR);
|
|
|
|
ngx_init_array(cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t),
|
2003-01-15 04:02:27 -03:00
|
|
|
NGX_CONF_ERROR);
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_init_array(cscf->server_names, cf->pool,
|
|
|
|
5, sizeof(ngx_http_server_name_t), NGX_CONF_ERROR);
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-06-11 11:28:34 -04:00
|
|
|
cscf->connection_pool_size = NGX_CONF_UNSET;
|
|
|
|
cscf->post_accept_timeout = NGX_CONF_UNSET;
|
2003-05-23 07:53:01 -04:00
|
|
|
cscf->request_pool_size = NGX_CONF_UNSET;
|
|
|
|
cscf->client_header_timeout = NGX_CONF_UNSET;
|
|
|
|
cscf->client_header_buffer_size = NGX_CONF_UNSET;
|
|
|
|
cscf->large_client_header = NGX_CONF_UNSET;
|
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
return cscf;
|
2003-01-09 02:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
|
2003-05-19 12:39:14 -04:00
|
|
|
void *parent, void *child)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
2003-05-30 10:27:59 -04:00
|
|
|
ngx_http_core_srv_conf_t *prev = parent;
|
|
|
|
ngx_http_core_srv_conf_t *conf = child;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
|
|
|
ngx_http_listen_t *l;
|
2003-01-15 04:02:27 -03:00
|
|
|
ngx_http_server_name_t *n;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-06-02 11:24:30 -04:00
|
|
|
/* TODO: it does not merge, it inits only */
|
2003-05-19 12:39:14 -04:00
|
|
|
|
|
|
|
if (conf->listen.nelts == 0) {
|
|
|
|
ngx_test_null(l, ngx_push_array(&conf->listen), NGX_CONF_ERROR);
|
2003-01-09 02:36:00 -03:00
|
|
|
l->addr = INADDR_ANY;
|
2003-06-03 11:42:58 -04:00
|
|
|
#if (WIN32)
|
|
|
|
l->port = 80;
|
|
|
|
#else
|
2003-06-02 11:24:30 -04:00
|
|
|
/* STUB: getuid() should be cached */
|
|
|
|
l->port = (getuid() == 0) ? 80 : 8000;
|
2003-06-03 11:42:58 -04:00
|
|
|
#endif
|
2003-01-09 02:36:00 -03:00
|
|
|
l->family = AF_INET;
|
|
|
|
}
|
|
|
|
|
2003-05-19 12:39:14 -04:00
|
|
|
if (conf->server_names.nelts == 0) {
|
|
|
|
ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR);
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_test_null(n->name.data, ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN),
|
2003-01-15 04:02:27 -03:00
|
|
|
NGX_CONF_ERROR);
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-01-15 04:02:27 -03:00
|
|
|
if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) {
|
2003-07-18 10:44:05 -04:00
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
|
|
|
"gethostname() failed");
|
|
|
|
return NGX_CONF_ERROR;
|
2003-01-15 04:02:27 -03:00
|
|
|
}
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-01-15 04:02:27 -03:00
|
|
|
n->name.len = ngx_strlen(n->name.data);
|
|
|
|
n->core_srv_conf = conf;
|
|
|
|
}
|
|
|
|
|
2003-06-11 11:28:34 -04:00
|
|
|
ngx_conf_merge_size_value(conf->connection_pool_size,
|
|
|
|
prev->connection_pool_size, 16384);
|
|
|
|
ngx_conf_merge_msec_value(conf->post_accept_timeout,
|
|
|
|
prev->post_accept_timeout, 30000);
|
2003-05-23 07:53:01 -04:00
|
|
|
ngx_conf_merge_size_value(conf->request_pool_size,
|
|
|
|
prev->request_pool_size, 16384);
|
|
|
|
ngx_conf_merge_msec_value(conf->client_header_timeout,
|
|
|
|
prev->client_header_timeout, 60000);
|
|
|
|
ngx_conf_merge_size_value(conf->client_header_buffer_size,
|
|
|
|
prev->client_header_buffer_size, 1024);
|
|
|
|
ngx_conf_merge_value(conf->large_client_header,
|
|
|
|
prev->large_client_header, 1);
|
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf)
|
2003-01-09 02:36:00 -03:00
|
|
|
{
|
|
|
|
ngx_http_core_loc_conf_t *lcf;
|
|
|
|
|
|
|
|
ngx_test_null(lcf,
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)),
|
2003-01-09 02:36:00 -03:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
2003-05-15 11:42:53 -04:00
|
|
|
/* set by ngx_pcalloc():
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
lcf->doc_root.len = 0;
|
|
|
|
lcf->doc_root.data = NULL;
|
|
|
|
lcf->types = NULL;
|
2003-05-27 08:18:54 -04:00
|
|
|
lcf->default_type.len = 0;
|
|
|
|
lcf->default_type.data = NULL;
|
2003-07-07 02:11:50 -04:00
|
|
|
lcf->err_log = NULL;
|
2003-05-15 11:42:53 -04:00
|
|
|
|
|
|
|
*/
|
2003-04-08 11:40:10 -04:00
|
|
|
|
2003-10-27 18:01:00 -03:00
|
|
|
lcf->client_body_timeout = NGX_CONF_UNSET;
|
2003-10-22 04:05:29 -03:00
|
|
|
lcf->sendfile = NGX_CONF_UNSET;
|
2003-01-09 02:36:00 -03:00
|
|
|
lcf->send_timeout = NGX_CONF_UNSET;
|
2003-10-29 05:30:44 -03:00
|
|
|
lcf->send_lowat = NGX_CONF_UNSET;
|
2003-05-14 13:13:13 -04:00
|
|
|
lcf->discarded_buffer_size = NGX_CONF_UNSET;
|
2003-05-21 09:28:21 -04:00
|
|
|
lcf->keepalive_timeout = NGX_CONF_UNSET;
|
2003-05-14 13:13:13 -04:00
|
|
|
lcf->lingering_time = NGX_CONF_UNSET;
|
|
|
|
lcf->lingering_timeout = NGX_CONF_UNSET;
|
2003-01-09 02:36:00 -03:00
|
|
|
|
2003-10-24 03:53:41 -03:00
|
|
|
lcf->msie_padding = NGX_CONF_UNSET;
|
|
|
|
|
2003-01-09 02:36:00 -03:00
|
|
|
return lcf;
|
|
|
|
}
|
2003-01-28 12:56:37 -03:00
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
|
|
|
|
static ngx_http_type_t default_types[] = {
|
|
|
|
{ ngx_string("html"), ngx_string("text/html") },
|
|
|
|
{ ngx_string("gif"), ngx_string("image/gif") },
|
|
|
|
{ ngx_string("jpg"), ngx_string("image/jpeg") },
|
|
|
|
{ ngx_null_string, ngx_null_string }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
|
2003-04-08 11:40:10 -04:00
|
|
|
void *parent, void *child)
|
|
|
|
{
|
2003-05-30 10:27:59 -04:00
|
|
|
ngx_http_core_loc_conf_t *prev = parent;
|
|
|
|
ngx_http_core_loc_conf_t *conf = child;
|
2003-05-14 13:13:13 -04:00
|
|
|
|
|
|
|
int i, key;
|
|
|
|
ngx_http_type_t *t;
|
|
|
|
|
2003-06-02 11:24:30 -04:00
|
|
|
ngx_conf_merge_str_value(conf->doc_root, prev->doc_root, "html");
|
2003-05-14 13:13:13 -04:00
|
|
|
|
|
|
|
if (conf->types == NULL) {
|
|
|
|
if (prev->types) {
|
|
|
|
conf->types = prev->types;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ngx_test_null(conf->types,
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME
|
2003-05-14 13:13:13 -04:00
|
|
|
* sizeof(ngx_array_t)),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
|
|
|
for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
|
2003-07-20 17:15:59 -04:00
|
|
|
ngx_init_array(conf->types[i], cf->pool,
|
|
|
|
5, sizeof(ngx_http_type_t), NGX_CONF_ERROR);
|
2003-05-14 13:13:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; default_types[i].exten.len; i++) {
|
|
|
|
ngx_http_types_hash_key(key, default_types[i].exten);
|
|
|
|
|
|
|
|
ngx_test_null(t, ngx_push_array(&conf->types[key]),
|
|
|
|
NGX_CONF_ERROR);
|
|
|
|
t->exten.len = default_types[i].exten.len;
|
|
|
|
t->exten.data = default_types[i].exten.data;
|
|
|
|
t->type.len = default_types[i].type.len;
|
|
|
|
t->type.data = default_types[i].type.data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-20 17:15:59 -04:00
|
|
|
if (conf->err_log == NULL) {
|
|
|
|
if (prev->err_log) {
|
|
|
|
conf->err_log = prev->err_log;
|
|
|
|
} else {
|
|
|
|
conf->err_log = cf->cycle->log;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_conf_merge_str_value(conf->default_type,
|
|
|
|
prev->default_type, "text/plain");
|
|
|
|
|
2003-10-27 18:01:00 -03:00
|
|
|
ngx_conf_merge_msec_value(conf->client_body_timeout,
|
|
|
|
prev->client_body_timeout, 10000);
|
2003-10-22 04:05:29 -03:00
|
|
|
ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 10000);
|
2003-10-29 05:30:44 -03:00
|
|
|
ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
|
2003-05-19 12:39:14 -04:00
|
|
|
ngx_conf_merge_size_value(conf->discarded_buffer_size,
|
|
|
|
prev->discarded_buffer_size, 1500);
|
2003-05-23 07:53:01 -04:00
|
|
|
ngx_conf_merge_msec_value(conf->keepalive_timeout,
|
|
|
|
prev->keepalive_timeout, 70000);
|
|
|
|
ngx_conf_merge_msec_value(conf->lingering_time,
|
|
|
|
prev->lingering_time, 30000);
|
|
|
|
ngx_conf_merge_msec_value(conf->lingering_timeout,
|
|
|
|
prev->lingering_timeout, 5000);
|
2003-05-14 13:13:13 -04:00
|
|
|
|
2003-10-24 03:53:41 -03:00
|
|
|
ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1);
|
|
|
|
|
2003-04-08 11:40:10 -04:00
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
2003-01-28 12:56:37 -03:00
|
|
|
{
|
2003-05-30 10:27:59 -04:00
|
|
|
ngx_http_core_srv_conf_t *scf = conf;
|
2003-05-19 12:39:14 -04:00
|
|
|
|
2003-05-15 11:42:53 -04:00
|
|
|
char *addr;
|
2003-05-20 11:37:55 -04:00
|
|
|
u_int p;
|
2003-05-27 08:18:54 -04:00
|
|
|
struct hostent *h;
|
2003-01-28 12:56:37 -03:00
|
|
|
ngx_str_t *args;
|
|
|
|
ngx_http_listen_t *ls;
|
|
|
|
|
2003-06-11 11:28:34 -04:00
|
|
|
/* TODO: check duplicate 'listen' directives,
|
2003-05-29 09:02:09 -04:00
|
|
|
add resolved name to server names ??? */
|
2003-05-15 11:42:53 -04:00
|
|
|
|
2003-01-28 12:56:37 -03:00
|
|
|
ngx_test_null(ls, ngx_push_array(&scf->listen), NGX_CONF_ERROR);
|
|
|
|
|
|
|
|
/* AF_INET only */
|
|
|
|
|
|
|
|
ls->family = AF_INET;
|
|
|
|
ls->flags = 0;
|
2003-01-29 04:25:51 -03:00
|
|
|
ls->file_name = cf->conf_file->file.name;
|
2003-01-28 12:56:37 -03:00
|
|
|
ls->line = cf->conf_file->line;
|
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
args = cf->args->elts;
|
2003-05-15 11:42:53 -04:00
|
|
|
addr = args[1].data;
|
|
|
|
|
|
|
|
for (p = 0; p < args[1].len; p++) {
|
|
|
|
if (addr[p] == ':') {
|
|
|
|
addr[p++] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p == args[1].len) {
|
2003-05-29 09:02:09 -04:00
|
|
|
/* no ":" in the "listen" */
|
2003-05-15 11:42:53 -04:00
|
|
|
p = 0;
|
|
|
|
}
|
2003-01-28 12:56:37 -03:00
|
|
|
|
2003-05-15 11:42:53 -04:00
|
|
|
ls->port = ngx_atoi(&addr[p], args[1].len - p);
|
2003-05-29 09:02:09 -04:00
|
|
|
if (ls->port == NGX_ERROR && p == 0) {
|
|
|
|
|
|
|
|
/* "listen host" */
|
|
|
|
ls->port = 80;
|
|
|
|
|
|
|
|
} else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
|
|
|
|
|| (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */
|
|
|
|
|
2003-07-18 10:44:05 -04:00
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"invalid port \"%s\" in \"%s\" directive, "
|
|
|
|
"it must be a number between 1 and 65535",
|
|
|
|
&addr[p], cmd->name.data);
|
|
|
|
|
|
|
|
return NGX_CONF_ERROR;
|
2003-05-29 09:02:09 -04:00
|
|
|
|
|
|
|
} else if (p == 0) {
|
|
|
|
ls->addr = INADDR_ANY;
|
|
|
|
return NGX_CONF_OK;
|
2003-01-28 12:56:37 -03:00
|
|
|
}
|
|
|
|
|
2003-05-29 09:02:09 -04:00
|
|
|
ls->addr = inet_addr(addr);
|
|
|
|
if (ls->addr == INADDR_NONE) {
|
|
|
|
h = gethostbyname(addr);
|
|
|
|
|
|
|
|
if (h == NULL || h->h_addr_list[0] == NULL) {
|
2003-07-18 10:44:05 -04:00
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"can not resolve host \"%s\" "
|
|
|
|
"in \"%s\" directive", addr, cmd->name.data);
|
|
|
|
return NGX_CONF_ERROR;
|
2003-05-29 09:02:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ls->addr = *(u_int32_t *)(h->h_addr_list[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
|
|
{
|
2003-05-30 10:27:59 -04:00
|
|
|
ngx_http_core_srv_conf_t *scf = conf;
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-05-30 10:27:59 -04:00
|
|
|
int i;
|
|
|
|
ngx_str_t *value;
|
2003-05-29 09:02:09 -04:00
|
|
|
ngx_http_server_name_t *sn;
|
|
|
|
|
|
|
|
/* TODO: several names */
|
|
|
|
/* TODO: warn about duplicate 'server_name' directives */
|
|
|
|
|
2003-05-30 10:27:59 -04:00
|
|
|
value = cf->args->elts;
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-05-30 10:27:59 -04:00
|
|
|
for (i = 1; i < cf->args->nelts; i++) {
|
|
|
|
if (value[i].len == 0) {
|
2003-07-18 10:44:05 -04:00
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"server name \"%s\" is invalid "
|
|
|
|
"in \"%s\" directive",
|
|
|
|
value[i].data, cmd->name.data);
|
|
|
|
return NGX_CONF_ERROR;
|
2003-05-30 10:27:59 -04:00
|
|
|
}
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-05-30 10:27:59 -04:00
|
|
|
ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR);
|
|
|
|
|
|
|
|
sn->name.len = value[i].len;
|
|
|
|
sn->name.data = value[i].data;
|
|
|
|
sn->core_srv_conf = scf;
|
|
|
|
}
|
2003-05-29 09:02:09 -04:00
|
|
|
|
2003-01-28 12:56:37 -03:00
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
2003-07-07 02:11:50 -04:00
|
|
|
|
|
|
|
|
|
|
|
static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
|
|
{
|
|
|
|
ngx_http_core_loc_conf_t *lcf = conf;
|
|
|
|
|
|
|
|
ngx_str_t *value;
|
|
|
|
|
|
|
|
value = cf->args->elts;
|
|
|
|
|
2003-07-10 12:26:57 -04:00
|
|
|
ngx_test_null(lcf->err_log,
|
|
|
|
ngx_log_create_errlog(cf->cycle, &value[1]),
|
2003-07-07 02:11:50 -04:00
|
|
|
NGX_CONF_ERROR);
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
2003-10-29 05:30:44 -03:00
|
|
|
|
|
|
|
|
|
|
|
static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data)
|
|
|
|
{
|
|
|
|
int *np = data;
|
|
|
|
|
|
|
|
#if (HAVE_LOWAT_EVENT)
|
|
|
|
|
|
|
|
if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
|
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"\"send_lowat\" must be less than %d "
|
|
|
|
"(sysctl net.inet.tcp.sendspace)",
|
|
|
|
ngx_freebsd_net_inet_tcp_sendspace);
|
|
|
|
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
|
|
|
"\"send_lowat\" is not supported, ignored");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|