mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
nginx-0.0.2-2004-02-11-20:08:49 import
This commit is contained in:
parent
c7a2f68606
commit
54498db7a2
@ -21,6 +21,7 @@ ngx_func_test="int efd = 0, fd = 1, n;
|
|||||||
|
|
||||||
if [ $ngx_found = yes ]; then
|
if [ $ngx_found = yes ]; then
|
||||||
have=HAVE_EPOLL . auto/have
|
have=HAVE_EPOLL . auto/have
|
||||||
|
have=HAVE_CLEAR_EVENT . auto/have
|
||||||
CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
|
CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
|
||||||
EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
|
EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
|
||||||
EVENT_FOUND=YES
|
EVENT_FOUND=YES
|
||||||
|
@ -56,7 +56,6 @@ EVENT_DEPS="src/event/ngx_event.h \
|
|||||||
|
|
||||||
EVENT_SRCS="src/event/ngx_event.c \
|
EVENT_SRCS="src/event/ngx_event.c \
|
||||||
src/event/ngx_event_timer.c \
|
src/event/ngx_event_timer.c \
|
||||||
src/event/ngx_event_close.c \
|
|
||||||
src/event/ngx_event_accept.c \
|
src/event/ngx_event_accept.c \
|
||||||
src/event/ngx_event_connect.c \
|
src/event/ngx_event_connect.c \
|
||||||
src/event/ngx_event_pipe.c"
|
src/event/ngx_event_pipe.c"
|
||||||
|
@ -12,9 +12,7 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
|
|||||||
"malloc() %d bytes failed", size);
|
"malloc() %d bytes failed", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_ALLOC)
|
ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %08x:%d", p, size);
|
||||||
ngx_log_debug(log, "malloc: %08x:%d" _ p _ size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -57,27 +55,30 @@ void ngx_destroy_pool(ngx_pool_t *pool)
|
|||||||
ngx_pool_large_t *l;
|
ngx_pool_large_t *l;
|
||||||
|
|
||||||
for (l = pool->large; l; l = l->next) {
|
for (l = pool->large; l; l = l->next) {
|
||||||
#if (NGX_DEBUG_ALLOC)
|
|
||||||
ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
|
||||||
#endif
|
"free: %08x", l->alloc);
|
||||||
|
|
||||||
if (l->alloc) {
|
if (l->alloc) {
|
||||||
free(l->alloc);
|
free(l->alloc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (NGX_DEBUG)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we could allocate pool->log from this pool
|
* we could allocate the pool->log from this pool
|
||||||
* so we can not use this log while free()ing the pool
|
* so we can not use this log while the free()ing the pool
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (NGX_DEBUG_ALLOC)
|
|
||||||
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
|
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
|
||||||
ngx_log_debug(pool->log, "free: %08x" _ p);
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, "free: %08x", p);
|
||||||
|
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
|
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
|
||||||
@ -177,9 +178,8 @@ void ngx_pfree(ngx_pool_t *pool, void *p)
|
|||||||
|
|
||||||
for (l = pool->large; l; l = l->next) {
|
for (l = pool->large; l; l = l->next) {
|
||||||
if (p == l->alloc) {
|
if (p == l->alloc) {
|
||||||
#if (NGX_DEBUG_ALLOC)
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
|
||||||
ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
|
"free: %08x", l->alloc);
|
||||||
#endif
|
|
||||||
free(l->alloc);
|
free(l->alloc);
|
||||||
l->alloc = NULL;
|
l->alloc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -540,7 +540,7 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err,
|
void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
|
||||||
char *fmt, ...)
|
char *fmt, ...)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -238,7 +238,7 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
|
|||||||
|
|
||||||
|
|
||||||
ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
|
ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
|
||||||
void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err,
|
void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
|
||||||
char *fmt, ...);
|
char *fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ void ngx_close_listening_sockets(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|
ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|
||||||
{
|
{
|
||||||
ngx_int_t level;
|
ngx_uint_t level;
|
||||||
|
|
||||||
if (err == NGX_ECONNRESET
|
if (err == NGX_ECONNRESET
|
||||||
&& c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
&& c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
||||||
@ -252,6 +252,7 @@ ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|
|||||||
|
|
||||||
switch (c->log_error) {
|
switch (c->log_error) {
|
||||||
|
|
||||||
|
case NGX_ERROR_IGNORE_ECONNRESET:
|
||||||
case NGX_ERROR_INFO:
|
case NGX_ERROR_INFO:
|
||||||
level = NGX_LOG_INFO;
|
level = NGX_LOG_INFO;
|
||||||
break;
|
break;
|
||||||
|
@ -464,7 +464,7 @@ static void ngx_clean_old_cycles(ngx_event_t *ev)
|
|||||||
log = ngx_cycle->log;
|
log = ngx_cycle->log;
|
||||||
ngx_temp_pool->log = log;
|
ngx_temp_pool->log = log;
|
||||||
|
|
||||||
ngx_log_debug(log, "clean old cycles");
|
ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycles");
|
||||||
|
|
||||||
live = 0;
|
live = 0;
|
||||||
|
|
||||||
@ -480,7 +480,9 @@ static void ngx_clean_old_cycles(ngx_event_t *ev)
|
|||||||
for (n = 0; n < cycle[i]->connection_n; n++) {
|
for (n = 0; n < cycle[i]->connection_n; n++) {
|
||||||
if (cycle[i]->connections[n].fd != -1) {
|
if (cycle[i]->connections[n].fd != -1) {
|
||||||
found = 1;
|
found = 1;
|
||||||
ngx_log_debug(log, "live fd: %d" _ n);
|
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%d", n);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,15 +492,15 @@ static void ngx_clean_old_cycles(ngx_event_t *ev)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(log, "clean old cycle: %d" _ i);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycle: %d", i);
|
||||||
|
|
||||||
ngx_destroy_pool(cycle[i]->pool);
|
ngx_destroy_pool(cycle[i]->pool);
|
||||||
cycle[i] = NULL;
|
cycle[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(log, "old cycles status: %d" _ live);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "old cycles status: %d", live);
|
||||||
|
|
||||||
if (live) {
|
if (live) {
|
||||||
ngx_log_debug(log, "TIMER");
|
|
||||||
ngx_add_timer(ev, 30000);
|
ngx_add_timer(ev, 30000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,8 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
|
|||||||
#endif
|
#endif
|
||||||
file->fd = ngx_open_tempfile(file->name.data, 1);
|
file->fd = ngx_open_tempfile(file->name.data, 1);
|
||||||
|
|
||||||
ngx_log_debug(file->log, "temp fd: %d" _ file->fd);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
|
||||||
|
"temp fd:%d", file->fd);
|
||||||
|
|
||||||
if (file->fd != NGX_INVALID_FILE) {
|
if (file->fd != NGX_INVALID_FILE) {
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
@ -123,15 +124,14 @@ void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(file->log, "hashed path: %s" _ file->name.data);
|
|
||||||
|
|
||||||
name -= level;
|
name -= level;
|
||||||
file->name.data[pos - 1] = '/';
|
file->name.data[pos - 1] = '/';
|
||||||
ngx_memcpy(&file->name.data[pos], &file->name.data[name], level);
|
ngx_memcpy(&file->name.data[pos], &file->name.data[name], level);
|
||||||
pos += level + 1;
|
pos += level + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(file->log, "hashed path: %s" _ file->name.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
|
||||||
|
"hashed path: %s", file->name.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,7 +151,8 @@ int ngx_create_path(ngx_file_t *file, ngx_path_t *path)
|
|||||||
|
|
||||||
file->name.data[pos] = '\0';
|
file->name.data[pos] = '\0';
|
||||||
|
|
||||||
ngx_log_debug(file->log, "temp: %s" _ file->name.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
|
||||||
|
"temp file: \"%s\"", file->name.data);
|
||||||
|
|
||||||
if (ngx_create_dir(file->name.data) == NGX_FILE_ERROR) {
|
if (ngx_create_dir(file->name.data) == NGX_FILE_ERROR) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
@ -79,7 +79,8 @@ static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
|
|||||||
|
|
||||||
buf.len = 0;
|
buf.len = 0;
|
||||||
|
|
||||||
ngx_log_debug(ctx->log, "dir '%s':%d" _ dname->data _ dname->len);
|
ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0,
|
||||||
|
"gc dir \"%s\":%d", dname->data, dname->len);
|
||||||
|
|
||||||
if (ngx_open_dir(dname, &dir) == NGX_ERROR) {
|
if (ngx_open_dir(dname, &dir) == NGX_ERROR) {
|
||||||
ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
|
ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
|
||||||
@ -106,7 +107,8 @@ ngx_log_debug(ctx->log, "dir '%s':%d" _ dname->data _ dname->len);
|
|||||||
|
|
||||||
len = ngx_de_namelen(&dir);
|
len = ngx_de_namelen(&dir);
|
||||||
|
|
||||||
ngx_log_debug(ctx->log, "name '%s':%d" _ ngx_de_name(&dir) _ len);
|
ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0,
|
||||||
|
"gc name \"%s\":%d", ngx_de_name(&dir), len);
|
||||||
|
|
||||||
if (len == 1 && ngx_de_name(&dir)[0] == '.') {
|
if (len == 1 && ngx_de_name(&dir)[0] == '.') {
|
||||||
continue;
|
continue;
|
||||||
@ -139,7 +141,8 @@ ngx_log_debug(ctx->log, "name '%s':%d" _ ngx_de_name(&dir) _ len);
|
|||||||
ngx_memcpy(last, ngx_de_name(&dir), len + 1);
|
ngx_memcpy(last, ngx_de_name(&dir), len + 1);
|
||||||
fname.data = buf.data;
|
fname.data = buf.data;
|
||||||
|
|
||||||
ngx_log_debug(ctx->log, "path %s" _ fname.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
|
||||||
|
"gc path: \"%s\"", fname.data);
|
||||||
|
|
||||||
if (!dir.info_valid) {
|
if (!dir.info_valid) {
|
||||||
if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) {
|
if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) {
|
||||||
@ -151,7 +154,8 @@ ngx_log_debug(ctx->log, "path %s" _ fname.data);
|
|||||||
|
|
||||||
if (ngx_de_is_dir(&dir)) {
|
if (ngx_de_is_dir(&dir)) {
|
||||||
|
|
||||||
ngx_log_debug(ctx->log, "enter %s" _ fname.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
|
||||||
|
"gc enter dir \"%s\"", fname.data);
|
||||||
|
|
||||||
if (level == -1
|
if (level == -1
|
||||||
/* there can not be directory on the last level */
|
/* there can not be directory on the last level */
|
||||||
@ -187,7 +191,8 @@ ngx_log_debug(ctx->log, "enter %s" _ fname.data);
|
|||||||
|
|
||||||
} else if (ngx_de_is_file(&dir)) {
|
} else if (ngx_de_is_file(&dir)) {
|
||||||
|
|
||||||
ngx_log_debug(ctx->log, "file %s" _ fname.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
|
||||||
|
"gc file \"%s\"", fname.data);
|
||||||
|
|
||||||
if (level == -1
|
if (level == -1
|
||||||
|| (level < NGX_MAX_PATH_LEVEL && ctx->path->level[level] != 0))
|
|| (level < NGX_MAX_PATH_LEVEL && ctx->path->level[level] != 0))
|
||||||
@ -239,10 +244,10 @@ int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
|
|||||||
ngx_dir_t *dir)
|
ngx_dir_t *dir)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* we use mtime only and do not use atime because:
|
* We use mtime only and do not use atime because:
|
||||||
* on NTFS access time has a resolution of 1 hour,
|
* on NTFS access time has a resolution of 1 hour,
|
||||||
* on NT FAT access time has a resolution of 1 day,
|
* on NT FAT access time has a resolution of 1 day,
|
||||||
* Unices have mount option "noatime"
|
* Unices have the mount option "noatime".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (ngx_cached_time - ngx_de_mtime(dir) < 3600) {
|
if (ngx_cached_time - ngx_de_mtime(dir) < 3600) {
|
||||||
|
@ -42,7 +42,7 @@ static const char *err_levels[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const char *debug_levels[] = {
|
static const char *debug_levels[] = {
|
||||||
"debug", "debug_core", "debug_alloc", "debug_event", "debug_http"
|
"debug_core", "debug_alloc", "debug_event", "debug_http"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -81,9 +81,9 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
|||||||
len += ngx_snprintf(errstr + len, max - len,
|
len += ngx_snprintf(errstr + len, max - len,
|
||||||
PID_T_FMT "#%d: ", ngx_pid, /* STUB */ 0);
|
PID_T_FMT "#%d: ", ngx_pid, /* STUB */ 0);
|
||||||
|
|
||||||
if (log->data) {
|
if (log->data && *(int *) log->data != -1) {
|
||||||
len += ngx_snprintf(errstr + len, max - len,
|
len += ngx_snprintf(errstr + len, max - len,
|
||||||
"*%u ", * (u_int *) log->data);
|
"*%u ", *(u_int *) log->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (HAVE_VARIADIC_MACROS)
|
#if (HAVE_VARIADIC_MACROS)
|
||||||
@ -332,7 +332,7 @@ char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log)
|
|||||||
|
|
||||||
for (i = 2; i < cf->args->nelts; i++) {
|
for (i = 2; i < cf->args->nelts; i++) {
|
||||||
|
|
||||||
for (n = 1; n < NGX_LOG_DEBUG; n++) {
|
for (n = 1; n <= NGX_LOG_DEBUG; n++) {
|
||||||
if (ngx_strcmp(value[i].data, err_levels[n]) == 0) {
|
if (ngx_strcmp(value[i].data, err_levels[n]) == 0) {
|
||||||
|
|
||||||
if (log->log_level != 0) {
|
if (log->log_level != 0) {
|
||||||
@ -368,5 +368,9 @@ char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log->log_level == NGX_LOG_DEBUG) {
|
||||||
|
log->log_level = NGX_LOG_DEBUG_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
#define NGX_LOG_DEBUG_EVENT 0x40
|
#define NGX_LOG_DEBUG_EVENT 0x40
|
||||||
#define NGX_LOG_DEBUG_HTTP 0x80
|
#define NGX_LOG_DEBUG_HTTP 0x80
|
||||||
|
|
||||||
#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG
|
#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE
|
||||||
#define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP
|
#define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP
|
||||||
#define NGX_LOG_DEBUG_ALL 0xfffffff8
|
#define NGX_LOG_DEBUG_ALL 0xfffffff0
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -74,7 +74,7 @@ typedef size_t (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len);
|
|||||||
|
|
||||||
|
|
||||||
struct ngx_log_s {
|
struct ngx_log_s {
|
||||||
int log_level;
|
ngx_uint_t log_level;
|
||||||
ngx_open_file_t *file;
|
ngx_open_file_t *file;
|
||||||
void *data;
|
void *data;
|
||||||
ngx_log_handler_pt handler;
|
ngx_log_handler_pt handler;
|
||||||
@ -82,8 +82,6 @@ struct ngx_log_s {
|
|||||||
|
|
||||||
#define MAX_ERROR_STR 2048
|
#define MAX_ERROR_STR 2048
|
||||||
|
|
||||||
#define _ ,
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|
||||||
@ -94,21 +92,6 @@ struct ngx_log_s {
|
|||||||
#define ngx_log_error(level, log, args...) \
|
#define ngx_log_error(level, log, args...) \
|
||||||
if (log->log_level >= level) ngx_log_error_core(level, log, args)
|
if (log->log_level >= level) ngx_log_error_core(level, log, args)
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug(log, args...) \
|
|
||||||
if (log->log_level & NGX_LOG_DEBUG) \
|
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args)
|
|
||||||
#else
|
|
||||||
#define ngx_log_debug(log, args...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ngx_assert(assert, fallback, log, args...) \
|
|
||||||
if (!(assert)) { \
|
|
||||||
if (log->log_level >= NGX_LOG_ALERT) \
|
|
||||||
ngx_log_error_core(NGX_LOG_ALERT, log, 0, args); \
|
|
||||||
fallback; \
|
|
||||||
}
|
|
||||||
|
|
||||||
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
|
|
||||||
@ -121,21 +104,6 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
|||||||
#define ngx_log_error(level, log, ...) \
|
#define ngx_log_error(level, log, ...) \
|
||||||
if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
|
if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug(log, ...) \
|
|
||||||
if (log->log_level == NGX_LOG_DEBUG) \
|
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, 0, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define ngx_log_debug(log, ...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ngx_assert(assert, fallback, log, ...) \
|
|
||||||
if (!(assert)) { \
|
|
||||||
if (log->log_level >= NGX_LOG_ALERT) \
|
|
||||||
ngx_log_error_core(NGX_LOG_ALERT, log, 0, __VA_ARGS__); \
|
|
||||||
fallback; \
|
|
||||||
}
|
|
||||||
|
|
||||||
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
|
|
||||||
@ -145,21 +113,6 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
|||||||
|
|
||||||
#define HAVE_VARIADIC_MACROS 0
|
#define HAVE_VARIADIC_MACROS 0
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug(log, text) \
|
|
||||||
if (log->log_level == NGX_LOG_DEBUG) \
|
|
||||||
ngx_log_debug_core(log, 0, text)
|
|
||||||
#else
|
|
||||||
#define ngx_log_debug(log, text)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ngx_assert(assert, fallback, log, text) \
|
|
||||||
if (!(assert)) { \
|
|
||||||
if (log->log_level >= NGX_LOG_ALERT) \
|
|
||||||
ngx_assert_core(log, text); \
|
|
||||||
fallback; \
|
|
||||||
}
|
|
||||||
|
|
||||||
void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err,
|
void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
|
||||||
|
@ -217,12 +217,6 @@ static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
|
|||||||
} else {
|
} else {
|
||||||
n = ngx_read_file(src->file, dst->pos, size, src->file_pos);
|
n = ngx_read_file(src->file, dst->pos, size, src->file_pos);
|
||||||
|
|
||||||
if (n == 0) {
|
|
||||||
ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _
|
|
||||||
src->file_pos _ src->file_last _
|
|
||||||
dst->pos _ dst->last _ dst->start _ dst->end);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n == NGX_ERROR) {
|
if (n == NGX_ERROR) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ static int ngx_aio_del_connection(ngx_connection_t *c)
|
|||||||
|
|
||||||
rc = aio_cancel(c->fd, NULL);
|
rc = aio_cancel(c->fd, NULL);
|
||||||
|
|
||||||
ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_cancel: %d", rc);
|
||||||
|
|
||||||
if (rc == AIO_CANCELED) {
|
if (rc == AIO_CANCELED) {
|
||||||
c->read->active = c->write->active = 0;
|
c->read->active = c->write->active = 0;
|
||||||
|
@ -111,8 +111,8 @@ ngx_event_module_t ngx_epoll_module_ctx = {
|
|||||||
ngx_epoll_del_event, /* delete an event */
|
ngx_epoll_del_event, /* delete an event */
|
||||||
ngx_epoll_add_event, /* enable an event */
|
ngx_epoll_add_event, /* enable an event */
|
||||||
ngx_epoll_del_event, /* disable an event */
|
ngx_epoll_del_event, /* disable an event */
|
||||||
ngx_epoll_add_connection, /* add an connection */
|
NULL, /* add an connection */
|
||||||
ngx_epoll_del_connection, /* delete an connection */
|
NULL, /* delete an connection */
|
||||||
ngx_epoll_process_events, /* process the events */
|
ngx_epoll_process_events, /* process the events */
|
||||||
ngx_epoll_init, /* init the events */
|
ngx_epoll_init, /* init the events */
|
||||||
ngx_epoll_done, /* done the events */
|
ngx_epoll_done, /* done the events */
|
||||||
@ -167,7 +167,11 @@ static int ngx_epoll_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
ngx_event_actions = ngx_epoll_module_ctx.actions;
|
ngx_event_actions = ngx_epoll_module_ctx.actions;
|
||||||
|
|
||||||
ngx_event_flags = NGX_USE_EDGE_EVENT;
|
#if (HAVE_CLEAR_EVENT)
|
||||||
|
ngx_event_flags = NGX_USE_CLEAR_EVENT;
|
||||||
|
#else
|
||||||
|
ngx_event_flags = NGX_USE_LEVEL_EVENT;
|
||||||
|
#endif
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
@ -191,33 +195,53 @@ static void ngx_epoll_done(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
|
static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
|
||||||
{
|
{
|
||||||
struct epoll_event ee;
|
int op, prev;
|
||||||
|
ngx_event_t *e;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
|
struct epoll_event ee;
|
||||||
|
|
||||||
c = ev->data;
|
c = ev->data;
|
||||||
|
|
||||||
#if (NGX_READ_EVENT != EPOLLIN) || (NGX_WRITE_EVENT != EPOLLOUT)
|
|
||||||
if (event == NGX_READ_EVENT) {
|
if (event == NGX_READ_EVENT) {
|
||||||
|
e = c->write;
|
||||||
|
prev = EPOLLOUT;
|
||||||
|
#if (NGX_READ_EVENT != EPOLLIN)
|
||||||
event = EPOLLIN;
|
event = EPOLLIN;
|
||||||
|
|
||||||
} else {
|
|
||||||
event = EPOLLOUT;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ee.events = event|EPOLLET;
|
} else {
|
||||||
ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
|
e = c->read;
|
||||||
|
prev = EPOLLIN;
|
||||||
|
#if (NGX_WRITE_EVENT != EPOLLOUT)
|
||||||
|
event = EPOLLOUT;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
if (e->active) {
|
||||||
"epoll add event: fd:%d ev:%08X", c->fd, ee.events);
|
op = EPOLL_CTL_MOD;
|
||||||
|
event |= prev;
|
||||||
|
|
||||||
if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ee) == -1) {
|
} else {
|
||||||
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
op = EPOLL_CTL_ADD;
|
||||||
"epoll_ctl(EPOLL_CTL_MOD, %d) failed", c->fd);
|
}
|
||||||
|
|
||||||
|
ee.events = event | flags;
|
||||||
|
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
|
||||||
|
|
||||||
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
|
||||||
|
"epoll add event: fd:%d op:%d ev:%08X",
|
||||||
|
c->fd, op, ee.events);
|
||||||
|
|
||||||
|
if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
|
||||||
|
"epoll_ctl(%d, %d) failed", op, c->fd);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ev->active = 1;
|
ev->active = 1;
|
||||||
|
#if 0
|
||||||
|
ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
@ -225,20 +249,51 @@ static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
|
|
||||||
static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
|
static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||||
{
|
{
|
||||||
struct epoll_event ee;
|
int op, prev;
|
||||||
|
ngx_event_t *e;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
|
struct epoll_event ee;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* when the file descriptor is closed the epoll automatically deletes
|
||||||
|
* it from its queue so we do not need to delete explicity the event
|
||||||
|
* before the closing the file descriptor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (flags & NGX_CLOSE_EVENT) {
|
||||||
|
ev->active = 0;
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
c = ev->data;
|
c = ev->data;
|
||||||
|
|
||||||
ee.events = 0;
|
if (event == NGX_READ_EVENT) {
|
||||||
ee.data.ptr = NULL;
|
e = c->write;
|
||||||
|
prev = EPOLLOUT;
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
} else {
|
||||||
"epoll del event: fd:%d", c->fd);
|
e = c->read;
|
||||||
|
prev = EPOLLIN;
|
||||||
|
}
|
||||||
|
|
||||||
if (epoll_ctl(ep, EPOLL_CTL_DEL, c->fd, &ee) == -1) {
|
if (e->active) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
op = EPOLL_CTL_MOD;
|
||||||
"epoll_ctl(EPOLL_CTL_MOD, %d) failed", c->fd);
|
ee.events = prev | flags;
|
||||||
|
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
op = EPOLL_CTL_DEL;
|
||||||
|
ee.events = 0;
|
||||||
|
ee.data.ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
|
||||||
|
"epoll del event: fd:%d op:%d ev:%08X",
|
||||||
|
c->fd, op, ee.events);
|
||||||
|
|
||||||
|
if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
|
||||||
|
"epoll_ctl(%d, %d) failed", op, c->fd);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +303,7 @@ static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int ngx_epoll_add_connection(ngx_connection_t *c)
|
static int ngx_epoll_add_connection(ngx_connection_t *c)
|
||||||
{
|
{
|
||||||
struct epoll_event ee;
|
struct epoll_event ee;
|
||||||
@ -278,6 +334,7 @@ static int ngx_epoll_del_connection(ngx_connection_t *c)
|
|||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int ngx_epoll_process_events(ngx_log_t *log)
|
int ngx_epoll_process_events(ngx_log_t *log)
|
||||||
|
@ -254,7 +254,7 @@ static int ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* when the file descriptor is closed a kqueue automatically deletes
|
* when the file descriptor is closed the kqueue automatically deletes
|
||||||
* its filters so we do not need to delete explicity the event
|
* its filters so we do not need to delete explicity the event
|
||||||
* before the closing the file descriptor.
|
* before the closing the file descriptor.
|
||||||
*/
|
*/
|
||||||
|
@ -19,6 +19,11 @@ extern ngx_module_t ngx_devpoll_module;
|
|||||||
extern ngx_event_module_t ngx_devpoll_module_ctx;
|
extern ngx_event_module_t ngx_devpoll_module_ctx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (HAVE_EPOLL)
|
||||||
|
extern ngx_module_t ngx_epoll_module;
|
||||||
|
extern ngx_event_module_t ngx_epoll_module_ctx;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (HAVE_AIO)
|
#if (HAVE_AIO)
|
||||||
#include <ngx_aio_module.h>
|
#include <ngx_aio_module.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -176,18 +176,19 @@ extern ngx_event_actions_t ngx_event_actions;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The event filter requires to read/write the whole data -
|
* The event filter requires to read/write the whole data -
|
||||||
* select, poll, /dev/poll, kqueue.
|
* select, poll, /dev/poll, kqueue, epoll.
|
||||||
*/
|
*/
|
||||||
#define NGX_USE_LEVEL_EVENT 0x00000001
|
#define NGX_USE_LEVEL_EVENT 0x00000001
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The event filter is deleted after a notification without an additional
|
* The event filter is deleted after a notification without an additional
|
||||||
* syscall - select, poll, kqueue.
|
* syscall - select, poll, kqueue, epoll.
|
||||||
*/
|
*/
|
||||||
#define NGX_USE_ONESHOT_EVENT 0x00000002
|
#define NGX_USE_ONESHOT_EVENT 0x00000002
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The event filter notifies only the changes and an initial level - kqueue.
|
* The event filter notifies only the changes and an initial level -
|
||||||
|
* kqueue, epoll.
|
||||||
*/
|
*/
|
||||||
#define NGX_USE_CLEAR_EVENT 0x00000004
|
#define NGX_USE_CLEAR_EVENT 0x00000004
|
||||||
|
|
||||||
@ -205,7 +206,7 @@ extern ngx_event_actions_t ngx_event_actions;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The event filter notifies only the changes (the edges)
|
* The event filter notifies only the changes (the edges)
|
||||||
* but not an initial level - epoll.
|
* but not an initial level - early epoll patches.
|
||||||
*/
|
*/
|
||||||
#define NGX_USE_EDGE_EVENT 0x00000020
|
#define NGX_USE_EDGE_EVENT 0x00000020
|
||||||
|
|
||||||
@ -275,6 +276,27 @@ extern ngx_event_actions_t ngx_event_actions;
|
|||||||
#define NGX_DISABLE_EVENT EV_DISABLE
|
#define NGX_DISABLE_EVENT EV_DISABLE
|
||||||
|
|
||||||
|
|
||||||
|
#elif (HAVE_DEVPOLL)
|
||||||
|
|
||||||
|
#define NGX_READ_EVENT POLLIN
|
||||||
|
#define NGX_WRITE_EVENT POLLOUT
|
||||||
|
|
||||||
|
#define NGX_LEVEL_EVENT 0
|
||||||
|
|
||||||
|
|
||||||
|
#elif (HAVE_EPOLL)
|
||||||
|
|
||||||
|
#define NGX_READ_EVENT EPOLLIN
|
||||||
|
#define NGX_WRITE_EVENT EPOLLOUT
|
||||||
|
|
||||||
|
#define NGX_LEVEL_EVENT 0
|
||||||
|
#define NGX_CLEAR_EVENT EPOLLET
|
||||||
|
#define NGX_ONESHOT_EVENT 0x70000000
|
||||||
|
#if 0
|
||||||
|
#define NGX_ONESHOT_EVENT EPOLLONESHOT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#elif (HAVE_POLL)
|
#elif (HAVE_POLL)
|
||||||
|
|
||||||
#define NGX_READ_EVENT POLLIN
|
#define NGX_READ_EVENT POLLIN
|
||||||
@ -284,14 +306,6 @@ extern ngx_event_actions_t ngx_event_actions;
|
|||||||
#define NGX_ONESHOT_EVENT 1
|
#define NGX_ONESHOT_EVENT 1
|
||||||
|
|
||||||
|
|
||||||
#elif (HAVE_DEVPOLL)
|
|
||||||
|
|
||||||
#define NGX_READ_EVENT POLLIN
|
|
||||||
#define NGX_WRITE_EVENT POLLOUT
|
|
||||||
|
|
||||||
#define NGX_LEVEL_EVENT 0
|
|
||||||
|
|
||||||
|
|
||||||
#else /* select */
|
#else /* select */
|
||||||
|
|
||||||
#define NGX_READ_EVENT 0
|
#define NGX_READ_EVENT 0
|
||||||
|
@ -5,6 +5,12 @@
|
|||||||
#include <nginx.h>
|
#include <nginx.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int flag;
|
||||||
|
char *name;
|
||||||
|
} ngx_accept_log_ctx_t;
|
||||||
|
|
||||||
|
|
||||||
static size_t ngx_accept_log_error(void *data, char *buf, size_t len);
|
static size_t ngx_accept_log_error(void *data, char *buf, size_t len);
|
||||||
|
|
||||||
|
|
||||||
@ -20,6 +26,7 @@ void ngx_event_accept(ngx_event_t *ev)
|
|||||||
ngx_event_t *rev, *wev;
|
ngx_event_t *rev, *wev;
|
||||||
ngx_connection_t *c, *ls;
|
ngx_connection_t *c, *ls;
|
||||||
ngx_event_conf_t *ecf;
|
ngx_event_conf_t *ecf;
|
||||||
|
ngx_accept_log_ctx_t *ctx;
|
||||||
|
|
||||||
ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
|
ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
|
||||||
|
|
||||||
@ -32,9 +39,9 @@ void ngx_event_accept(ngx_event_t *ev)
|
|||||||
|
|
||||||
ls = ev->data;
|
ls = ev->data;
|
||||||
|
|
||||||
ngx_log_debug(ev->log, "accept on %s ready: %d" _
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
|
||||||
ls->listening->addr_text.data _
|
"accept on %s, ready: %d",
|
||||||
ev->available);
|
ls->listening->addr_text.data, ev->available);
|
||||||
|
|
||||||
ev->ready = 0;
|
ev->ready = 0;
|
||||||
accepted = 0;
|
accepted = 0;
|
||||||
@ -68,7 +75,16 @@ void ngx_event_accept(ngx_event_t *ev)
|
|||||||
ngx_memcpy(log, ls->log, sizeof(ngx_log_t));
|
ngx_memcpy(log, ls->log, sizeof(ngx_log_t));
|
||||||
pool->log = log;
|
pool->log = log;
|
||||||
|
|
||||||
log->data = ls->listening->addr_text.data;
|
if (!(ctx = ngx_palloc(pool, sizeof(ngx_accept_log_ctx_t)))) {
|
||||||
|
ngx_destroy_pool(pool);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -1 disable logging the connection number */
|
||||||
|
ctx->flag = -1;
|
||||||
|
ctx->name = ls->listening->addr_text.data;
|
||||||
|
|
||||||
|
log->data = ctx;
|
||||||
log->handler = ngx_accept_log_error;
|
log->handler = ngx_accept_log_error;
|
||||||
|
|
||||||
len = ls->listening->socklen;
|
len = ls->listening->socklen;
|
||||||
@ -233,8 +249,8 @@ void ngx_event_accept(ngx_event_t *ev)
|
|||||||
wev->log = log;
|
wev->log = log;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In the multithreaded model the connection counter is updated by
|
* TODO: MT: - atomic increment (x86: lock xadd)
|
||||||
* the main thread only that accept()s connections.
|
* or protection by critical section or mutex
|
||||||
*
|
*
|
||||||
* TODO: MP: - allocated in a shared memory
|
* TODO: MP: - allocated in a shared memory
|
||||||
* - atomic increment (x86: lock xadd)
|
* - atomic increment (x86: lock xadd)
|
||||||
@ -279,7 +295,7 @@ void ngx_event_accept(ngx_event_t *ev)
|
|||||||
|
|
||||||
static size_t ngx_accept_log_error(void *data, char *buf, size_t len)
|
static size_t ngx_accept_log_error(void *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
char *sock = data;
|
ngx_accept_log_ctx_t *ctx = data;
|
||||||
|
|
||||||
return ngx_snprintf(buf, len, " while accept() on %s", sock);
|
return ngx_snprintf(buf, len, " while accept() on %s", ctx->name);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <ngx_core.h>
|
#include <ngx_core.h>
|
||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
#include <ngx_event_connect.h>
|
#include <ngx_event_connect.h>
|
||||||
|
#include <nginx.h>
|
||||||
|
|
||||||
|
|
||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
@ -180,6 +181,17 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
|||||||
|
|
||||||
pc->connection = c;
|
pc->connection = c;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: MT: - atomic increment (x86: lock xadd)
|
||||||
|
* or protection by critical section or mutex
|
||||||
|
*
|
||||||
|
* TODO: MP: - allocated in a shared memory
|
||||||
|
* - atomic increment (x86: lock xadd)
|
||||||
|
* or protection by critical section or mutex
|
||||||
|
*/
|
||||||
|
|
||||||
|
c->number = ngx_connection_counter++;
|
||||||
|
|
||||||
if (ngx_add_conn) {
|
if (ngx_add_conn) {
|
||||||
if (ngx_add_conn(c) == NGX_ERROR) {
|
if (ngx_add_conn(c) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
@ -192,7 +204,8 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
|||||||
addr.sin_port = peer->port;
|
addr.sin_port = peer->port;
|
||||||
addr.sin_addr.s_addr = peer->addr;
|
addr.sin_addr.s_addr = peer->addr;
|
||||||
|
|
||||||
ngx_log_debug(pc->log, "CONNECT: %s" _ peer->addr_port_text.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0,
|
||||||
|
"connect to %s", peer->addr_port_text.data);
|
||||||
|
|
||||||
rc = connect(s, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
rc = connect(s, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
|
||||||
|
|
||||||
@ -269,7 +282,7 @@ ngx_log_debug(pc->log, "CONNECT: %s" _ peer->addr_port_text.data);
|
|||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(pc->log, "CONNECTED");
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pc->log, 0, "connected");
|
||||||
|
|
||||||
wev->ready = 1;
|
wev->ready = 1;
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(p->log, "read upstream: %d" _ p->upstream->read->ready);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe read upstream: %d", p->upstream->read->ready);
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
|
|
||||||
@ -104,7 +105,8 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|||||||
p->preread_hunks = NULL;
|
p->preread_hunks = NULL;
|
||||||
n = p->preread_size;
|
n = p->preread_size;
|
||||||
|
|
||||||
ngx_log_debug(p->log, "preread: %d" _ n);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe preread: %d", n);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -169,7 +171,8 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|||||||
|
|
||||||
p->upstream_blocked = 1;
|
p->upstream_blocked = 1;
|
||||||
|
|
||||||
ngx_log_debug(p->log, "downstream ready");
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe downstream ready");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -184,7 +187,8 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|||||||
|
|
||||||
rc = ngx_event_pipe_write_chain_to_temp_file(p);
|
rc = ngx_event_pipe_write_chain_to_temp_file(p);
|
||||||
|
|
||||||
ngx_log_debug(p->log, "temp offset: %d" _ p->temp_file->offset);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe temp offset: %d", p->temp_file->offset);
|
||||||
|
|
||||||
if (rc == NGX_AGAIN) {
|
if (rc == NGX_AGAIN) {
|
||||||
if (ngx_event_flags & NGX_USE_LEVEL_EVENT
|
if (ngx_event_flags & NGX_USE_LEVEL_EVENT
|
||||||
@ -215,14 +219,16 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|||||||
|
|
||||||
/* if there're no hunks to read in then disable a level event */
|
/* if there're no hunks to read in then disable a level event */
|
||||||
|
|
||||||
ngx_log_debug(p->log, "no hunks to read in");
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"no pipe hunks to read in");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = ngx_recv_chain(p->upstream, chain);
|
n = ngx_recv_chain(p->upstream, chain);
|
||||||
|
|
||||||
ngx_log_debug(p->log, "recv_chain: %d" _ n);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe recv chain: %d", n);
|
||||||
|
|
||||||
if (p->free_raw_hunks) {
|
if (p->free_raw_hunks) {
|
||||||
chain->next = p->free_raw_hunks;
|
chain->next = p->free_raw_hunks;
|
||||||
@ -312,7 +318,8 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
|||||||
ngx_hunk_t *h;
|
ngx_hunk_t *h;
|
||||||
ngx_chain_t *out, **ll, *cl, *tl;
|
ngx_chain_t *out, **ll, *cl, *tl;
|
||||||
|
|
||||||
ngx_log_debug(p->log, "write downstream: %d" _ p->downstream->write->ready);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe write downstream: %d", p->downstream->write->ready);
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
if (p->downstream_error) {
|
if (p->downstream_error) {
|
||||||
@ -383,7 +390,8 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
ngx_log_debug(p->log, "no hunks to write BUSY: %d" _ to_write);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe busy hunk data: %d", to_write);
|
||||||
|
|
||||||
if (!(p->upstream_blocked && to_write)) {
|
if (!(p->upstream_blocked && to_write)) {
|
||||||
break;
|
break;
|
||||||
@ -472,12 +480,14 @@ static int ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
|||||||
cl = out;
|
cl = out;
|
||||||
ll = NULL;
|
ll = NULL;
|
||||||
|
|
||||||
ngx_log_debug(p->log, "offset: %d" _ p->temp_file->offset);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe offset: %d", p->temp_file->offset);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
hsize = cl->hunk->last - cl->hunk->pos;
|
hsize = cl->hunk->last - cl->hunk->pos;
|
||||||
|
|
||||||
ngx_log_debug(p->log, "hunk size: %d" _ hsize);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
|
"pipe hunk size: %d", hsize);
|
||||||
|
|
||||||
if ((size + hsize > p->temp_file_write_size)
|
if ((size + hsize > p->temp_file_write_size)
|
||||||
|| (p->temp_file->offset + size + hsize > p->max_temp_file_size))
|
|| (p->temp_file->offset + size + hsize > p->max_temp_file_size))
|
||||||
@ -491,7 +501,7 @@ ngx_log_debug(p->log, "hunk size: %d" _ hsize);
|
|||||||
|
|
||||||
} while (cl);
|
} while (cl);
|
||||||
|
|
||||||
ngx_log_debug(p->log, "size: %d" _ size);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "size: %d", size);
|
||||||
|
|
||||||
if (cl) {
|
if (cl) {
|
||||||
p->in = cl;
|
p->in = cl;
|
||||||
@ -584,7 +594,9 @@ int ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_hunk_t *hunk)
|
|||||||
hunk->shadow = h;
|
hunk->shadow = h;
|
||||||
|
|
||||||
ngx_alloc_link_and_set_hunk(cl, h, p->pool, NGX_ERROR);
|
ngx_alloc_link_and_set_hunk(cl, h, p->pool, NGX_ERROR);
|
||||||
ngx_log_debug(p->log, "HUNK %d" _ h->num);
|
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "hunk #%d", h->num);
|
||||||
|
|
||||||
ngx_chain_add_link(p->in, p->last_in, cl);
|
ngx_chain_add_link(p->in, p->last_in, cl);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
@ -377,9 +377,11 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
ctx->zstream.avail_out = conf->bufs.size;
|
ctx->zstream.avail_out = conf->bufs.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _
|
ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
ctx->zstream.next_in _ ctx->zstream.next_out _
|
"deflate in: ni:%X no:%X ai:%d ao:%d fl:%d",
|
||||||
ctx->zstream.avail_in _ ctx->zstream.avail_out _ ctx->flush);
|
ctx->zstream.next_in, ctx->zstream.next_out,
|
||||||
|
ctx->zstream.avail_in, ctx->zstream.avail_out,
|
||||||
|
ctx->flush);
|
||||||
|
|
||||||
rc = deflate(&ctx->zstream, ctx->flush);
|
rc = deflate(&ctx->zstream, ctx->flush);
|
||||||
if (rc != Z_OK && rc != Z_STREAM_END) {
|
if (rc != Z_OK && rc != Z_STREAM_END) {
|
||||||
@ -388,9 +390,11 @@ ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _
|
|||||||
return ngx_http_gzip_error(ctx);
|
return ngx_http_gzip_error(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _
|
ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
ctx->zstream.next_in _ ctx->zstream.next_out _
|
"deflate out: ni:%X no:%X ai:%d ao:%d rc:%d",
|
||||||
ctx->zstream.avail_in _ ctx->zstream.avail_out _ rc);
|
ctx->zstream.next_in, ctx->zstream.next_out,
|
||||||
|
ctx->zstream.avail_in, ctx->zstream.avail_out,
|
||||||
|
rc);
|
||||||
|
|
||||||
ctx->in_hunk->pos = (char *) ctx->zstream.next_in;
|
ctx->in_hunk->pos = (char *) ctx->zstream.next_in;
|
||||||
ctx->out_hunk->last = (char *) ctx->zstream.next_out;
|
ctx->out_hunk->last = (char *) ctx->zstream.next_out;
|
||||||
@ -512,7 +516,6 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
|
|||||||
int alloc;
|
int alloc;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
|
|
||||||
alloc = items * size;
|
alloc = items * size;
|
||||||
if (alloc % 512 != 0) {
|
if (alloc % 512 != 0) {
|
||||||
|
|
||||||
@ -527,10 +530,9 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
|
|||||||
ctx->free_mem += alloc;
|
ctx->free_mem += alloc;
|
||||||
ctx->allocated -= alloc;
|
ctx->allocated -= alloc;
|
||||||
|
|
||||||
#if 1
|
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
|
||||||
ngx_log_debug(ctx->request->connection->log, "ALLOC: %d:%d:%d:%08X" _
|
"gzip alloc: n:%d s:%d a:%d p:%08X",
|
||||||
items _ size _ alloc _ p);
|
items, size, alloc, p);
|
||||||
#endif
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -550,7 +552,8 @@ static void ngx_http_gzip_filter_free(void *opaque, void *address)
|
|||||||
ngx_http_gzip_ctx_t *ctx = opaque;
|
ngx_http_gzip_ctx_t *ctx = opaque;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ngx_log_debug(ctx->request->connection->log, "FREE: %08X" _ address);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
|
||||||
|
"gzip free: %X", address);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +286,8 @@ static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r,
|
|||||||
ctx->path.data[ctx->path.len - 1] = '\0';
|
ctx->path.data[ctx->path.len - 1] = '\0';
|
||||||
ctx->path.data[ctx->path.len] = '\0';
|
ctx->path.data[ctx->path.len] = '\0';
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "IS_DIR: %s" _ ctx->path.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"http check dir: \"%s\"", ctx->path.data);
|
||||||
|
|
||||||
if (ngx_file_info(ctx->path.data, &r->file.info) == -1) {
|
if (ngx_file_info(ctx->path.data, &r->file.info) == -1) {
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ static int ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
|||||||
ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
|
ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
|
||||||
r->headers_in.if_modified_since->value.len);
|
r->headers_in.if_modified_since->value.len);
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "%d %d" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
ims _ r->headers_out.last_modified_time);
|
"http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I think that the equality of the dates is correcter
|
* I think that the equality of the dates is correcter
|
||||||
|
@ -59,7 +59,8 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
char *last;
|
char *last;
|
||||||
uint32_t file_crc, redirect_crc;
|
uint32_t file_crc, redirect_crc;
|
||||||
ngx_fd_t fd;
|
ngx_fd_t fd;
|
||||||
ngx_int_t rc, level;
|
ngx_int_t rc;
|
||||||
|
ngx_uint_t level;
|
||||||
ngx_str_t name, location;
|
ngx_str_t name, location;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_log_t *log;
|
ngx_log_t *log;
|
||||||
|
@ -167,8 +167,9 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
ngx_cpystrn(c->status_line.data, p->status_start, c->status_line.len + 1);
|
ngx_cpystrn(c->status_line.data, p->status_start, c->status_line.len + 1);
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "http cache status %d '%s'" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
c->status _ c->status_line.data);
|
"http cache status %d \"%s\"",
|
||||||
|
c->status, c->status_line.data);
|
||||||
|
|
||||||
/* TODO: ngx_init_table */
|
/* TODO: ngx_init_table */
|
||||||
c->headers_in.headers = ngx_create_table(r->pool, 20);
|
c->headers_in.headers = ngx_create_table(r->pool, 20);
|
||||||
@ -212,8 +213,9 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "HTTP cache header: '%s: %s'" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
h->key.data _ h->value.data);
|
"http cache header: \"%s: %s\"",
|
||||||
|
h->key.data, h->value.data);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -221,7 +223,8 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
/* a whole header has been parsed successfully */
|
/* a whole header has been parsed successfully */
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "HTTP header done");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"http cache header done");
|
||||||
|
|
||||||
c->ctx.file_start = p->header_in->pos - p->header_in->start;
|
c->ctx.file_start = p->header_in->pos - p->header_in->start;
|
||||||
|
|
||||||
@ -253,7 +256,8 @@ void ngx_http_proxy_cache_busy_lock(ngx_http_proxy_ctx_t *p)
|
|||||||
rc = ngx_http_busy_lock_cachable(p->lcf->busy_lock, &p->busy_lock,
|
rc = ngx_http_busy_lock_cachable(p->lcf->busy_lock, &p->busy_lock,
|
||||||
p->try_busy_lock);
|
p->try_busy_lock);
|
||||||
|
|
||||||
ngx_log_debug(p->request->connection->log, "LOCK CACHABLE: %d" _ rc);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
|
||||||
|
"http cache busy lock cachable: %d", rc);
|
||||||
|
|
||||||
if (rc == NGX_OK) {
|
if (rc == NGX_OK) {
|
||||||
if (p->try_busy_lock) {
|
if (p->try_busy_lock) {
|
||||||
@ -354,8 +358,9 @@ static void ngx_http_proxy_cache_look_complete_request(ngx_http_proxy_ctx_t *p)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(p->request->connection->log, "OLD: %d, NEW: %d" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
|
||||||
p->cache->ctx.file.fd _ ctx->file.fd);
|
"http cache old fd:%d, new fd:%d",
|
||||||
|
p->cache->ctx.file.fd, ctx->file.fd);
|
||||||
|
|
||||||
if (p->cache->ctx.file.fd != NGX_INVALID_FILE) {
|
if (p->cache->ctx.file.fd != NGX_INVALID_FILE) {
|
||||||
if (ngx_close_file(p->cache->ctx.file.fd) == NGX_FILE_ERROR) {
|
if (ngx_close_file(p->cache->ctx.file.fd) == NGX_FILE_ERROR) {
|
||||||
@ -603,8 +608,9 @@ int ngx_http_proxy_update_cache(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
ep = p->upstream->event_pipe;
|
ep = p->upstream->event_pipe;
|
||||||
|
|
||||||
ngx_log_debug(p->request->connection->log, "LEN: " OFF_T_FMT ", " OFF_T_FMT _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
|
||||||
p->cache->ctx.length _ ep->read_length);
|
"http cache update len: " OFF_T_FMT ":" OFF_T_FMT,
|
||||||
|
p->cache->ctx.length, ep->read_length);
|
||||||
|
|
||||||
if (p->cache->ctx.length == -1) {
|
if (p->cache->ctx.length == -1) {
|
||||||
/* TODO: test rc */
|
/* TODO: test rc */
|
||||||
|
@ -346,7 +346,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev)
|
|||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
ngx_http_proxy_ctx_t *p;
|
ngx_http_proxy_ctx_t *p;
|
||||||
|
|
||||||
ngx_log_debug(wev->log, "http proxy check client");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy check client");
|
||||||
|
|
||||||
c = wev->data;
|
c = wev->data;
|
||||||
r = c->data;
|
r = c->data;
|
||||||
@ -362,14 +362,16 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev)
|
|||||||
|
|
||||||
if (!p->cachable && p->upstream->peer.connection) {
|
if (!p->cachable && p->upstream->peer.connection) {
|
||||||
ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
|
ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
|
||||||
"client closed prematurely connection, "
|
"kevent() reported that client have closed "
|
||||||
|
"prematurely connection, "
|
||||||
"so upstream connection is closed too");
|
"so upstream connection is closed too");
|
||||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
|
ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
|
||||||
"client closed prematurely connection");
|
"kevent() reported that client have closed "
|
||||||
|
"prematurely connection");
|
||||||
|
|
||||||
if (p->upstream == NULL || p->upstream->peer.connection == NULL) {
|
if (p->upstream == NULL || p->upstream->peer.connection == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
||||||
@ -385,7 +387,7 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev)
|
|||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
ngx_http_proxy_ctx_t *p;
|
ngx_http_proxy_ctx_t *p;
|
||||||
|
|
||||||
ngx_log_debug(rev->log, "busy lock");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http proxy busy lock");
|
||||||
|
|
||||||
c = rev->data;
|
c = rev->data;
|
||||||
r = c->data;
|
r = c->data;
|
||||||
@ -412,11 +414,12 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(rev->log, "client sent while busy lock");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
|
||||||
|
"http proxy: client sent while busy lock");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: kevent() notify about error, otherwise we need to
|
* TODO: kevent() notify about error, otherwise we need to
|
||||||
* call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio
|
* call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio.
|
||||||
* if there's no error we need to disable event.
|
* if there's no error we need to disable event.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -452,7 +455,8 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc)
|
|||||||
|
|
||||||
r = p->request;
|
r = p->request;
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "finalize http proxy request");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"finalize http proxy request");
|
||||||
|
|
||||||
if (p->upstream && p->upstream->peer.connection) {
|
if (p->upstream && p->upstream->peer.connection) {
|
||||||
ngx_http_proxy_close_connection(p);
|
ngx_http_proxy_close_connection(p);
|
||||||
@ -470,12 +474,15 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p->upstream && p->upstream->event_pipe) {
|
if (p->upstream && p->upstream->event_pipe) {
|
||||||
ngx_log_debug(r->connection->log, "TEMP FD: %d" _
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
p->upstream->event_pipe->temp_file->file.fd);
|
"http proxy temp fd: %d",
|
||||||
|
p->upstream->event_pipe->temp_file->file.fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->cache) {
|
if (p->cache) {
|
||||||
ngx_log_debug(r->connection->log, "CACHE FD: %d" _ p->cache->ctx.file.fd);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"http proxy cache fd: %d",
|
||||||
|
p->cache->ctx.file.fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->upstream && p->upstream->event_pipe) {
|
if (p->upstream && p->upstream->event_pipe) {
|
||||||
@ -504,7 +511,8 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p)
|
|||||||
p->lcf->busy_lock->busy--;
|
p->lcf->busy_lock->busy--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "proxy close connection: %d" _ c->fd);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
|
"http proxy close connection: %d", c->fd);
|
||||||
|
|
||||||
if (c->fd == -1) {
|
if (c->fd == -1) {
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -192,15 +192,19 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
*(h->last++) = CR; *(h->last++) = LF;
|
*(h->last++) = CR; *(h->last++) = LF;
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "proxy: '%s: %s'" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
header[i].key.data _ header[i].value.data);
|
"http proxy header: \"%s: %s\"",
|
||||||
|
header[i].key.data, header[i].value.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add "\r\n" at the header end */
|
/* add "\r\n" at the header end */
|
||||||
*(h->last++) = CR; *(h->last++) = LF;
|
*(h->last++) = CR; *(h->last++) = LF;
|
||||||
|
|
||||||
/* STUB */ *(h->last) = '\0';
|
#if (NGX_DEBUG)
|
||||||
ngx_log_debug(r->connection->log, "PROXY:\n'%s'" _ h->pos);
|
*(h->last) = '\0';
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"http proxy header:\n\"%s\"", h->pos);
|
||||||
|
#endif
|
||||||
|
|
||||||
return chain;
|
return chain;
|
||||||
}
|
}
|
||||||
@ -218,8 +222,9 @@ static void ngx_http_proxy_init_upstream(void *data)
|
|||||||
|
|
||||||
r = p->request;
|
r = p->request;
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "timer_set: %d" _
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
r->connection->read->timer_set);
|
"http proxy set timer: %d",
|
||||||
|
r->connection->read->timer_set);
|
||||||
|
|
||||||
if (r->connection->read->timer_set) {
|
if (r->connection->read->timer_set) {
|
||||||
ngx_del_timer(r->connection->read);
|
ngx_del_timer(r->connection->read);
|
||||||
@ -588,7 +593,7 @@ static void ngx_http_proxy_send_request_handler(ngx_event_t *wev)
|
|||||||
|
|
||||||
static void ngx_http_proxy_dummy_handler(ngx_event_t *wev)
|
static void ngx_http_proxy_dummy_handler(ngx_event_t *wev)
|
||||||
{
|
{
|
||||||
ngx_log_debug(wev->log, "dummy handler");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy dummy handler");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -603,7 +608,8 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
|
|||||||
p = c->data;
|
p = c->data;
|
||||||
p->action = "reading upstream status line";
|
p->action = "reading upstream status line";
|
||||||
|
|
||||||
ngx_log_debug(rev->log, "http proxy process status line");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
|
||||||
|
"http proxy process status line");
|
||||||
|
|
||||||
if (rev->timedout) {
|
if (rev->timedout) {
|
||||||
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
|
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
|
||||||
@ -717,8 +723,9 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
|
|||||||
ngx_cpystrn(p->upstream->status_line.data, p->status_start,
|
ngx_cpystrn(p->upstream->status_line.data, p->status_start,
|
||||||
p->upstream->status_line.len + 1);
|
p->upstream->status_line.len + 1);
|
||||||
|
|
||||||
ngx_log_debug(rev->log, "http proxy status %d '%s'" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0,
|
||||||
p->upstream->status _ p->upstream->status_line.data);
|
"http proxy status %d \"%s\"",
|
||||||
|
p->upstream->status, p->upstream->status_line.data);
|
||||||
|
|
||||||
if (p->upstream->headers_in.headers) {
|
if (p->upstream->headers_in.headers) {
|
||||||
p->upstream->headers_in.headers->nelts = 0;
|
p->upstream->headers_in.headers->nelts = 0;
|
||||||
@ -747,7 +754,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
|
|||||||
r = p->request;
|
r = p->request;
|
||||||
p->action = "reading upstream headers";
|
p->action = "reading upstream headers";
|
||||||
|
|
||||||
ngx_log_debug(rev->log, "http proxy process header line");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
|
||||||
|
"http proxy process header line");
|
||||||
|
|
||||||
if (rev->timedout) {
|
if (rev->timedout) {
|
||||||
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
|
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
|
||||||
@ -818,8 +826,9 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "HTTP proxy header: '%s: %s'" _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
h->key.data _ h->value.data);
|
"http proxy header: \"%s: %s\"",
|
||||||
|
h->key.data, h->value.data);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -827,7 +836,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
|
|||||||
|
|
||||||
/* a whole header has been parsed successfully */
|
/* a whole header has been parsed successfully */
|
||||||
|
|
||||||
ngx_log_debug(c->log, "HTTP header done");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
|
"http proxy header done");
|
||||||
|
|
||||||
/* TODO: hook to process the upstream header */
|
/* TODO: hook to process the upstream header */
|
||||||
|
|
||||||
@ -1072,13 +1082,15 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
|
|||||||
c = ev->data;
|
c = ev->data;
|
||||||
|
|
||||||
if (ev->write) {
|
if (ev->write) {
|
||||||
ngx_log_debug(ev->log, "http proxy process downstream");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
||||||
|
"http proxy process downstream");
|
||||||
r = c->data;
|
r = c->data;
|
||||||
p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
||||||
p->action = "sending to client";
|
p->action = "sending to client";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ngx_log_debug(ev->log, "http proxy process upstream");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
||||||
|
"http proxy process upstream");
|
||||||
p = c->data;
|
p = c->data;
|
||||||
r = p->request;
|
r = p->request;
|
||||||
p->action = "reading upstream body";
|
p->action = "reading upstream body";
|
||||||
@ -1125,7 +1137,8 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ep->upstream_done || ep->upstream_eof || ep->upstream_error) {
|
if (ep->upstream_done || ep->upstream_eof || ep->upstream_error) {
|
||||||
ngx_log_debug(ev->log, "http proxy upstream exit");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
||||||
|
"http proxy upstream exit");
|
||||||
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
||||||
ngx_http_proxy_finalize_request(p, 0);
|
ngx_http_proxy_finalize_request(p, 0);
|
||||||
return;
|
return;
|
||||||
@ -1133,30 +1146,12 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ep->downstream_error) {
|
if (ep->downstream_error) {
|
||||||
ngx_log_debug(ev->log, "http proxy downstream error");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
||||||
|
"http proxy downstream error");
|
||||||
if (!p->cachable && p->upstream->peer.connection) {
|
if (!p->cachable && p->upstream->peer.connection) {
|
||||||
ngx_http_proxy_finalize_request(p, 0);
|
ngx_http_proxy_finalize_request(p, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (ep->downstream_done) {
|
|
||||||
ngx_log_debug(ev->log, "http proxy downstream done");
|
|
||||||
ngx_http_proxy_finalize_request(p, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ep->downstream_error) {
|
|
||||||
ngx_log_debug(ev->log, "http proxy downstream error");
|
|
||||||
if (!p->cachable && p->upstream->peer.connection) {
|
|
||||||
ngx_http_proxy_close_connection(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p->upstream->peer.connection == NULL) {
|
|
||||||
ngx_http_close_request(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1164,7 +1159,8 @@ static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p, int ft_type)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
ngx_log_debug(p->request->connection->log, "next upstream: %d" _ ft_type);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
|
||||||
|
"http proxy next upstream: %d", ft_type);
|
||||||
|
|
||||||
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
|
||||||
|
|
||||||
|
@ -589,23 +589,26 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DEBUG STUFF */
|
#if (NGX_DEBUG)
|
||||||
in_port = in_ports.elts;
|
in_port = in_ports.elts;
|
||||||
for (p = 0; p < in_ports.nelts; p++) {
|
for (p = 0; p < in_ports.nelts; p++) {
|
||||||
ngx_log_debug(cf->log, "port: %d %08x" _ in_port[p].port _ &in_port[p]);
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
|
||||||
|
"port: %d %08x", in_port[p].port, &in_port[p]);
|
||||||
in_addr = in_port[p].addrs.elts;
|
in_addr = in_port[p].addrs.elts;
|
||||||
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
||||||
char ip[20];
|
char ip[20];
|
||||||
ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20);
|
ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20);
|
||||||
ngx_log_debug(cf->log, "%s %08x" _ ip _ in_addr[a].core_srv_conf);
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
|
||||||
|
"%s %08x", ip, in_addr[a].core_srv_conf);
|
||||||
s_name = in_addr[a].names.elts;
|
s_name = in_addr[a].names.elts;
|
||||||
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
||||||
ngx_log_debug(cf->log, "%s %08x" _ s_name[n].name.data _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
|
||||||
s_name[n].core_srv_conf);
|
"%s %08x", s_name[n].name.data,
|
||||||
|
s_name[n].core_srv_conf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**/
|
#endif
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,9 @@ int ngx_http_busy_lock_cachable(ngx_http_busy_lock_t *bl,
|
|||||||
|
|
||||||
rc = ngx_http_busy_lock_look_cachable(bl, bc, lock);
|
rc = ngx_http_busy_lock_look_cachable(bl, bc, lock);
|
||||||
|
|
||||||
ngx_log_debug(bc->event->log, "BUSYLOCK: %d %d:%d" _
|
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, bc->event->log, 0,
|
||||||
rc _ bl->waiting _ bl->max_waiting);
|
"http busylock: %d w:%d mw::%d",
|
||||||
|
rc, bl->waiting, bl->max_waiting);
|
||||||
|
|
||||||
if (rc == NGX_OK) { /* no the same request, there's free slot */
|
if (rc == NGX_OK) { /* no the same request, there's free slot */
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
@ -305,7 +305,7 @@ static void ngx_http_phase_event_handler(ngx_event_t *ev)
|
|||||||
c = ev->data;
|
c = ev->data;
|
||||||
r = c->data;
|
r = c->data;
|
||||||
|
|
||||||
ngx_log_debug(ev->log, "phase event handler");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, "phase event handler");
|
||||||
|
|
||||||
ngx_http_run_phases(r);
|
ngx_http_run_phases(r);
|
||||||
|
|
||||||
@ -612,19 +612,6 @@ int ngx_http_redirect(ngx_http_request_t *r, int redirect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ngx_http_error(ngx_http_request_t *r, int error)
|
|
||||||
{
|
|
||||||
/* STUB */
|
|
||||||
ngx_log_debug(r->connection->log, "http error: %d" _ error);
|
|
||||||
|
|
||||||
/* log request */
|
|
||||||
|
|
||||||
ngx_http_special_response_handler(r, error);
|
|
||||||
ngx_http_close_request(r, 0);
|
|
||||||
return NGX_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_set_exten(ngx_http_request_t *r)
|
ngx_int_t ngx_http_set_exten(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
@ -706,13 +693,15 @@ int ngx_http_delay_handler(ngx_http_request_t *r)
|
|||||||
static int on;
|
static int on;
|
||||||
|
|
||||||
if (on++ == 0) {
|
if (on++ == 0) {
|
||||||
ngx_log_debug(r->connection->log, "SET http delay");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"http set delay");
|
||||||
ngx_add_timer(r->connection->write, 10000);
|
ngx_add_timer(r->connection->write, 10000);
|
||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->connection->write->timedout = 0;
|
r->connection->write->timedout = 0;
|
||||||
ngx_log_debug(r->connection->log, "RESET http delay");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"http reset delay");
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,6 @@ ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
|
|||||||
|
|
||||||
int ngx_http_internal_redirect(ngx_http_request_t *r,
|
int ngx_http_internal_redirect(ngx_http_request_t *r,
|
||||||
ngx_str_t *uri, ngx_str_t *args);
|
ngx_str_t *uri, ngx_str_t *args);
|
||||||
int ngx_http_error(ngx_http_request_t *r, int error);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
|
#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
|
||||||
|
@ -36,12 +36,14 @@ int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx)
|
|||||||
ngx_md5_text(ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len,
|
ngx_md5_text(ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len,
|
||||||
ctx->md5);
|
ctx->md5);
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "URL: %s, md5: %s" _ ctx->key.data _
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len);
|
"file cache uri: %s, md5: %s", ctx->key.data,
|
||||||
|
ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len);
|
||||||
|
|
||||||
ngx_create_hashed_filename(&ctx->file, ctx->path);
|
ngx_create_hashed_filename(&ctx->file, ctx->path);
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "FILE: %s" _ ctx->file.name.data);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
|
"file cache name: %s", ctx->file.name.data);
|
||||||
|
|
||||||
/* TODO: look open files cache */
|
/* TODO: look open files cache */
|
||||||
|
|
||||||
@ -129,7 +131,10 @@ int ngx_http_cache_open_file(ngx_http_cache_ctx_t *ctx, ngx_file_uniq_t uniq)
|
|||||||
ctx->buf->last += n;
|
ctx->buf->last += n;
|
||||||
|
|
||||||
if (ctx->expires < ngx_time()) {
|
if (ctx->expires < ngx_time()) {
|
||||||
ngx_log_debug(ctx->log, "EXPIRED");
|
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
||||||
|
"http file cache expired");
|
||||||
|
|
||||||
return NGX_HTTP_CACHE_STALE;
|
return NGX_HTTP_CACHE_STALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,10 +333,10 @@ static int ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
*(h->last++) = CR; *(h->last++) = LF;
|
*(h->last++) = CR; *(h->last++) = LF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* STUB */
|
#if (NGX_DEBUG)
|
||||||
*(h->last) = '\0';
|
*(h->last) = '\0';
|
||||||
ngx_log_debug(r->connection->log, "%s\n" _ h->pos);
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s\n", h->pos);
|
||||||
/**/
|
#endif
|
||||||
|
|
||||||
/* the end of HTTP header */
|
/* the end of HTTP header */
|
||||||
*(h->last++) = CR; *(h->last++) = LF;
|
*(h->last++) = CR; *(h->last++) = LF;
|
||||||
|
@ -11,16 +11,17 @@ ngx_http_header_t ngx_http_headers_in[] = {
|
|||||||
offsetof(ngx_http_headers_in_t, if_modified_since) },
|
offsetof(ngx_http_headers_in_t, if_modified_since) },
|
||||||
{ ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) },
|
{ ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) },
|
||||||
{ ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer) },
|
{ ngx_string("Referer"), offsetof(ngx_http_headers_in_t, referer) },
|
||||||
|
|
||||||
{ ngx_string("Content-Length"),
|
{ ngx_string("Content-Length"),
|
||||||
offsetof(ngx_http_headers_in_t, content_length) },
|
offsetof(ngx_http_headers_in_t, content_length) },
|
||||||
{ ngx_string("Accept-Encoding"),
|
|
||||||
offsetof(ngx_http_headers_in_t, accept_encoding) },
|
|
||||||
{ ngx_string("Range"), offsetof(ngx_http_headers_in_t, range) },
|
{ ngx_string("Range"), offsetof(ngx_http_headers_in_t, range) },
|
||||||
#if 0
|
#if 0
|
||||||
{ ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range) },
|
{ ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range) },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{ ngx_string("Accept-Encoding"),
|
||||||
|
offsetof(ngx_http_headers_in_t, accept_encoding) },
|
||||||
|
|
||||||
{ ngx_string("Authorization"),
|
{ ngx_string("Authorization"),
|
||||||
offsetof(ngx_http_headers_in_t, authorization) },
|
offsetof(ngx_http_headers_in_t, authorization) },
|
||||||
|
|
||||||
|
@ -648,8 +648,8 @@ ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r)
|
|||||||
|
|
||||||
while (p < r->uri_start + r->uri.len + 1) {
|
while (p < r->uri_start + r->uri.len + 1) {
|
||||||
|
|
||||||
ngx_log_debug(r->connection->log, "S: %d UN: '%x:%c', URI: '%c'" _
|
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
state _ ch _ ch _ *u);
|
"s:%d in:'%x:%c', out:'%c'", state, ch, ch, *u);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case sw_usual:
|
case sw_usual:
|
||||||
|
@ -84,7 +84,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
|||||||
rev = c->read;
|
rev = c->read;
|
||||||
rev->event_handler = ngx_http_init_request;
|
rev->event_handler = ngx_http_init_request;
|
||||||
|
|
||||||
/* STUB: epoll */ c->write->event_handler = ngx_http_empty_handler;
|
/* STUB: epoll edge */ c->write->event_handler = ngx_http_empty_handler;
|
||||||
|
|
||||||
if (rev->ready) {
|
if (rev->ready) {
|
||||||
/* deferred accept, aio, iocp, epoll */
|
/* deferred accept, aio, iocp, epoll */
|
||||||
@ -1180,6 +1180,8 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
h = c->buffer;
|
h = c->buffer;
|
||||||
|
wev = c->write;
|
||||||
|
wev->event_handler = ngx_http_empty_handler;
|
||||||
|
|
||||||
if (h->pos < h->last) {
|
if (h->pos < h->last) {
|
||||||
|
|
||||||
@ -1214,8 +1216,6 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
|
|||||||
|
|
||||||
h->pos = h->last = h->start;
|
h->pos = h->last = h->start;
|
||||||
rev->event_handler = ngx_http_keepalive_handler;
|
rev->event_handler = ngx_http_keepalive_handler;
|
||||||
wev = c->write;
|
|
||||||
wev->event_handler = ngx_http_empty_handler;
|
|
||||||
|
|
||||||
if (wev->active) {
|
if (wev->active) {
|
||||||
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
|
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
|
||||||
@ -1522,7 +1522,7 @@ void ngx_http_close_request(ngx_http_request_t *r, int error)
|
|||||||
void ngx_http_close_connection(ngx_connection_t *c)
|
void ngx_http_close_connection(ngx_connection_t *c)
|
||||||
{
|
{
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
"close connection: %d", c->fd);
|
"close http connection: %d", c->fd);
|
||||||
|
|
||||||
if (c->pool == NULL) {
|
if (c->pool == NULL) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
|
ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ssize_t buffer_output;
|
ssize_t postpone_output;
|
||||||
} ngx_http_write_filter_conf_t;
|
} ngx_http_write_filter_conf_t;
|
||||||
|
|
||||||
|
|
||||||
@ -23,11 +23,19 @@ static int ngx_http_write_filter_init(ngx_cycle_t *cycle);
|
|||||||
|
|
||||||
static ngx_command_t ngx_http_write_filter_commands[] = {
|
static ngx_command_t ngx_http_write_filter_commands[] = {
|
||||||
|
|
||||||
|
/* STUB */
|
||||||
{ ngx_string("buffer_output"),
|
{ ngx_string("buffer_output"),
|
||||||
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_size_slot,
|
ngx_conf_set_size_slot,
|
||||||
NGX_HTTP_LOC_CONF_OFFSET,
|
NGX_HTTP_LOC_CONF_OFFSET,
|
||||||
offsetof(ngx_http_write_filter_conf_t, buffer_output),
|
offsetof(ngx_http_write_filter_conf_t, postpone_output),
|
||||||
|
NULL },
|
||||||
|
|
||||||
|
{ 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 },
|
NULL },
|
||||||
|
|
||||||
ngx_null_command
|
ngx_null_command
|
||||||
@ -112,21 +120,19 @@ int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_FILTER)
|
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
ngx_log_debug(r->connection->log,
|
"http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT,
|
||||||
"write filter: last:%d flush:%qd size:%qd" _
|
last, flush, size);
|
||||||
last _ flush _ size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
|
conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
|
||||||
ngx_http_write_filter_module);
|
ngx_http_write_filter_module);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* avoid the output if there is no last hunk, no flush point and
|
* avoid the output if there is no last hunk, no flush point and
|
||||||
* the size of the hunks is smaller than "buffer_output" directive
|
* the size of the hunks is smaller than "postpone_output" directive
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!last && flush == 0 && size < conf->buffer_output) {
|
if (!last && flush == 0 && size < conf->postpone_output) {
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,9 +146,8 @@ int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
chain = ngx_write_chain(r->connection, ctx->out);
|
chain = ngx_write_chain(r->connection, ctx->out);
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_FILTER)
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
ngx_log_debug(r->connection->log, "write filter %x" _ chain);
|
"http write filter %X", chain);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (chain == NGX_CHAIN_ERROR) {
|
if (chain == NGX_CHAIN_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
@ -166,7 +171,7 @@ static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf)
|
|||||||
ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)),
|
ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
conf->buffer_output = NGX_CONF_UNSET;
|
conf->postpone_output = NGX_CONF_UNSET;
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
@ -178,7 +183,8 @@ static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf,
|
|||||||
ngx_http_write_filter_conf_t *prev = parent;
|
ngx_http_write_filter_conf_t *prev = parent;
|
||||||
ngx_http_write_filter_conf_t *conf = child;
|
ngx_http_write_filter_conf_t *conf = child;
|
||||||
|
|
||||||
ngx_conf_merge_size_value(conf->buffer_output, prev->buffer_output, 1460);
|
ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,
|
||||||
|
1460);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,10 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "rev->complete: %d" _ rev->complete);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
ngx_log_debug(c->log, "aio size: %d" _ size);
|
"rev->complete: %d", rev->complete);
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
|
"aio size: %d", size);
|
||||||
|
|
||||||
if (!rev->complete) {
|
if (!rev->complete) {
|
||||||
ngx_memzero(&rev->aiocb, sizeof(struct aiocb));
|
ngx_memzero(&rev->aiocb, sizeof(struct aiocb));
|
||||||
@ -52,7 +54,8 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "aio_read: #%d OK" _ c->fd);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
|
"aio_read: #%d OK", c->fd);
|
||||||
|
|
||||||
rev->active = 1;
|
rev->active = 1;
|
||||||
rev->ready = 0;
|
rev->ready = 0;
|
||||||
@ -93,7 +96,8 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(rev->log, "aio_read: #%d %d" _ c->fd _ n);
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, rev->log, 0,
|
||||||
|
"aio_read: #%d %d", c->fd, n);
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
rev->eof = 1;
|
rev->eof = 1;
|
||||||
|
@ -41,7 +41,7 @@ ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
|
|||||||
|
|
||||||
n = ngx_aio_read(c, buf, size);
|
n = ngx_aio_read(c, buf, size);
|
||||||
|
|
||||||
ngx_log_debug(c->log, "aio_read: %d" _ n);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_read: %d", n);
|
||||||
|
|
||||||
if (n == NGX_AGAIN) {
|
if (n == NGX_AGAIN) {
|
||||||
return total ? total : NGX_AGAIN;
|
return total ? total : NGX_AGAIN;
|
||||||
@ -64,7 +64,8 @@ ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
|
|||||||
total += n;
|
total += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "aio_read total: %d" _ total);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
|
"aio_read total: %d", total);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total ? total : NGX_AGAIN;
|
return total ? total : NGX_AGAIN;
|
||||||
|
@ -28,7 +28,8 @@ ssize_t ngx_aio_write(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(wev->log, "aio: wev->complete: %d" _ wev->complete);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, wev->log, 0,
|
||||||
|
"aio: wev->complete: %d", wev->complete);
|
||||||
|
|
||||||
if (!wev->complete) {
|
if (!wev->complete) {
|
||||||
ngx_memzero(&wev->aiocb, sizeof(struct aiocb));
|
ngx_memzero(&wev->aiocb, sizeof(struct aiocb));
|
||||||
@ -49,7 +50,7 @@ ngx_log_debug(wev->log, "aio: wev->complete: %d" _ wev->complete);
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(wev->log, "aio_write: OK");
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, wev->log, 0, "aio_write: OK");
|
||||||
|
|
||||||
wev->active = 1;
|
wev->active = 1;
|
||||||
wev->ready = 0;
|
wev->ready = 0;
|
||||||
@ -102,7 +103,7 @@ ngx_log_debug(wev->log, "aio: wev->complete: %d" _ wev->complete);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_log_debug(wev->log, "aio_write: %d" _ n);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, wev->log, 0, "aio_write: %d", n);
|
||||||
|
|
||||||
wev->active = 0;
|
wev->active = 0;
|
||||||
wev->ready = 1;
|
wev->ready = 1;
|
||||||
|
@ -44,9 +44,7 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
|
|
||||||
n = ngx_aio_write(c, buf, size);
|
n = ngx_aio_write(c, buf, size);
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_write: %d", n);
|
||||||
ngx_log_debug(c->log, "aio_write: %d" _ n);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (n == NGX_ERROR) {
|
if (n == NGX_ERROR) {
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
@ -57,9 +55,8 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
c->sent += n;
|
c->sent += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
ngx_log_debug(c->log, "aio_write sent: " OFF_T_FMT _ c->sent);
|
"aio_write sent: " OFF_T_FMT, c->sent);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (cl = in; cl; cl = cl->next) {
|
for (cl = in; cl; cl = cl->next) {
|
||||||
|
|
||||||
|
@ -11,15 +11,16 @@ ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset)
|
|||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
ngx_log_debug(file->log, "read: %d, %x, %d, " OFF_T_FMT _
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
|
||||||
file->fd _ buf _ size _ offset);
|
"read: %d, %X, %d, " OFF_T_FMT, file->fd, buf, size, offset);
|
||||||
|
|
||||||
#if (HAVE_PREAD)
|
#if (HAVE_PREAD)
|
||||||
|
|
||||||
n = pread(file->fd, buf, size, offset);
|
n = pread(file->fd, buf, size, offset);
|
||||||
|
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "pread() failed");
|
ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
|
||||||
|
"pread() failed, file \"%s\"", file->name.data);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +36,6 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|
||||||
/* Linux has a broken strerror_r() */
|
|
||||||
#define HAVE_STRERROR_R 0
|
|
||||||
|
|
||||||
#include <ngx_auto_config.h>
|
#include <ngx_auto_config.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
|
|
||||||
|
|
||||||
static int ngx_readv_error(ngx_event_t *rev, ngx_err_t err);
|
|
||||||
|
|
||||||
#if (HAVE_KQUEUE)
|
#if (HAVE_KQUEUE)
|
||||||
|
|
||||||
ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
||||||
@ -20,18 +18,22 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|||||||
rev = c->read;
|
rev = c->read;
|
||||||
|
|
||||||
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
|
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
|
||||||
ngx_log_debug(c->log, "recv: eof:%d, avail:%d, err:%d" _
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
rev->kq_eof _ rev->available _ rev->kq_errno);
|
"readv: eof:%d, avail:%d, err:%d",
|
||||||
|
rev->kq_eof, rev->available, rev->kq_errno);
|
||||||
|
|
||||||
if (rev->available == 0) {
|
if (rev->available == 0) {
|
||||||
if (rev->kq_eof) {
|
if (rev->kq_eof) {
|
||||||
rev->ready = 0;
|
rev->ready = 0;
|
||||||
rev->eof = 1;
|
rev->eof = 1;
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
|
||||||
|
"kevent() reported about an closed connection");
|
||||||
|
|
||||||
if (rev->kq_errno) {
|
if (rev->kq_errno) {
|
||||||
rev->error = 1;
|
rev->error = 1;
|
||||||
ngx_set_socket_errno(rev->kq_errno);
|
ngx_set_socket_errno(rev->kq_errno);
|
||||||
return ngx_readv_error(rev, rev->kq_errno);
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -65,7 +67,8 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|||||||
chain = chain->next;
|
chain = chain->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
|
"readv: %d:%d", io.nelts, iov->iov_len);
|
||||||
|
|
||||||
rev = c->read;
|
rev = c->read;
|
||||||
|
|
||||||
@ -105,11 +108,19 @@ ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = ngx_readv_error(rev, ngx_socket_errno);
|
err = ngx_socket_errno;
|
||||||
|
|
||||||
} while (n == NGX_EINTR);
|
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
||||||
|
"readv() not ready");
|
||||||
|
n = NGX_AGAIN;
|
||||||
|
|
||||||
/* NGX_ERROR || NGX_AGAIN */
|
} else {
|
||||||
|
n = ngx_connection_error(c, err, "readv() failed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (err == NGX_EINTR);
|
||||||
|
|
||||||
rev->ready = 0;
|
rev->ready = 0;
|
||||||
|
|
||||||
@ -154,7 +165,8 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|||||||
chain = chain->next;
|
chain = chain->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
|
"readv: %d:%d", io.nelts, iov->iov_len);
|
||||||
|
|
||||||
rev = c->read;
|
rev = c->read;
|
||||||
|
|
||||||
@ -173,11 +185,19 @@ ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = ngx_readv_error(rev, ngx_socket_errno);
|
err = ngx_socket_errno;
|
||||||
|
|
||||||
} while (n == NGX_EINTR);
|
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
||||||
|
"readv() not ready");
|
||||||
|
n = NGX_AGAIN;
|
||||||
|
|
||||||
/* NGX_ERROR || NGX_AGAIN */
|
} else {
|
||||||
|
n = ngx_connection_error(c, err, "readv() failed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (err == NGX_EINTR);
|
||||||
|
|
||||||
rev->ready = 0;
|
rev->ready = 0;
|
||||||
|
|
||||||
@ -189,21 +209,3 @@ ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* NAVE_KQUEUE */
|
#endif /* NAVE_KQUEUE */
|
||||||
|
|
||||||
|
|
||||||
static int ngx_readv_error(ngx_event_t *rev, ngx_err_t err)
|
|
||||||
{
|
|
||||||
if (err == NGX_EAGAIN) {
|
|
||||||
ngx_log_error(NGX_LOG_INFO, rev->log, err, "readv() returned EAGAIN");
|
|
||||||
return NGX_AGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == NGX_EINTR) {
|
|
||||||
ngx_log_error(NGX_LOG_INFO, rev->log, err, "readv() returned EINTR");
|
|
||||||
return NGX_EINTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_ERR, rev->log, err, "readv() failed");
|
|
||||||
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
@ -90,7 +90,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
err = ngx_socket_errno;
|
err = ngx_socket_errno;
|
||||||
|
|
||||||
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, err,
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
||||||
"recv() not ready");
|
"recv() not ready");
|
||||||
n = NGX_AGAIN;
|
n = NGX_AGAIN;
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
err = ngx_socket_errno;
|
err = ngx_socket_errno;
|
||||||
|
|
||||||
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, err,
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
||||||
"recv() not ready");
|
"recv() not ready");
|
||||||
n = NGX_AGAIN;
|
n = NGX_AGAIN;
|
||||||
|
|
||||||
|
@ -82,24 +82,24 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
|
||||||
if (err == NGX_EINTR) {
|
|
||||||
eintr = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, err,
|
if (err == NGX_EINTR) {
|
||||||
|
eintr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,
|
||||||
"sendfilev() sent only " SIZE_T_FMT " bytes",
|
"sendfilev() sent only " SIZE_T_FMT " bytes",
|
||||||
sent);
|
sent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
ngx_log_error(NGX_LOG_CRIT, c->log, err, "sendfilev() failed");
|
ngx_connection_error(c, err, "sendfilev() failed");
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
ngx_log_debug(c->log, "sendfilev: %d " SIZE_T_FMT _ n _ sent);
|
"sendfilev: %d " SIZE_T_FMT, n, sent);
|
||||||
#endif
|
|
||||||
|
|
||||||
c->sent += sent;
|
c->sent += sent;
|
||||||
|
|
||||||
|
@ -22,6 +22,18 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (HAVE_KQUEUE)
|
||||||
|
|
||||||
|
if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->kq_eof) {
|
||||||
|
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
|
||||||
|
"kevent() reported about an closed connection");
|
||||||
|
|
||||||
|
wev->error = 1;
|
||||||
|
return NGX_CHAIN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_CHAIN_ERROR);
|
ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_CHAIN_ERROR);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -49,25 +61,26 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
|
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
if (err == NGX_EAGAIN) {
|
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, err, "writev() EAGAIN");
|
|
||||||
|
|
||||||
} else if (err == NGX_EINTR) {
|
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
||||||
eintr = 1;
|
if (err == NGX_EINTR) {
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, err, "writev() EINTR");
|
eintr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
||||||
|
"writev() not ready");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
ngx_log_error(NGX_LOG_CRIT, c->log, err, "writev() failed");
|
ngx_connection_error(c, err, "writev() failed");
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sent = n > 0 ? n : 0;
|
sent = n > 0 ? n : 0;
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
ngx_log_debug(c->log, "writev: " OFF_T_FMT _ sent);
|
"writev: " OFF_T_FMT, sent);
|
||||||
#endif
|
|
||||||
|
|
||||||
c->sent += sent;
|
c->sent += sent;
|
||||||
|
|
||||||
@ -75,8 +88,6 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
|
|
||||||
size = cl->hunk->last - cl->hunk->pos;
|
size = cl->hunk->last - cl->hunk->pos;
|
||||||
|
|
||||||
ngx_log_debug(c->log, "SIZE: %d" _ size);
|
|
||||||
|
|
||||||
if (sent >= size) {
|
if (sent >= size) {
|
||||||
sent -= size;
|
sent -= size;
|
||||||
|
|
||||||
|
@ -64,9 +64,7 @@ ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "WSASend(): %d", sent);
|
||||||
ngx_log_debug(c->log, "WSASend(): %d" _ sent);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
c->sent += sent;
|
c->sent += sent;
|
||||||
|
|
||||||
@ -207,9 +205,7 @@ ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "WSASend(): %d", sent);
|
||||||
ngx_log_debug(c->log, "WSASend(): %d" _ sent);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
c->sent += sent;
|
c->sent += sent;
|
||||||
|
|
||||||
@ -391,9 +387,7 @@ non-block
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG_WRITE_CHAIN)
|
|
||||||
ngx_log_debug(c->log, "WSASend(): %d" _ sent);
|
ngx_log_debug(c->log, "WSASend(): %d" _ sent);
|
||||||
#endif
|
|
||||||
|
|
||||||
c->sent += sent;
|
c->sent += sent;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user