diff src/event/modules/ngx_devpoll_module.c @ 452:23fb87bddda1 release-0.1.1

nginx-0.1.1-RELEASE import *) Feature: the gzip_types directive. *) Feature: the tcp_nodelay directive. *) Feature: the send_lowat directive is working not only on OSes that support kqueue NOTE_LOWAT, but also on OSes that support SO_SNDLOWAT. *) Feature: the setproctitle() emulation for Linux and Solaris. *) Bugfix: the "Location" header rewrite bug fixed while the proxying. *) Bugfix: the ngx_http_chunked_module module may get caught in an endless loop. *) Bugfix: the /dev/poll module bugs fixed. *) Bugfix: the responses were corrupted when the temporary files were used while the proxying. *) Bugfix: the unescaped requests were passed to the backend. *) Bugfix: while the build configuration on Linux 2.4 the --with-poll_module parameter was required.
author Igor Sysoev <igor@sysoev.ru>
date Mon, 11 Oct 2004 15:07:03 +0000
parents 42d11f017717
children a88a3e4e158f
line wrap: on
line diff
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -202,13 +202,7 @@ static int ngx_devpoll_add_event(ngx_eve
 #endif
 
 #if (NGX_READ_EVENT != POLLIN)
-    if (event == NGX_READ_EVENT) {
-        event = POLLOUT;
-#if (NGX_WRITE_EVENT != POLLOUT)
-    } else {
-        event = POLLIN;
-#endif
-    }
+    event = (event == NGX_READ_EVENT) ? POLLIN : POLLOUT;
 #endif
 
 #if (NGX_DEBUG)
@@ -218,6 +212,7 @@ static int ngx_devpoll_add_event(ngx_eve
 #endif
 
     ev->active = 1;
+
     return ngx_devpoll_set_event(ev, event, 0);
 }
 
@@ -229,6 +224,10 @@ static int ngx_devpoll_del_event(ngx_eve
 
     c = ev->data;
 
+#if (NGX_READ_EVENT != POLLIN)
+    event = (event == NGX_READ_EVENT) ? POLLIN : POLLOUT;
+#endif
+
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                    "devpoll del event: fd:%d ev:%04X", c->fd, event);
 
@@ -242,13 +241,9 @@ static int ngx_devpoll_del_event(ngx_eve
         return NGX_OK;
     }
 
-    /* we need to restore the second event if it exists */
+    /* restore the paired event if it exists */
 
-    if (event == NGX_READ_EVENT) {
-        if (ev->accept) {
-            return NGX_OK;
-        }
-
+    if (event == POLLIN) {
         e = c->write;
         event = POLLOUT;
 
@@ -257,7 +252,7 @@ static int ngx_devpoll_del_event(ngx_eve
         event = POLLIN;
     }
 
-    if (e) {
+    if (e && e->active) {
         return ngx_devpoll_set_event(e, event, 0);
     }
 
@@ -273,7 +268,7 @@ static int ngx_devpoll_set_event(ngx_eve
     c = ev->data;
 
     ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
-                   "devpoll fd:%d ev:%d fl:%d", c->fd, event, flags);
+                   "devpoll fd:%d ev:%04X fl:%04X", c->fd, event, flags);
 
     if (nchanges >= max_changes) {
         ngx_log_error(NGX_LOG_WARN, ev->log, 0,