[nginx] Events: removed broken thread support from event timers.
Valentin Bartenev
vbart at nginx.com
Thu Oct 30 22:24:39 UTC 2014
details: http://hg.nginx.org/nginx/rev/1f513d7f1b45
branches:
changeset: 5894:1f513d7f1b45
user: Valentin Bartenev <vbart at nginx.com>
date: Mon Aug 25 13:34:39 2014 +0400
description:
Events: removed broken thread support from event timers.
It's mostly dead code. And the idea of thread support for this task has
been deprecated.
diffstat:
src/core/ngx_rbtree.c | 6 ++----
src/core/ngx_rbtree.h | 6 ++----
src/event/ngx_event_timer.c | 34 ++--------------------------------
src/event/ngx_event_timer.h | 15 +--------------
src/os/unix/ngx_process_cycle.c | 1 -
5 files changed, 7 insertions(+), 55 deletions(-)
diffs (175 lines):
diff -r fa4161fe8254 -r 1f513d7f1b45 src/core/ngx_rbtree.c
--- a/src/core/ngx_rbtree.c Wed Oct 22 15:31:19 2014 +0200
+++ b/src/core/ngx_rbtree.c Mon Aug 25 13:34:39 2014 +0400
@@ -22,8 +22,7 @@ static ngx_inline void ngx_rbtree_right_
void
-ngx_rbtree_insert(ngx_thread_volatile ngx_rbtree_t *tree,
- ngx_rbtree_node_t *node)
+ngx_rbtree_insert(ngx_rbtree_t *tree, ngx_rbtree_node_t *node)
{
ngx_rbtree_node_t **root, *temp, *sentinel;
@@ -155,8 +154,7 @@ ngx_rbtree_insert_timer_value(ngx_rbtree
void
-ngx_rbtree_delete(ngx_thread_volatile ngx_rbtree_t *tree,
- ngx_rbtree_node_t *node)
+ngx_rbtree_delete(ngx_rbtree_t *tree, ngx_rbtree_node_t *node)
{
ngx_uint_t red;
ngx_rbtree_node_t **root, *sentinel, *subst, *temp, *w;
diff -r fa4161fe8254 -r 1f513d7f1b45 src/core/ngx_rbtree.h
--- a/src/core/ngx_rbtree.h Wed Oct 22 15:31:19 2014 +0200
+++ b/src/core/ngx_rbtree.h Mon Aug 25 13:34:39 2014 +0400
@@ -48,10 +48,8 @@ struct ngx_rbtree_s {
(tree)->insert = i
-void ngx_rbtree_insert(ngx_thread_volatile ngx_rbtree_t *tree,
- ngx_rbtree_node_t *node);
-void ngx_rbtree_delete(ngx_thread_volatile ngx_rbtree_t *tree,
- ngx_rbtree_node_t *node);
+void ngx_rbtree_insert(ngx_rbtree_t *tree, ngx_rbtree_node_t *node);
+void ngx_rbtree_delete(ngx_rbtree_t *tree, ngx_rbtree_node_t *node);
void ngx_rbtree_insert_value(ngx_rbtree_node_t *root, ngx_rbtree_node_t *node,
ngx_rbtree_node_t *sentinel);
void ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *root,
diff -r fa4161fe8254 -r 1f513d7f1b45 src/event/ngx_event_timer.c
--- a/src/event/ngx_event_timer.c Wed Oct 22 15:31:19 2014 +0200
+++ b/src/event/ngx_event_timer.c Mon Aug 25 13:34:39 2014 +0400
@@ -10,13 +10,8 @@
#include <ngx_event.h>
-#if (NGX_THREADS)
-ngx_mutex_t *ngx_event_timer_mutex;
-#endif
-
-
-ngx_thread_volatile ngx_rbtree_t ngx_event_timer_rbtree;
-static ngx_rbtree_node_t ngx_event_timer_sentinel;
+ngx_rbtree_t ngx_event_timer_rbtree;
+static ngx_rbtree_node_t ngx_event_timer_sentinel;
/*
* the event timer rbtree may contain the duplicate keys, however,
@@ -30,20 +25,6 @@ ngx_event_timer_init(ngx_log_t *log)
ngx_rbtree_init(&ngx_event_timer_rbtree, &ngx_event_timer_sentinel,
ngx_rbtree_insert_timer_value);
-#if (NGX_THREADS)
-
- if (ngx_event_timer_mutex) {
- ngx_event_timer_mutex->log = log;
- return NGX_OK;
- }
-
- ngx_event_timer_mutex = ngx_mutex_init(log, 0);
- if (ngx_event_timer_mutex == NULL) {
- return NGX_ERROR;
- }
-
-#endif
-
return NGX_OK;
}
@@ -58,15 +39,11 @@ ngx_event_find_timer(void)
return NGX_TIMER_INFINITE;
}
- ngx_mutex_lock(ngx_event_timer_mutex);
-
root = ngx_event_timer_rbtree.root;
sentinel = ngx_event_timer_rbtree.sentinel;
node = ngx_rbtree_min(root, sentinel);
- ngx_mutex_unlock(ngx_event_timer_mutex);
-
timer = (ngx_msec_int_t) (node->key - ngx_current_msec);
return (ngx_msec_t) (timer > 0 ? timer : 0);
@@ -82,9 +59,6 @@ ngx_event_expire_timers(void)
sentinel = ngx_event_timer_rbtree.sentinel;
for ( ;; ) {
-
- ngx_mutex_lock(ngx_event_timer_mutex);
-
root = ngx_event_timer_rbtree.root;
if (root == sentinel) {
@@ -104,8 +78,6 @@ ngx_event_expire_timers(void)
ngx_rbtree_delete(&ngx_event_timer_rbtree, &ev->timer);
- ngx_mutex_unlock(ngx_event_timer_mutex);
-
#if (NGX_DEBUG)
ev->timer.left = NULL;
ev->timer.right = NULL;
@@ -123,6 +95,4 @@ ngx_event_expire_timers(void)
break;
}
-
- ngx_mutex_unlock(ngx_event_timer_mutex);
}
diff -r fa4161fe8254 -r 1f513d7f1b45 src/event/ngx_event_timer.h
--- a/src/event/ngx_event_timer.h Wed Oct 22 15:31:19 2014 +0200
+++ b/src/event/ngx_event_timer.h Mon Aug 25 13:34:39 2014 +0400
@@ -24,12 +24,7 @@ ngx_msec_t ngx_event_find_timer(void);
void ngx_event_expire_timers(void);
-#if (NGX_THREADS)
-extern ngx_mutex_t *ngx_event_timer_mutex;
-#endif
-
-
-extern ngx_thread_volatile ngx_rbtree_t ngx_event_timer_rbtree;
+extern ngx_rbtree_t ngx_event_timer_rbtree;
static ngx_inline void
@@ -39,12 +34,8 @@ ngx_event_del_timer(ngx_event_t *ev)
"event timer del: %d: %M",
ngx_event_ident(ev->data), ev->timer.key);
- ngx_mutex_lock(ngx_event_timer_mutex);
-
ngx_rbtree_delete(&ngx_event_timer_rbtree, &ev->timer);
- ngx_mutex_unlock(ngx_event_timer_mutex);
-
#if (NGX_DEBUG)
ev->timer.left = NULL;
ev->timer.right = NULL;
@@ -89,12 +80,8 @@ ngx_event_add_timer(ngx_event_t *ev, ngx
"event timer add: %d: %M:%M",
ngx_event_ident(ev->data), timer, ev->timer.key);
- ngx_mutex_lock(ngx_event_timer_mutex);
-
ngx_rbtree_insert(&ngx_event_timer_rbtree, &ev->timer);
- ngx_mutex_unlock(ngx_event_timer_mutex);
-
ev->timer_set = 1;
}
diff -r fa4161fe8254 -r 1f513d7f1b45 src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c Wed Oct 22 15:31:19 2014 +0200
+++ b/src/os/unix/ngx_process_cycle.c Mon Aug 25 13:34:39 2014 +0400
@@ -1213,7 +1213,6 @@ ngx_wakeup_worker_threads(ngx_cycle_t *c
/* STUB */
ngx_done_events(cycle);
- ngx_mutex_destroy(ngx_event_timer_mutex);
return;
}
More information about the nginx-devel
mailing list