nginx-0.0.1-2003-05-22-19:23:47 import
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 3ca006d..e9bda7a 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -319,7 +319,7 @@
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 83f0f68..f3f332a 100644
--- a/src/http/ngx_http_event.c
+++ b/src/http/ngx_http_event.c
@@ -33,6 +33,7 @@
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 @@
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 @@
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 @@
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_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 @@
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 53c32e1..53699ff 100644
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -58,15 +58,6 @@
#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 @@
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 @@
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 @@
/* 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 @@
} 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;
}