mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
nginx-0.0.7-2004-07-14-20:01:42 import
This commit is contained in:
parent
846c27b2ac
commit
7823cc3b0d
35
auto/modules
35
auto/modules
@ -41,7 +41,33 @@ if [ $TEST_BUILD_RTSIG = YES ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# the filter order is important
|
||||||
|
# ngx_http_write_filter
|
||||||
|
# ngx_http_ssl_filter
|
||||||
|
# ngx_http_header_filter
|
||||||
|
# ngx_http_chunked_filter
|
||||||
|
# ngx_http_range_header_filter
|
||||||
|
# ngx_http_gzip_filter
|
||||||
|
# ngx_http_charset_filter
|
||||||
|
# ngx_http_ssi_filter
|
||||||
|
# ngx_http_headers_filter
|
||||||
|
# ngx_http_copy_filter
|
||||||
|
# ngx_http_range_body_filter
|
||||||
|
# ngx_http_not_modified_filter
|
||||||
|
|
||||||
|
HTTP_FILTER_MODULES="$HTTP_WRITE_FILTER_MODULE"
|
||||||
|
|
||||||
|
if [ $HTTP_SSL = YES ]; then
|
||||||
|
have=NGX_HTTP_SSL . auto/have
|
||||||
|
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSL_FILTER_MODULE"
|
||||||
|
HTTP_DEPS="$HTTP_DEPS $HTTP_SSL_DEPS"
|
||||||
|
HTTP_SRCS="$HTTP_SRCS $HTTP_SSL_SRCS"
|
||||||
|
# STUB: move to auto/libs/ssl
|
||||||
|
CORE_LIBS="$CORE_LIBS -lssl -lcrypto"
|
||||||
|
fi
|
||||||
|
|
||||||
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES \
|
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES \
|
||||||
|
$HTTP_HEADER_FILTER_MODULE \
|
||||||
$HTTP_CHUNKED_FILTER_MODULE \
|
$HTTP_CHUNKED_FILTER_MODULE \
|
||||||
$HTTP_RANGE_HEADER_FILTER_MODULE"
|
$HTTP_RANGE_HEADER_FILTER_MODULE"
|
||||||
|
|
||||||
@ -58,15 +84,6 @@ if [ $HTTP_CHARSET = YES ]; then
|
|||||||
HTTP_SRCS="$HTTP_SRCS $HTTP_CHARSET_SRCS"
|
HTTP_SRCS="$HTTP_SRCS $HTTP_CHARSET_SRCS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $HTTP_SSL = YES ]; then
|
|
||||||
have=NGX_HTTP_SSL . auto/have
|
|
||||||
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSL_FILTER_MODULE"
|
|
||||||
HTTP_DEPS="$HTTP_DEPS $HTTP_SSL_DEPS"
|
|
||||||
HTTP_SRCS="$HTTP_SRCS $HTTP_SSL_SRCS"
|
|
||||||
# STUB: move to auto/libs/ssl
|
|
||||||
CORE_LIBS="$CORE_LIBS -lssl -lcrypto"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $HTTP_SSI = YES ]; then
|
if [ $HTTP_SSI = YES ]; then
|
||||||
have=NGX_HTTP_SSI . auto/have
|
have=NGX_HTTP_SSI . auto/have
|
||||||
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSI_FILTER_MODULE"
|
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSI_FILTER_MODULE"
|
||||||
|
@ -190,8 +190,8 @@ HTTP_MODULES="ngx_http_module \
|
|||||||
|
|
||||||
HTTP_FILE_CACHE_MODULE=ngx_http_cache_module
|
HTTP_FILE_CACHE_MODULE=ngx_http_cache_module
|
||||||
|
|
||||||
HTTP_FILTER_MODULES="ngx_http_write_filter_module \
|
HTTP_WRITE_FILTER_MODULE="ngx_http_write_filter_module"
|
||||||
ngx_http_header_filter_module"
|
HTTP_HEADER_FILTER_MODULE="ngx_http_header_filter_module"
|
||||||
|
|
||||||
HTTP_CHUNKED_FILTER_MODULE=ngx_http_chunked_filter_module
|
HTTP_CHUNKED_FILTER_MODULE=ngx_http_chunked_filter_module
|
||||||
HTTP_HEADERS_FILTER_MODULE=ngx_http_headers_filter_module
|
HTTP_HEADERS_FILTER_MODULE=ngx_http_headers_filter_module
|
||||||
|
@ -23,6 +23,8 @@ int sigtimedwait(const sigset_t *set, siginfo_t *info,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ngx_linux_rtsig_max;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -45,6 +47,8 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle);
|
|||||||
|
|
||||||
static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle);
|
static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle);
|
||||||
static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf);
|
static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||||
|
static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
|
||||||
|
void *post, void *data);
|
||||||
|
|
||||||
|
|
||||||
static sigset_t set;
|
static sigset_t set;
|
||||||
@ -55,7 +59,7 @@ static struct pollfd *overflow_list;
|
|||||||
static ngx_str_t rtsig_name = ngx_string("rtsig");
|
static ngx_str_t rtsig_name = ngx_string("rtsig");
|
||||||
|
|
||||||
static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = {
|
static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = {
|
||||||
ngx_conf_check_num_bounds, 2, 10
|
ngx_check_ngx_overflow_threshold_bounds, 2, 10
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -644,6 +648,7 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
|
|||||||
rev = c->read;
|
rev = c->read;
|
||||||
|
|
||||||
if (rev->active
|
if (rev->active
|
||||||
|
&& !rev->closed
|
||||||
&& rev->event_handler
|
&& rev->event_handler
|
||||||
&& (overflow_list[i].revents
|
&& (overflow_list[i].revents
|
||||||
& (POLLIN|POLLERR|POLLHUP|POLLNVAL)))
|
& (POLLIN|POLLERR|POLLHUP|POLLNVAL)))
|
||||||
@ -663,6 +668,7 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
|
|||||||
wev = c->write;
|
wev = c->write;
|
||||||
|
|
||||||
if (wev->active
|
if (wev->active
|
||||||
|
&& !wev->closed
|
||||||
&& wev->event_handler
|
&& wev->event_handler
|
||||||
&& (overflow_list[i].revents
|
&& (overflow_list[i].revents
|
||||||
& (POLLOUT|POLLERR|POLLHUP|POLLNVAL)))
|
& (POLLOUT|POLLERR|POLLHUP|POLLNVAL)))
|
||||||
@ -686,39 +692,58 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
if (tested >= rtscf->overflow_test) {
|
if (tested >= rtscf->overflow_test) {
|
||||||
|
|
||||||
/*
|
if (ngx_linux_rtsig_max) {
|
||||||
* Check the current rt queue length to prevent the new overflow.
|
|
||||||
*
|
|
||||||
* Learn the /proc/sys/kernel/rtsig-max value because
|
|
||||||
* it can be changed sisnce the last checking.
|
|
||||||
*/
|
|
||||||
|
|
||||||
name[0] = CTL_KERN;
|
/*
|
||||||
name[1] = KERN_RTSIGMAX;
|
* Check the current rt queue length to prevent
|
||||||
len = sizeof(rtsig_max);
|
* the new overflow.
|
||||||
if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) {
|
*
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
|
* Learn the /proc/sys/kernel/rtsig-max value because
|
||||||
"sysctl(KERN_RTSIGMAX) failed");
|
* it can be changed sisnce the last checking.
|
||||||
return NGX_ERROR;
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_RTSIGNR;
|
name[1] = KERN_RTSIGMAX;
|
||||||
len = sizeof(rtsig_nr);
|
len = sizeof(rtsig_max);
|
||||||
if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1) {
|
if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1)
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
|
{
|
||||||
"sysctl(KERN_RTSIGNR) failed");
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
|
||||||
return NGX_ERROR;
|
"sysctl(KERN_RTSIGMAX) failed");
|
||||||
}
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
name[0] = CTL_KERN;
|
||||||
* drain rt signal queue if the /proc/sys/kernel/rtsig-nr is bigger
|
name[1] = KERN_RTSIGNR;
|
||||||
* than "/proc/sys/kernel/rtsig-max / rtsig_overflow_threshold"
|
len = sizeof(rtsig_nr);
|
||||||
*/
|
if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1)
|
||||||
|
{
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
|
||||||
|
"sysctl(KERN_RTSIGNR) failed");
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* drain rt signal queue if the /proc/sys/kernel/rtsig-nr
|
||||||
|
* is bigger than
|
||||||
|
* /proc/sys/kernel/rtsig-max / rtsig_overflow_threshold
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) {
|
||||||
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
|
"rtsig queue state: %d/%d",
|
||||||
|
rtsig_nr, rtsig_max);
|
||||||
|
while (ngx_rtsig_process_events(cycle) == NGX_OK) {
|
||||||
|
/* void */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Linux has not KERN_RTSIGMAX since 2.6.6-mm2
|
||||||
|
* so drain rt signal queue unconditionally
|
||||||
|
*/
|
||||||
|
|
||||||
if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) {
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
|
||||||
"rtsig queue state: %d/%d", rtsig_nr, rtsig_max);
|
|
||||||
while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ }
|
while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,3 +799,18 @@ static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
|
||||||
|
void *post, void *data)
|
||||||
|
{
|
||||||
|
if (ngx_linux_rtsig_max) {
|
||||||
|
return ngx_conf_check_num_bounds(cf, post, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||||
|
"\"rtsig_overflow_threshold\" is not supported "
|
||||||
|
"since Linux 2.6.6-mm2, ignored");
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
@ -22,12 +22,12 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
|
|
||||||
unsigned accepted;
|
|
||||||
} ngx_http_ssl_ctx_t;
|
} ngx_http_ssl_ctx_t;
|
||||||
|
|
||||||
|
|
||||||
static ngx_http_ssl_ctx_t *ngx_http_ssl_create_ctx(ngx_http_request_t *r);
|
static ngx_http_ssl_ctx_t *ngx_http_ssl_create_ctx(ngx_http_request_t *r);
|
||||||
|
static ngx_chain_t *ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in,
|
||||||
|
off_t limit);
|
||||||
static void ngx_http_ssl_error(ngx_uint_t level, ngx_log_t *log, int err,
|
static void ngx_http_ssl_error(ngx_uint_t level, ngx_log_t *log, int err,
|
||||||
char *fmt, ...);
|
char *fmt, ...);
|
||||||
static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf);
|
static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf);
|
||||||
@ -152,7 +152,7 @@ ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngx_http_ssl_error(NGX_LOG_ALERT, r->connection->log, rc,
|
ngx_http_ssl_error(NGX_LOG_ALERT, r->connection->log, rc,
|
||||||
"SSL_accept() failed");
|
"SSL_read() failed");
|
||||||
|
|
||||||
SSL_set_shutdown(ctx->ssl, SSL_RECEIVED_SHUTDOWN);
|
SSL_set_shutdown(ctx->ssl, SSL_RECEIVED_SHUTDOWN);
|
||||||
|
|
||||||
@ -160,11 +160,8 @@ ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in,
|
ngx_int_t ngx_http_ssl_writer(ngx_http_request_t *r, ngx_chain_t *in)
|
||||||
off_t limit)
|
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
size_t send, size;
|
|
||||||
ngx_http_ssl_ctx_t *ctx;
|
ngx_http_ssl_ctx_t *ctx;
|
||||||
|
|
||||||
ctx = ngx_http_get_module_ctx(r, ngx_http_ssl_filter_module);
|
ctx = ngx_http_get_module_ctx(r, ngx_http_ssl_filter_module);
|
||||||
@ -175,7 +172,12 @@ ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in,
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"SSL_shutdown: %d", rc);
|
"SSL_shutdown: %d", rc);
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
return NGX_AGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
if (rc == 1) {
|
if (rc == 1) {
|
||||||
|
SSL_free(ctx->ssl);
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,9 +190,28 @@ ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in,
|
|||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngx_http_ssl_error(NGX_LOG_ALERT, r->connection->log, rc,
|
||||||
|
"SSL_shutdown() failed");
|
||||||
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ch = ngx_http_ssl_write(r, ctx, in, 0);
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_chain_t *ngx_http_ssl_write(ngx_http_request_t *r,
|
||||||
|
ngx_http_ssl_ctx_t *ctx,
|
||||||
|
ngx_chain_t *in,
|
||||||
|
off_t limit)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
size_t send, size;
|
||||||
|
|
||||||
|
ctx = ngx_http_get_module_ctx(r, ngx_http_ssl_filter_module);
|
||||||
|
|
||||||
send = 0;
|
send = 0;
|
||||||
|
|
||||||
for (/* void */; in; in = in->next) {
|
for (/* void */; in; in = in->next) {
|
||||||
@ -205,9 +226,20 @@ ngx_int_t ngx_http_ssl_write(ngx_http_request_t *r, ngx_chain_t *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = SSL_write(ctx->ssl, in->buf->pos, size);
|
rc = SSL_write(ctx->ssl, in->buf->pos, size);
|
||||||
|
|
||||||
|
if (rc > 0) {
|
||||||
|
in->buf->pos += rc;
|
||||||
|
|
||||||
|
if (rc == size) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
r->connection->write->ready = 0;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n);
|
ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t n);
|
||||||
|
ngx_int_t ngx_http_ssl_writer(ngx_http_request_t *r, ngx_chain_t *in);
|
||||||
|
|
||||||
void ngx_http_ssl_close_connection(SSL *ssl, ngx_log_t *log);
|
void ngx_http_ssl_close_connection(SSL *ssl, ngx_log_t *log);
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,6 +206,20 @@ static ngx_command_t ngx_http_core_commands[] = {
|
|||||||
offsetof(ngx_http_core_loc_conf_t, send_lowat),
|
offsetof(ngx_http_core_loc_conf_t, send_lowat),
|
||||||
&ngx_http_lowat_post },
|
&ngx_http_lowat_post },
|
||||||
|
|
||||||
|
{ ngx_string("postpone_output"),
|
||||||
|
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, postpone_output),
|
||||||
|
NULL },
|
||||||
|
|
||||||
|
{ ngx_string("limit_rate"),
|
||||||
|
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, limit_rate),
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ ngx_string("keepalive_timeout"),
|
{ ngx_string("keepalive_timeout"),
|
||||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||||
ngx_conf_set_msec_slot,
|
ngx_conf_set_msec_slot,
|
||||||
@ -1251,6 +1265,8 @@ static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf)
|
|||||||
lcf->tcp_nopush = NGX_CONF_UNSET;
|
lcf->tcp_nopush = NGX_CONF_UNSET;
|
||||||
lcf->send_timeout = NGX_CONF_UNSET_MSEC;
|
lcf->send_timeout = NGX_CONF_UNSET_MSEC;
|
||||||
lcf->send_lowat = NGX_CONF_UNSET_SIZE;
|
lcf->send_lowat = NGX_CONF_UNSET_SIZE;
|
||||||
|
lcf->postpone_output = NGX_CONF_UNSET_SIZE;
|
||||||
|
lcf->limit_rate = NGX_CONF_UNSET_SIZE;
|
||||||
lcf->discarded_buffer_size = NGX_CONF_UNSET_SIZE;
|
lcf->discarded_buffer_size = NGX_CONF_UNSET_SIZE;
|
||||||
lcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
|
lcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
|
||||||
lcf->lingering_time = NGX_CONF_UNSET_MSEC;
|
lcf->lingering_time = NGX_CONF_UNSET_MSEC;
|
||||||
@ -1334,6 +1350,9 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
|
|||||||
ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
|
ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
|
||||||
ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 60000);
|
ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 60000);
|
||||||
ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
|
ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
|
||||||
|
ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,
|
||||||
|
1460);
|
||||||
|
ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);
|
||||||
ngx_conf_merge_size_value(conf->discarded_buffer_size,
|
ngx_conf_merge_size_value(conf->discarded_buffer_size,
|
||||||
prev->discarded_buffer_size, 1500);
|
prev->discarded_buffer_size, 1500);
|
||||||
ngx_conf_merge_msec_value(conf->keepalive_timeout,
|
ngx_conf_merge_msec_value(conf->keepalive_timeout,
|
||||||
|
@ -134,6 +134,8 @@ typedef struct {
|
|||||||
size_t discarded_buffer_size; /* discarded_buffer_size */
|
size_t discarded_buffer_size; /* discarded_buffer_size */
|
||||||
size_t client_body_buffer_size; /* client_body_buffer_size */
|
size_t client_body_buffer_size; /* client_body_buffer_size */
|
||||||
size_t send_lowat; /* send_lowat */
|
size_t send_lowat; /* send_lowat */
|
||||||
|
size_t postpone_output; /* postpone_output */
|
||||||
|
size_t limit_rate; /* limit_rate */
|
||||||
|
|
||||||
ngx_msec_t client_body_timeout; /* client_body_timeout */
|
ngx_msec_t client_body_timeout; /* client_body_timeout */
|
||||||
ngx_msec_t send_timeout; /* send_timeout */
|
ngx_msec_t send_timeout; /* send_timeout */
|
||||||
|
@ -33,6 +33,9 @@ ngx_module_t ngx_http_header_filter_module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_http_output_body_filter_pt write_filter;
|
||||||
|
|
||||||
|
|
||||||
static char server_string[] = "Server: " NGINX_VER CRLF;
|
static char server_string[] = "Server: " NGINX_VER CRLF;
|
||||||
|
|
||||||
|
|
||||||
@ -355,7 +358,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
ln->buf = b;
|
ln->buf = b;
|
||||||
ln->next = NULL;
|
ln->next = NULL;
|
||||||
|
|
||||||
return ngx_http_write_filter(r, ln);
|
return write_filter(r, ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -363,5 +366,7 @@ static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_http_top_header_filter = ngx_http_header_filter;
|
ngx_http_top_header_filter = ngx_http_header_filter;
|
||||||
|
|
||||||
|
write_filter = ngx_http_top_body_filter;
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
@ -5,43 +5,14 @@
|
|||||||
#include <ngx_http.h>
|
#include <ngx_http.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t postpone_output; /* postpone_output */
|
|
||||||
size_t limit_rate; /* limit_rate */
|
|
||||||
} ngx_http_write_filter_conf_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_chain_t *out;
|
ngx_chain_t *out;
|
||||||
} ngx_http_write_filter_ctx_t;
|
} ngx_http_write_filter_ctx_t;
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf);
|
|
||||||
static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf,
|
|
||||||
void *parent, void *child);
|
|
||||||
static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle);
|
static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle);
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_write_filter_commands[] = {
|
|
||||||
|
|
||||||
{ ngx_string("postpone_output"),
|
|
||||||
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_write_filter_conf_t, postpone_output),
|
|
||||||
NULL },
|
|
||||||
|
|
||||||
{ ngx_string("limit_rate"),
|
|
||||||
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_write_filter_conf_t, limit_rate),
|
|
||||||
NULL },
|
|
||||||
|
|
||||||
ngx_null_command
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ngx_http_module_t ngx_http_write_filter_module_ctx = {
|
ngx_http_module_t ngx_http_write_filter_module_ctx = {
|
||||||
NULL, /* pre conf */
|
NULL, /* pre conf */
|
||||||
|
|
||||||
@ -51,15 +22,15 @@ ngx_http_module_t ngx_http_write_filter_module_ctx = {
|
|||||||
NULL, /* create server configuration */
|
NULL, /* create server configuration */
|
||||||
NULL, /* merge server configuration */
|
NULL, /* merge server configuration */
|
||||||
|
|
||||||
ngx_http_write_filter_create_conf, /* create location configuration */
|
NULL, /* create location configuration */
|
||||||
ngx_http_write_filter_merge_conf /* merge location configuration */
|
NULL, /* merge location configuration */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ngx_module_t ngx_http_write_filter_module = {
|
ngx_module_t ngx_http_write_filter_module = {
|
||||||
NGX_MODULE,
|
NGX_MODULE,
|
||||||
&ngx_http_write_filter_module_ctx, /* module context */
|
&ngx_http_write_filter_module_ctx, /* module context */
|
||||||
ngx_http_write_filter_commands, /* module directives */
|
NULL, /* module directives */
|
||||||
NGX_HTTP_MODULE, /* module type */
|
NGX_HTTP_MODULE, /* module type */
|
||||||
ngx_http_write_filter_init, /* init module */
|
ngx_http_write_filter_init, /* init module */
|
||||||
NULL /* init process */
|
NULL /* init process */
|
||||||
@ -68,11 +39,11 @@ ngx_module_t ngx_http_write_filter_module = {
|
|||||||
|
|
||||||
ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||||
{
|
{
|
||||||
int last;
|
int last;
|
||||||
off_t size, flush, sent;
|
off_t size, flush, sent;
|
||||||
ngx_chain_t *cl, *ln, **ll, *chain;
|
ngx_chain_t *cl, *ln, **ll, *chain;
|
||||||
ngx_http_write_filter_ctx_t *ctx;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
ngx_http_write_filter_conf_t *conf;
|
ngx_http_write_filter_ctx_t *ctx;
|
||||||
|
|
||||||
ctx = ngx_http_get_module_ctx(r->main ? r->main : r,
|
ctx = ngx_http_get_module_ctx(r->main ? r->main : r,
|
||||||
ngx_http_write_filter_module);
|
ngx_http_write_filter_module);
|
||||||
@ -125,8 +96,8 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
"http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT,
|
"http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT,
|
||||||
last, flush, size);
|
last, flush, size);
|
||||||
|
|
||||||
conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
|
clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
|
||||||
ngx_http_write_filter_module);
|
ngx_http_core_module);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* avoid the output if there is no last buf, no flush point,
|
* avoid the output if there is no last buf, no flush point,
|
||||||
@ -134,7 +105,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
* is smaller than "postpone_output" directive
|
* is smaller than "postpone_output" directive
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!last && flush == 0 && in && size < (off_t) conf->postpone_output) {
|
if (!last && flush == 0 && in && size < (off_t) clcf->postpone_output) {
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,17 +124,17 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
sent = r->connection->sent;
|
sent = r->connection->sent;
|
||||||
|
|
||||||
chain = ngx_write_chain(r->connection, ctx->out,
|
chain = ngx_write_chain(r->connection, ctx->out,
|
||||||
conf->limit_rate ? conf->limit_rate:
|
clcf->limit_rate ? clcf->limit_rate:
|
||||||
OFF_T_MAX_VALUE);
|
OFF_T_MAX_VALUE);
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http write filter %X", chain);
|
"http write filter %X", chain);
|
||||||
|
|
||||||
if (conf->limit_rate) {
|
if (clcf->limit_rate) {
|
||||||
sent = r->connection->sent - sent;
|
sent = r->connection->sent - sent;
|
||||||
r->connection->write->delayed = 1;
|
r->connection->write->delayed = 1;
|
||||||
ngx_add_timer(r->connection->write,
|
ngx_add_timer(r->connection->write,
|
||||||
(ngx_msec_t) sent * 1000 / conf->limit_rate);
|
(ngx_msec_t) (sent * 1000 / clcf->limit_rate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chain == NGX_CHAIN_ERROR) {
|
if (chain == NGX_CHAIN_ERROR) {
|
||||||
@ -180,36 +151,6 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf)
|
|
||||||
{
|
|
||||||
ngx_http_write_filter_conf_t *conf;
|
|
||||||
|
|
||||||
ngx_test_null(conf,
|
|
||||||
ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
conf->postpone_output = NGX_CONF_UNSET_SIZE;
|
|
||||||
conf->limit_rate = NGX_CONF_UNSET_SIZE;
|
|
||||||
|
|
||||||
return conf;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf,
|
|
||||||
void *parent, void *child)
|
|
||||||
{
|
|
||||||
ngx_http_write_filter_conf_t *prev = parent;
|
|
||||||
ngx_http_write_filter_conf_t *conf = child;
|
|
||||||
|
|
||||||
ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,
|
|
||||||
1460);
|
|
||||||
|
|
||||||
ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle)
|
static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_top_body_filter = ngx_http_write_filter;
|
ngx_http_top_body_filter = ngx_http_write_filter;
|
||||||
|
@ -205,7 +205,7 @@ ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd,
|
|||||||
|
|
||||||
ev->event_handler = handler;
|
ev->event_handler = handler;
|
||||||
|
|
||||||
if (ngx_add_conn) {
|
if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
|
||||||
if (ngx_add_conn(c) == NGX_ERROR) {
|
if (ngx_add_conn(c) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -218,3 +218,15 @@ ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd,
|
|||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log)
|
||||||
|
{
|
||||||
|
if (close(fd[0]) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close(fd[1]) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size,
|
|||||||
ngx_log_t *log);
|
ngx_log_t *log);
|
||||||
ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd,
|
ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd,
|
||||||
ngx_int_t event, ngx_event_handler_pt handler);
|
ngx_int_t event, ngx_event_handler_pt handler);
|
||||||
|
void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_CHANNEL_H_INCLUDED_ */
|
#endif /* _NGX_CHANNEL_H_INCLUDED_ */
|
||||||
|
@ -84,7 +84,7 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
size = sizeof(ngx_freebsd_kern_ostype);
|
size = sizeof(ngx_freebsd_kern_ostype);
|
||||||
if (sysctlbyname("kern.ostype",
|
if (sysctlbyname("kern.ostype",
|
||||||
ngx_freebsd_kern_ostype, &size, NULL, 0) == -1) {
|
ngx_freebsd_kern_ostype, &size, NULL, 0) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno,
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
"sysctlbyname(kern.ostype) failed");
|
"sysctlbyname(kern.ostype) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
size = sizeof(ngx_freebsd_kern_osrelease);
|
size = sizeof(ngx_freebsd_kern_osrelease);
|
||||||
if (sysctlbyname("kern.osrelease",
|
if (sysctlbyname("kern.osrelease",
|
||||||
ngx_freebsd_kern_osrelease, &size, NULL, 0) == -1) {
|
ngx_freebsd_kern_osrelease, &size, NULL, 0) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno,
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
"sysctlbyname(kern.osrelease) failed");
|
"sysctlbyname(kern.osrelease) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
if (sysctlbyname("kern.osreldate",
|
if (sysctlbyname("kern.osreldate",
|
||||||
&ngx_freebsd_kern_osreldate, &size, NULL, 0) == -1) {
|
&ngx_freebsd_kern_osreldate, &size, NULL, 0) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno,
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
"sysctlbyname(kern.osreldate) failed");
|
"sysctlbyname(kern.osreldate) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
size = sysctls[i].size;
|
size = sysctls[i].size;
|
||||||
if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0)
|
if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0)
|
||||||
== -1) {
|
== -1) {
|
||||||
err = errno;
|
err = ngx_errno;
|
||||||
if (err != NGX_ENOENT) {
|
if (err != NGX_ENOENT) {
|
||||||
if (sysctls[i].value == &ngx_freebsd_machdep_hlt_logical_cpus) {
|
if (sysctls[i].value == &ngx_freebsd_machdep_hlt_logical_cpus) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -5,5 +5,7 @@
|
|||||||
ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
|
ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
|
||||||
off_t limit);
|
off_t limit);
|
||||||
|
|
||||||
|
extern int ngx_linux_rtsig_max;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_LINUX_H_INCLUDED_ */
|
#endif /* _NGX_LINUX_H_INCLUDED_ */
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
char ngx_linux_kern_ostype[50];
|
char ngx_linux_kern_ostype[50];
|
||||||
char ngx_linux_kern_osrelease[20];
|
char ngx_linux_kern_osrelease[20];
|
||||||
|
|
||||||
|
int ngx_linux_rtsig_max;
|
||||||
|
|
||||||
|
|
||||||
ngx_os_io_t ngx_os_io = {
|
ngx_os_io_t ngx_os_io = {
|
||||||
ngx_unix_recv,
|
ngx_unix_recv,
|
||||||
@ -23,14 +25,15 @@ ngx_os_io_t ngx_os_io = {
|
|||||||
|
|
||||||
int ngx_os_init(ngx_log_t *log)
|
int ngx_os_init(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
int name[2], len;
|
int name[2], len, rtsig_max;
|
||||||
|
|
||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_OSTYPE;
|
name[1] = KERN_OSTYPE;
|
||||||
len = sizeof(ngx_linux_kern_ostype);
|
len = sizeof(ngx_linux_kern_ostype);
|
||||||
if (sysctl(name, sizeof(name), ngx_linux_kern_ostype, &len, NULL, 0)
|
if (sysctl(name, sizeof(name), ngx_linux_kern_ostype, &len, NULL, 0)
|
||||||
== -1) {
|
== -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno, "sysctl(KERN_OSTYPE) failed");
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
|
"sysctl(KERN_OSTYPE) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +42,7 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
len = sizeof(ngx_linux_kern_osrelease);
|
len = sizeof(ngx_linux_kern_osrelease);
|
||||||
if (sysctl(name, sizeof(name), ngx_linux_kern_osrelease, &len, NULL, 0)
|
if (sysctl(name, sizeof(name), ngx_linux_kern_osrelease, &len, NULL, 0)
|
||||||
== -1) {
|
== -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno,
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
"sysctl(KERN_OSRELEASE) failed");
|
"sysctl(KERN_OSRELEASE) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -48,5 +51,16 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
ngx_linux_kern_ostype, ngx_linux_kern_osrelease);
|
ngx_linux_kern_ostype, ngx_linux_kern_osrelease);
|
||||||
|
|
||||||
|
|
||||||
|
name[0] = CTL_KERN;
|
||||||
|
name[1] = KERN_RTSIGMAX;
|
||||||
|
len = sizeof(rtsig_max);
|
||||||
|
if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_INFO, log, ngx_errno,
|
||||||
|
"sysctl(KERN_RTSIGMAX) failed");
|
||||||
|
} else {
|
||||||
|
ngx_linux_rtsig_max = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ngx_posix_init(log);
|
return ngx_posix_init(log);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <ngx_config.h>
|
#include <ngx_config.h>
|
||||||
#include <ngx_core.h>
|
#include <ngx_core.h>
|
||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
|
#include <ngx_channel.h>
|
||||||
|
|
||||||
|
|
||||||
static void ngx_execute_proc(ngx_cycle_t *cycle, void *data);
|
static void ngx_execute_proc(ngx_cycle_t *cycle, void *data);
|
||||||
@ -50,6 +51,11 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
||||||
|
"channel %d:%d",
|
||||||
|
ngx_processes[s].channel[0],
|
||||||
|
ngx_processes[s].channel[1]);
|
||||||
|
|
||||||
if (ngx_nonblocking(ngx_processes[s].channel[0]) == -1) {
|
if (ngx_nonblocking(ngx_processes[s].channel[0]) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
ngx_nonblocking_n " failed while spawning \"%s\"",
|
ngx_nonblocking_n " failed while spawning \"%s\"",
|
||||||
@ -270,15 +276,3 @@ void ngx_process_get_status()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log)
|
|
||||||
{
|
|
||||||
if (close(fd[0]) == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (close(fd[1]) == -1) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -47,7 +47,6 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
|
|||||||
char *name, ngx_int_t respawn);
|
char *name, ngx_int_t respawn);
|
||||||
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
|
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
|
||||||
void ngx_process_get_status(void);
|
void ngx_process_get_status(void);
|
||||||
void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log);
|
|
||||||
|
|
||||||
#define ngx_sched_yield() sched_yield()
|
#define ngx_sched_yield() sched_yield()
|
||||||
|
|
||||||
|
@ -614,6 +614,10 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (n == ngx_process_slot) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (close(ngx_processes[n].channel[1]) == -1) {
|
if (close(ngx_processes[n].channel[1]) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
"close() failed");
|
"close() failed");
|
||||||
|
@ -146,6 +146,10 @@ ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m)
|
|||||||
|
|
||||||
err = pthread_mutex_trylock(&m->mutex);
|
err = pthread_mutex_trylock(&m->mutex);
|
||||||
|
|
||||||
|
if (err == NGX_EBUSY) {
|
||||||
|
return NGX_AGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, m->log, err,
|
ngx_log_error(NGX_LOG_ALERT, m->log, err,
|
||||||
"pthread_mutex_trylock(" PTR_FMT ") failed", m);
|
"pthread_mutex_trylock(" PTR_FMT ") failed", m);
|
||||||
|
@ -27,21 +27,24 @@ int ngx_os_init(ngx_log_t *log)
|
|||||||
if (sysinfo(SI_SYSNAME, ngx_solaris_sysname, sizeof(ngx_solaris_sysname))
|
if (sysinfo(SI_SYSNAME, ngx_solaris_sysname, sizeof(ngx_solaris_sysname))
|
||||||
== -1)
|
== -1)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_SYSNAME) failed");
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
|
"sysinfo(SI_SYSNAME) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sysinfo(SI_RELEASE, ngx_solaris_release, sizeof(ngx_solaris_release))
|
if (sysinfo(SI_RELEASE, ngx_solaris_release, sizeof(ngx_solaris_release))
|
||||||
== -1)
|
== -1)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_RELEASE) failed");
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
|
"sysinfo(SI_RELEASE) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sysinfo(SI_VERSION, ngx_solaris_version, sizeof(ngx_solaris_version))
|
if (sysinfo(SI_VERSION, ngx_solaris_version, sizeof(ngx_solaris_version))
|
||||||
== -1)
|
== -1)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_SYSNAME) failed");
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||||
|
"sysinfo(SI_SYSNAME) failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user