[nginx] Events: removed broken thread support from posted events.

Valentin Bartenev vbart at nginx.com
Mon Sep 1 14:22:14 UTC 2014


details:   http://hg.nginx.org/nginx/rev/3377f9459e99
branches:  
changeset: 5820:3377f9459e99
user:      Valentin Bartenev <vbart at nginx.com>
date:      Mon Sep 01 18:20:03 2014 +0400
description:
Events: removed broken thread support from posted events.

It's mostly dead code.  And the idea of thread support for this task has
been deprecated.

diffstat:

 src/core/ngx_connection.c                   |   25 +----
 src/core/ngx_resolver.c                     |   11 --
 src/event/modules/ngx_devpoll_module.c      |   28 +----
 src/event/modules/ngx_epoll_module.c        |   26 +---
 src/event/modules/ngx_eventport_module.c    |   28 +----
 src/event/modules/ngx_kqueue_module.c       |   29 +----
 src/event/modules/ngx_poll_module.c         |   28 +----
 src/event/modules/ngx_rtsig_module.c        |   34 +----
 src/event/modules/ngx_select_module.c       |   11 +-
 src/event/modules/ngx_win32_select_module.c |   11 +-
 src/event/ngx_event.c                       |   22 +----
 src/event/ngx_event.h                       |   29 -----
 src/event/ngx_event_accept.c                |    7 -
 src/event/ngx_event_connect.c               |   11 --
 src/event/ngx_event_mutex.c                 |    2 +-
 src/event/ngx_event_posted.c                |  144 +---------------------------
 src/event/ngx_event_posted.h                |   30 +----
 src/event/ngx_event_timer.c                 |   30 -----
 src/os/unix/ngx_channel.c                   |    7 -
 src/os/unix/ngx_process_cycle.c             |    9 +-
 20 files changed, 66 insertions(+), 456 deletions(-)

diffs (truncated from 1018 to 300 lines):

diff -r 8e7ee4c70a3c -r 3377f9459e99 src/core/ngx_connection.c
--- a/src/core/ngx_connection.c	Mon Sep 01 17:50:59 2014 +0400
+++ b/src/core/ngx_connection.c	Mon Sep 01 18:20:03 2014 +0400
@@ -951,7 +951,9 @@ ngx_close_connection(ngx_connection_t *c
      * before we clean the connection
      */
 
-    ngx_mutex_lock(ngx_posted_events_mutex);
+    ngx_unlock(&c->lock);
+
+#endif
 
     if (c->read->prev) {
         ngx_delete_posted_event(c->read);
@@ -964,27 +966,6 @@ ngx_close_connection(ngx_connection_t *c
     c->read->closed = 1;
     c->write->closed = 1;
 
-    ngx_unlock(&c->lock);
-    c->read->locked = 0;
-    c->write->locked = 0;
-
-    ngx_mutex_unlock(ngx_posted_events_mutex);
-
-#else
-
-    if (c->read->prev) {
-        ngx_delete_posted_event(c->read);
-    }
-
-    if (c->write->prev) {
-        ngx_delete_posted_event(c->write);
-    }
-
-    c->read->closed = 1;
-    c->write->closed = 1;
-
-#endif
-
     ngx_reusable_connection(c, 0);
 
     log_error = c->log_error;
diff -r 8e7ee4c70a3c -r 3377f9459e99 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Mon Sep 01 17:50:59 2014 +0400
+++ b/src/core/ngx_resolver.c	Mon Sep 01 18:20:03 2014 +0400
@@ -3082,17 +3082,6 @@ ngx_udp_connect(ngx_udp_connection_t *uc
 
     c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
 
-#if (NGX_THREADS)
-
-    /* TODO: lock event when call completion handler */
-
-    rev->lock = &c->lock;
-    wev->lock = &c->lock;
-    rev->own_lock = &c->lock;
-    wev->own_lock = &c->lock;
-
-#endif
-
     ngx_log_debug3(NGX_LOG_DEBUG_EVENT, &uc->log, 0,
                    "connect to %V, fd:%d #%uA", &uc->server, s, c->number);
 
diff -r 8e7ee4c70a3c -r 3377f9459e99 src/event/modules/ngx_devpoll_module.c
--- a/src/event/modules/ngx_devpoll_module.c	Mon Sep 01 17:50:59 2014 +0400
+++ b/src/event/modules/ngx_devpoll_module.c	Mon Sep 01 18:20:03 2014 +0400
@@ -404,8 +404,6 @@ ngx_devpoll_process_events(ngx_cycle_t *
         return NGX_ERROR;
     }
 
-    ngx_mutex_lock(ngx_posted_events_mutex);
-
     for (i = 0; i < events; i++) {
 
         fd = event_list[i].fd;
@@ -495,19 +493,13 @@ ngx_devpoll_process_events(ngx_cycle_t *
         rev = c->read;
 
         if ((revents & POLLIN) && rev->active) {
-
-            if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) {
-                rev->posted_ready = 1;
-
-            } else {
-                rev->ready = 1;
-            }
+            rev->ready = 1;
 
             if (flags & NGX_POST_EVENTS) {
-                queue = (ngx_event_t **) (rev->accept ?
-                               &ngx_posted_accept_events : &ngx_posted_events);
+                queue = rev->accept ? &ngx_posted_accept_events
+                                    : &ngx_posted_events;
 
-                ngx_locked_post_event(rev, queue);
+                ngx_post_event(rev, queue);
 
             } else {
                 instance = rev->instance;
@@ -523,16 +515,10 @@ ngx_devpoll_process_events(ngx_cycle_t *
         wev = c->write;
 
         if ((revents & POLLOUT) && wev->active) {
-
-            if (flags & NGX_POST_THREAD_EVENTS) {
-                wev->posted_ready = 1;
-
-            } else {
-                wev->ready = 1;
-            }
+            wev->ready = 1;
 
             if (flags & NGX_POST_EVENTS) {
-                ngx_locked_post_event(wev, &ngx_posted_events);
+                ngx_post_event(wev, &ngx_posted_events);
 
             } else {
                 wev->handler(wev);
@@ -540,8 +526,6 @@ ngx_devpoll_process_events(ngx_cycle_t *
         }
     }
 
-    ngx_mutex_unlock(ngx_posted_events_mutex);
-
     return NGX_OK;
 }
 
diff -r 8e7ee4c70a3c -r 3377f9459e99 src/event/modules/ngx_epoll_module.c
--- a/src/event/modules/ngx_epoll_module.c	Mon Sep 01 17:50:59 2014 +0400
+++ b/src/event/modules/ngx_epoll_module.c	Mon Sep 01 18:20:03 2014 +0400
@@ -612,8 +612,6 @@ ngx_epoll_process_events(ngx_cycle_t *cy
         return NGX_ERROR;
     }
 
-    ngx_mutex_lock(ngx_posted_events_mutex);
-
     for (i = 0; i < events; i++) {
         c = event_list[i].data.ptr;
 
@@ -674,18 +672,13 @@ ngx_epoll_process_events(ngx_cycle_t *cy
             }
 #endif
 
-            if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) {
-                rev->posted_ready = 1;
-
-            } else {
-                rev->ready = 1;
-            }
+            rev->ready = 1;
 
             if (flags & NGX_POST_EVENTS) {
-                queue = (ngx_event_t **) (rev->accept ?
-                               &ngx_posted_accept_events : &ngx_posted_events);
+                queue = rev->accept ? &ngx_posted_accept_events
+                                    : &ngx_posted_events;
 
-                ngx_locked_post_event(rev, queue);
+                ngx_post_event(rev, queue);
 
             } else {
                 rev->handler(rev);
@@ -708,15 +701,10 @@ ngx_epoll_process_events(ngx_cycle_t *cy
                 continue;
             }
 
-            if (flags & NGX_POST_THREAD_EVENTS) {
-                wev->posted_ready = 1;
-
-            } else {
-                wev->ready = 1;
-            }
+            wev->ready = 1;
 
             if (flags & NGX_POST_EVENTS) {
-                ngx_locked_post_event(wev, &ngx_posted_events);
+                ngx_post_event(wev, &ngx_posted_events);
 
             } else {
                 wev->handler(wev);
@@ -724,8 +712,6 @@ ngx_epoll_process_events(ngx_cycle_t *cy
         }
     }
 
-    ngx_mutex_unlock(ngx_posted_events_mutex);
-
     return NGX_OK;
 }
 
diff -r 8e7ee4c70a3c -r 3377f9459e99 src/event/modules/ngx_eventport_module.c
--- a/src/event/modules/ngx_eventport_module.c	Mon Sep 01 17:50:59 2014 +0400
+++ b/src/event/modules/ngx_eventport_module.c	Mon Sep 01 18:20:03 2014 +0400
@@ -466,8 +466,6 @@ ngx_eventport_process_events(ngx_cycle_t
         return NGX_ERROR;
     }
 
-    ngx_mutex_lock(ngx_posted_events_mutex);
-
     for (i = 0; i < events; i++) {
 
         if (event_list[i].portev_source == PORT_SOURCE_TIMER) {
@@ -534,19 +532,13 @@ ngx_eventport_process_events(ngx_cycle_t
             wev->active = 0;
 
             if (revents & POLLIN) {
-
-                if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) {
-                    rev->posted_ready = 1;
-
-                } else {
-                    rev->ready = 1;
-                }
+                rev->ready = 1;
 
                 if (flags & NGX_POST_EVENTS) {
-                    queue = (ngx_event_t **) (rev->accept ?
-                               &ngx_posted_accept_events : &ngx_posted_events);
+                    queue = rev->accept ? &ngx_posted_accept_events
+                                        : &ngx_posted_events;
 
-                    ngx_locked_post_event(rev, queue);
+                    ngx_post_event(rev, queue);
 
                 } else {
                     rev->handler(rev);
@@ -574,16 +566,10 @@ ngx_eventport_process_events(ngx_cycle_t
             }
 
             if (revents & POLLOUT) {
-
-                if (flags & NGX_POST_THREAD_EVENTS) {
-                    wev->posted_ready = 1;
-
-                } else {
-                    wev->ready = 1;
-                }
+                wev->ready = 1;
 
                 if (flags & NGX_POST_EVENTS) {
-                    ngx_locked_post_event(wev, &ngx_posted_events);
+                    ngx_post_event(wev, &ngx_posted_events);
 
                 } else {
                     wev->handler(wev);
@@ -600,8 +586,6 @@ ngx_eventport_process_events(ngx_cycle_t
         }
     }
 
-    ngx_mutex_unlock(ngx_posted_events_mutex);
-
     return NGX_OK;
 }
 
diff -r 8e7ee4c70a3c -r 3377f9459e99 src/event/modules/ngx_kqueue_module.c
--- a/src/event/modules/ngx_kqueue_module.c	Mon Sep 01 17:50:59 2014 +0400
+++ b/src/event/modules/ngx_kqueue_module.c	Mon Sep 01 18:20:03 2014 +0400
@@ -573,8 +573,6 @@ ngx_kqueue_process_events(ngx_cycle_t *c
         return NGX_ERROR;
     }
 
-    ngx_mutex_lock(ngx_posted_events_mutex);
-
     for (i = 0; i < events; i++) {
 
         ngx_kqueue_dump_event(cycle->log, &event_list[i]);
@@ -626,24 +624,6 @@ ngx_kqueue_process_events(ngx_cycle_t *c
                 ev->active = 0;
             }
 
-#if (NGX_THREADS)
-
-            if ((flags & NGX_POST_THREAD_EVENTS) && !ev->accept) {
-                ev->posted_ready = 1;
-                ev->posted_available = event_list[i].data;
-
-                if (event_list[i].flags & EV_EOF) {
-                    ev->posted_eof = 1;
-                    ev->posted_errno = event_list[i].fflags;
-                }
-
-                ngx_locked_post_event(ev, &ngx_posted_events);
-
-                continue;
-            }
-
-#endif
-
             ev->available = event_list[i].data;
 
             if (event_list[i].flags & EV_EOF) {
@@ -674,9 +654,10 @@ ngx_kqueue_process_events(ngx_cycle_t *c
         }
 
         if (flags & NGX_POST_EVENTS) {
-            queue = (ngx_event_t **) (ev->accept ? &ngx_posted_accept_events:
-                                                   &ngx_posted_events);
-            ngx_locked_post_event(ev, queue);
+            queue = ev->accept ? &ngx_posted_accept_events
+                               : &ngx_posted_events;
+



More information about the nginx-devel mailing list