diff src/event/modules/ngx_poll_module.c @ 32:da8c190bdaba NGINX_0_1_16

nginx 0.1.16 *) Bugfix: if the response were transferred by chunks, then on the HEAD request the final chunk was issued. *) Bugfix: the "Connection: keep-alive" header were issued, even if the keepalive_timeout directive forbade the keep-alive use. *) Bugfix: the errors in the ngx_http_fastcgi_module caused the segmentation faults. *) Bugfix: the compressed response encrypted by SSL may not transferred complete. *) Bugfix: the TCP-specific TCP_NODELAY, TCP_NOPSUH, and TCP_CORK options, are not used for the unix domain sockets. *) Feature: the rewrite directive supports the arguments rewriting. *) Bugfix: the response code 400 was returned for the POST request with the "Content-Length: 0" header; bug appeared in 0.1.14.
author Igor Sysoev <http://sysoev.ru>
date Tue, 25 Jan 2005 00:00:00 +0300
parents 46833bd150cb
children 6cfc63e68377
line wrap: on
line diff
--- a/src/event/modules/ngx_poll_module.c
+++ b/src/event/modules/ngx_poll_module.c
@@ -262,7 +262,7 @@ static ngx_int_t ngx_poll_del_event(ngx_
 
 static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle)
 {
-    int                 ready;
+    int                 ready, revents;
     ngx_int_t           i, nready;
     ngx_uint_t          n, found, lock, expire;
     ngx_msec_t          timer;
@@ -378,33 +378,30 @@ static ngx_int_t ngx_poll_process_events
 
     for (i = 0; i < nevents && ready; i++) {
 
+        revents = event_list[i].revents;
+
 #if 0
         ngx_log_debug4(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
                        "poll: %d: fd:%d ev:%04Xd rev:%04Xd",
-                       i, event_list[i].fd,
-                       event_list[i].events, event_list[i].revents);
+                       i, event_list[i].fd, event_list[i].events, revents);
 #else
-        if (event_list[i].revents) {
+        if (revents) {
             ngx_log_debug4(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
                            "poll: %d: fd:%d ev:%04Xd rev:%04Xd",
-                           i, event_list[i].fd,
-                           event_list[i].events, event_list[i].revents);
+                           i, event_list[i].fd, event_list[i].events, revents);
         }
 #endif
 
-        if (event_list[i].revents & POLLNVAL) {
+        if (revents & POLLNVAL) {
             ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
                           "poll() error fd:%d ev:%04Xd rev:%04Xd",
-                          event_list[i].fd,
-                          event_list[i].events, event_list[i].revents);
+                          event_list[i].fd, event_list[i].events, revents);
         }
 
-        if (event_list[i].revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL))
-        {
+        if (revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
             ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
                           "strange poll() events fd:%d ev:%04Xd rev:%04Xd",
-                          event_list[i].fd,
-                          event_list[i].events, event_list[i].revents);
+                          event_list[i].fd, event_list[i].events, revents);
         }
 
         if (event_list[i].fd == -1) {
@@ -447,9 +444,21 @@ static ngx_int_t ngx_poll_process_events
             continue;
         }
 
+        if ((revents & (POLLERR|POLLHUP|POLLNVAL))
+             && (revents & (POLLIN|POLLOUT)) == 0)
+        {
+            /*
+             * if the error events were returned without POLLIN or POLLOUT,
+             * then add these flags to handle the events at least in one
+             * active handler
+             */
+
+            revents |= POLLIN|POLLOUT;
+        }
+
         found = 0;
 
-        if (event_list[i].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) {
+        if (revents & POLLIN) {
             found = 1;
 
             ev = c->read;
@@ -474,7 +483,7 @@ static ngx_int_t ngx_poll_process_events
 #endif
         }
 
-        if (event_list[i].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
+        if (revents & POLLOUT) {
             found = 1;
             ev = c->write;
             ev->ready = 1;