diff options
Diffstat (limited to 'src/event')
| -rw-r--r-- | src/event/modules/ngx_kqueue_module.c | 11 | ||||
| -rw-r--r-- | src/event/ngx_event.h | 27 | ||||
| -rw-r--r-- | src/event/ngx_event_proxy.c | 25 |
3 files changed, 43 insertions, 20 deletions
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c index bc2fe217e..4fe9e6b53 100644 --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -12,19 +12,15 @@ #include <ngx_event_timer.h> #include <ngx_kqueue_module.h> -#if (USE_KQUEUE) && !(HAVE_KQUEUE) -#error "kqueue is not supported on this platform" -#endif - /* STUB */ #define KQUEUE_NCHANGES 512 #define KQUEUE_NEVENTS 512 -/* should be per-thread */ +/* should be per-thread if threads are used without thread pool */ #if 1 -int kq; +int kq; #else static int kq; #endif @@ -60,7 +56,6 @@ int ngx_kqueue_init(int max_connections, ngx_log_t *log) return NGX_ERROR; } -#if !(USE_KQUEUE) ngx_event_actions.add = ngx_kqueue_add_event; ngx_event_actions.del = ngx_kqueue_del_event; ngx_event_actions.timer = ngx_event_add_timer; @@ -91,8 +86,6 @@ int ngx_kqueue_init(int max_connections, ngx_log_t *log) #endif -#endif - return NGX_OK; } diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h index f67ae9513..c3cc9079e 100644 --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -146,31 +146,33 @@ typedef struct { } ngx_event_actions_t; -/* Event filter requires to read/write the whole data - +/* The event filter requires to read/write the whole data - select, poll, /dev/poll, kqueue. */ #define NGX_HAVE_LEVEL_EVENT 1 -/* Event filter is deleted after notification - select, poll, kqueue. - Using /dev/poll it can be implemented with additional syscall */ +/* The event filter is deleted after a notification without an additional + syscall - select, poll, kqueue. */ #define NGX_HAVE_ONESHOT_EVENT 2 -/* Event filter notifies only changes and initial level - kqueue */ +/* The event filter notifies only the changes and an initial level - kqueue */ #define NGX_HAVE_CLEAR_EVENT 4 -/* Event filter has kqueue features - eof flag, errno, available data, etc */ +/* The event filter has kqueue features - the eof flag, errno, + available data, etc */ #define NGX_HAVE_KQUEUE_EVENT 8 -/* Event filter supports low water mark - kqueue's NOTE_LOWAT, - early kqueue implementations have no NOTE_LOWAT so we need a separate flag */ +/* The event filter supports low water mark - kqueue's NOTE_LOWAT. + Early kqueue implementations have no NOTE_LOWAT so we need a separate flag */ #define NGX_HAVE_LOWAT_EVENT 0x00000010 -/* Event filter notifies only changes (edges) but not initial level - epoll */ +/* The event filter notifies only the changes (the edges) + but not an initial level - epoll */ #define NGX_HAVE_EDGE_EVENT 0x00000020 -/* No need to add or delete event filters - rt signals */ +/* No need to add or delete the event filters - rt signals */ #define NGX_HAVE_SIGIO_EVENT 0x00000040 -/* No need to add or delete event filters - overlapped, aio_read, aioread */ +/* No need to add or delete the event filters - overlapped, aio_read, aioread */ #define NGX_HAVE_AIO_EVENT 0x00000080 /* Need to add socket or handle only once - i/o completion port. @@ -284,6 +286,11 @@ extern int ngx_event_flags; #endif +#if !(HAVE_EPOLL) +#define ngx_edge_add_event(ev) NGX_ERROR +#endif + + ssize_t ngx_event_recv_core(ngx_connection_t *c, char *buf, size_t size); int ngx_event_close_connection(ngx_event_t *ev); diff --git a/src/event/ngx_event_proxy.c b/src/event/ngx_event_proxy.c index 334f8684d..47530f6e5 100644 --- a/src/event/ngx_event_proxy.c +++ b/src/event/ngx_event_proxy.c @@ -40,6 +40,27 @@ ngx_log_debug(p->log, "read upstream"); } else { +#if (HAVE_KQUEUE) /* kqueue notifies about the end of file or a pending error */ + + if (ngx_event_type == NGX_HAVE_KQUEUE_EVENT) { + + if (p->upstream->read->error) { + ngx_log_error(NGX_LOG_ERR, p->log, + p->upstream->read->error, + "readv() failed"); + p->upstream_error = 1; + + return NGX_ERROR; + + } else if (p->upstream->read->eof + && p->upstream->read->available == 0) { + p->upstream_eof = 1; + p->block_upstream = 0; + + break; + } + } +#endif /* use the free hunks if they exist */ if (p->free_hunks) { @@ -151,6 +172,7 @@ ngx_log_debug(p->log, "recv_chain: %d" _ n); } p->upstream_eof = 1; p->block_upstream = 0; + break; } @@ -399,7 +421,8 @@ int ngx_event_proxy_write_to_downstream(ngx_event_proxy_t *p) ngx_hunk_t *h; ngx_chain_t *entry; - if (p->downstream_level == 0 + if (p->upstream_level == 0 + && p->downstream_level == 0 && p->busy_hunk == NULL && p->out_hunks == NULL && p->in_hunks == NULL |
