diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2003-10-30 08:51:06 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-30 08:51:06 +0000 |
| commit | 68ee8f144242965c9650ad99604d1717c0f84c18 (patch) | |
| tree | 7327fe5fcc7b45d0ade16767c74e918b8ba6f328 /src/event | |
| parent | 14be46ee9862352fc055da8005e9bdf3dd1bc16e (diff) | |
| download | nginx-68ee8f144242965c9650ad99604d1717c0f84c18.tar.gz nginx-68ee8f144242965c9650ad99604d1717c0f84c18.tar.bz2 | |
nginx-0.0.1-2003-10-30-11:51:06 import
Diffstat (limited to 'src/event')
| -rw-r--r-- | src/event/modules/ngx_kqueue_module.c | 4 | ||||
| -rw-r--r-- | src/event/ngx_event.h | 23 | ||||
| -rw-r--r-- | src/event/ngx_event_acceptex.c | 6 | ||||
| -rw-r--r-- | src/event/ngx_event_connect.c | 3 | ||||
| -rw-r--r-- | src/event/ngx_event_pipe.c | 78 | ||||
| -rw-r--r-- | src/event/ngx_event_pipe.h | 1 |
6 files changed, 60 insertions, 55 deletions
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c index 6f6ed622b..26e109b1a 100644 --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -437,8 +437,8 @@ static int ngx_kqueue_process_events(ngx_log_t *log) break; case EVFILT_AIO: - ev->aio_complete = 1; - ev->active = 0; + ev->complete = 1; + ev->ready = 1; ev->event_handler(ev); diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h index 1e5a63a79..629e83d14 100644 --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -61,18 +61,15 @@ struct ngx_event_s { /* * the event was passed or would be passed to a kernel; - * aio mode: 1 - the posted aio operation, - * 0 - the complete aio operation or no aio operation. + * in aio mode - operation was posted. */ unsigned active:1; - /* - * the ready event; - * in aio mode "ready" is always set - it makes things simple - * to learn whether the aio operation complete use aio_complete flag - */ + /* the ready event; in aio mode 0 means that no operation can be posted */ unsigned ready:1; - unsigned aio_complete:1; + + /* aio operation is complete */ + unsigned complete:1; unsigned eof:1; unsigned error:1; @@ -89,12 +86,20 @@ struct ngx_event_s { unsigned deferred_accept:1; + /* TODO: aio_eof and kq_eof can be the single pending_eof */ + /* the pending eof in aio chain operation */ + unsigned aio_eof:1; + + /* the pending eof reported by kqueue */ + unsigned kq_eof:1; + #if (WIN32) + /* setsockopt(SO_UPDATE_ACCEPT_CONTEXT) was succesfull */ unsigned accept_context_updated:1; #endif #if (HAVE_KQUEUE) - unsigned kq_eof:1; + /* the pending errno reported by kqueue */ int kq_errno; #endif diff --git a/src/event/ngx_event_acceptex.c b/src/event/ngx_event_acceptex.c index 8fd978eb0..c737434b7 100644 --- a/src/event/ngx_event_acceptex.c +++ b/src/event/ngx_event_acceptex.c @@ -120,6 +120,9 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n) wev->write = 1; rev->event_handler = ngx_event_acceptex; + rev->ready = 1; + wev->ready = 1; + ngx_test_null(c->pool, ngx_create_pool(ls->pool_size, ls->log), NGX_ERROR); @@ -127,8 +130,7 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n) ngx_test_null(c->buffer, ngx_create_temp_hunk(c->pool, ls->post_accept_buffer_size - + 2 * (c->listening->socklen + 16), - 0, 0), + + 2 * (c->listening->socklen + 16)), NGX_ERROR); ngx_test_null(c->local_sockaddr, ngx_palloc(c->pool, ls->socklen), diff --git a/src/event/ngx_event_connect.c b/src/event/ngx_event_connect.c index d47c5429b..c697c1be5 100644 --- a/src/event/ngx_event_connect.c +++ b/src/event/ngx_event_connect.c @@ -204,12 +204,13 @@ ngx_log_debug(pc->log, "CONNECT: %s" _ peer->addr_port_text.data); if (ngx_event_flags & NGX_USE_AIO_EVENT) { /* aio, iocp */ - rev->ready = 1; #if 1 /* TODO: NGX_EINPROGRESS */ + rev->ready = 1; wev->ready = 1; + return NGX_OK; #endif } diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c index d9f9abcec..387d8b861 100644 --- a/src/event/ngx_event_pipe.c +++ b/src/event/ngx_event_pipe.c @@ -101,71 +101,52 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) } else { -#if (HAVE_KQUEUE) - /* * kqueue notifies about the end of file or a pending error. * This test allows not to allocate a hunk on these conditions * and not to call ngx_recv_chain(). */ - if (ngx_event_flags == NGX_HAVE_KQUEUE_EVENT) { - - if (p->upstream->read->available == 0) { - if (p->upstream->read->kq_eof) { - p->upstream->read->ready = 0; - p->upstream->read->eof = 0; - p->upstream_eof = 1; - p->read = 1; - - if (p->upstream->read->kq_errno) { - p->upstream->read->error = 1; - p->upstream_error = 1; - p->upstream_eof = 0; - - ngx_log_error(NGX_LOG_ERR, p->log, - p->upstream->read->kq_errno, - "readv() failed"); - } - - break; - } - } + if (p->upstream->read->available == 0 + && (p->upstream->read->kq_eof || p->upstream->read->aio_eof)) + { + p->upstream->read->ready = 0; + p->upstream->read->eof = 0; + p->upstream_eof = 1; + p->read = 1; -#if 0 +#if (HAVE_KQUEUE) if (p->upstream->read->kq_errno) { + p->upstream->read->error = 1; + p->upstream_error = 1; + p->upstream_eof = 0; + ngx_log_error(NGX_LOG_ERR, p->log, p->upstream->read->kq_errno, "readv() failed"); - p->upstream_error = 1; - - break; - - } else if (p->upstream->read->kq_eof - && p->upstream->read->available == 0) { - p->upstream_eof = 1; - p->read = 1; - - break; } #endif + break; } -#endif if (p->free_raw_hunks) { /* use the free hunks if they exist */ chain = p->free_raw_hunks; - p->free_raw_hunks = NULL; + if (p->single_buf) { + p->free_raw_hunks = p->free_raw_hunks->next; + chain->next = NULL; + } else { + p->free_raw_hunks = NULL; + } } else if (p->hunks < p->bufs.num) { /* allocate a new hunk if it's still allowed */ - ngx_test_null(h, ngx_create_temp_hunk(p->pool, - p->bufs.size, 0, 0), + ngx_test_null(h, ngx_create_temp_hunk(p->pool, p->bufs.size), NGX_ABORT); p->hunks++; @@ -214,7 +195,12 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) } chain = p->free_raw_hunks; - p->free_raw_hunks = NULL; + if (p->single_buf) { + p->free_raw_hunks = p->free_raw_hunks->next; + chain->next = NULL; + } else { + p->free_raw_hunks = NULL; + } } else { @@ -229,6 +215,9 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) ngx_log_debug(p->log, "recv_chain: %d" _ n); + if (p->free_raw_hunks) { + chain->next = p->free_raw_hunks; + } p->free_raw_hunks = chain; if (n == NGX_ERROR) { @@ -237,6 +226,10 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) } if (n == NGX_AGAIN) { + if (p->single_buf) { + ngx_event_pipe_remove_shadow_links(chain->hunk); + } + break; } @@ -283,8 +276,11 @@ int ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) return NGX_ABORT; } - /* TODO: p->free_raw_hunk->next can be free()ed */ p->free_raw_hunks = p->free_raw_hunks->next; + + for (cl = p->free_raw_hunks; cl; cl = cl->next) { + ngx_pfree(p->pool, cl->hunk->start); + } } if (p->cachable && p->in) { diff --git a/src/event/ngx_event_pipe.h b/src/event/ngx_event_pipe.h index f59b60e7d..fc68cc6e7 100644 --- a/src/event/ngx_event_pipe.h +++ b/src/event/ngx_event_pipe.h @@ -38,6 +38,7 @@ struct ngx_event_pipe_s { unsigned read:1; unsigned cachable:1; + unsigned single_buf:1; unsigned upstream_done:1; unsigned upstream_error:1; unsigned upstream_eof:1; |
