diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/ngx_http_core_module.c | 2 | ||||
| -rw-r--r-- | src/http/ngx_http_event.c | 56 | ||||
| -rw-r--r-- | src/http/ngx_http_output_filter.c | 42 |
3 files changed, 64 insertions, 36 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 3ca006d97..e9bda7a78 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -319,7 +319,7 @@ ngx_log_debug(r->connection->log, "trans: %s" _ lcfp[i]->name.data); lcf = (ngx_http_core_loc_conf_t *) ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx); - if (lcf->sendfile == 0) { + if ((ngx_io.flags & NGX_IO_SENDFILE) == 0 || lcf->sendfile == 0) { r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY; } diff --git a/src/http/ngx_http_event.c b/src/http/ngx_http_event.c index 83f0f688d..f3f332a18 100644 --- a/src/http/ngx_http_event.c +++ b/src/http/ngx_http_event.c @@ -33,6 +33,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r); static void ngx_http_keepalive_handler(ngx_event_t *ev); static void ngx_http_set_lingering_close(ngx_http_request_t *r); static void ngx_http_lingering_close_handler(ngx_event_t *ev); +static void ngx_http_empty_handler(ngx_event_t *wev); static void ngx_http_header_parse_error(ngx_http_request_t *r, int parse_err); static size_t ngx_http_log_error(void *data, char *buf, size_t len); @@ -1001,6 +1002,8 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r) c = (ngx_connection_t *) r->connection; rev = c->read; + ngx_log_debug(c->log, "set http keepalive handler"); + ctx = (ngx_http_log_ctx_t *) c->log->data; ctx->action = "closing request"; ngx_http_close_request(r, 0); @@ -1061,10 +1064,15 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r) rev->event_handler = ngx_http_keepalive_handler; wev = c->write; - if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { - if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) { - ngx_http_close_connection(c); - return; + if (wev->active) { + if (ngx_event_flags & NGX_USE_LEVEL_EVENT) { + if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) { + ngx_http_close_connection(c); + return; + } + + } else if ((ngx_event_flags & NGX_HAVE_AIO_EVENT) == 0) { + wev->event_handler = ngx_http_empty_handler; } } @@ -1158,11 +1166,16 @@ static void ngx_http_set_lingering_close(ngx_http_request_t *r) rev->blocked = 0; } - if (c->write->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) { - if (ngx_del_event(c->write, NGX_WRITE_EVENT, 0) == NGX_ERROR) { - ngx_http_close_request(r, 0); - ngx_http_close_connection(c); - return; + if (c->write->active) { + if (ngx_event_flags & NGX_USE_LEVEL_EVENT) { + if (ngx_del_event(c->write, NGX_WRITE_EVENT, 0) == NGX_ERROR) { + ngx_http_close_request(r, 0); + ngx_http_close_connection(c); + return; + } + + } else if ((ngx_event_flags & NGX_HAVE_AIO_EVENT) == 0) { + c->write->event_handler = ngx_http_empty_handler; } } @@ -1259,6 +1272,14 @@ static void ngx_http_lingering_close_handler(ngx_event_t *rev) } +static void ngx_http_empty_handler(ngx_event_t *wev) +{ + ngx_log_debug(wev->log, "http empty handler"); + + return; +} + + void ngx_http_close_request(ngx_http_request_t *r, int error) { ngx_http_log_ctx_t *ctx; @@ -1306,17 +1327,22 @@ void ngx_http_close_connection(ngx_connection_t *c) c->read->timer_set = 0; } - if (c->read->active) { - ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); - } - if (c->write->timer_set) { ngx_del_timer(c->write); c->write->timer_set = 0; } - if (c->write->active) { - ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT); + if (1) { + ngx_del_conn(c); + + } else { + if (c->read->active) { + ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); + } + + if (c->write->active) { + ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT); + } } if (ngx_close_socket(c->fd) == -1) { diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c index 53c32e1ad..53699ff04 100644 --- a/src/http/ngx_http_output_filter.c +++ b/src/http/ngx_http_output_filter.c @@ -58,15 +58,6 @@ ngx_module_t ngx_http_output_filter_module = { #define next_filter (*ngx_http_top_body_filter) -#if 0 -static int (*next_filter) (ngx_http_request_t *r, ngx_chain_t *ch); -#endif - - -#if 0 -#define next_filter ngx_http_output_filter_module_ctx.next_output_body_filter -#endif - #define need_to_copy(r, hunk) \ (((r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY) \ && (hunk->type & NGX_HUNK_IN_MEMORY) == 0) \ @@ -159,6 +150,8 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) return rc; } +ngx_log_debug(r->connection->log, "HERE"); + /* NGX_OK */ /* set our hunk free */ ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start; @@ -211,6 +204,20 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) return rc; } #endif + + if (ctx->incoming->hunk->type & NGX_HUNK_IN_MEMORY) { + size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos; + + } else { + size = ctx->incoming->hunk->file_last + - ctx->incoming->hunk->file_pos; + } + + /* delete the completed hunk from the incoming chain */ + if (size == 0) { + ctx->incoming = ctx->incoming->next; + } + ctx->out.hunk = ctx->hunk; ctx->out.next = NULL; @@ -226,19 +233,8 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) /* repeat until we will have copied the whole first hunk from the chain ctx->incoming */ - if (ctx->incoming->hunk->type & NGX_HUNK_IN_MEMORY) { - size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos; - - } else { - size = ctx->incoming->hunk->file_last - - ctx->incoming->hunk->file_pos; - } - } while (size); - /* delete the completed hunk from the incoming chain */ - ctx->incoming = ctx->incoming->next; - /* repeat until we will have processed the whole chain ctx->incoming */ } while (ctx->incoming); @@ -276,6 +272,12 @@ static int ngx_http_output_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src) } else { 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) { return n; } |
