[sheepdog] [PATCH 2/2] Revert "sheep: allow {register, unregister}_event to be called in worker thread"
MORITA Kazutaka
morita.kazutaka at gmail.com
Fri Jan 17 04:35:32 CET 2014
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Now there is no user who calls register_event in worker threads.
This reverts commit 6601e90cf2c5168dfc15919caabcaef50eb75483.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
include/event.h | 15 ---------------
lib/event.c | 14 ++------------
2 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/include/event.h b/include/event.h
index 0082e1a..8f8b21f 100644
--- a/include/event.h
+++ b/include/event.h
@@ -27,21 +27,6 @@ void add_timer(struct timer *t, unsigned int mseconds);
#define EVENT_PRIO_DEFAULT 0
#define EVENT_PRIO_MIN INT_MIN
-/*
- * We can register/unregister the events in the worker thread with the
- * assumption:
- *
- * - one event will only be manipluated by a single entity.
- *
- * By allowing register/unregister events in the work thread, we get the
- * following benefits:
- *
- * 1. avoid to be trapped to main thread for better performance
- * 2. make sure registeration is done before some other events
- *
- * This doesn't mean we can manipulate the same event with multiple threads
- * simultaneously.
- */
static inline int register_event(int fd, event_handler_t h, void *data)
{
return register_event_prio(fd, h, data, EVENT_PRIO_DEFAULT);
diff --git a/lib/event.c b/lib/event.c
index cdb33d6..88078f4 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -21,7 +21,6 @@
static int efd;
static struct rb_root events_tree = RB_ROOT;
-static struct sd_rw_lock events_lock = SD_RW_LOCK_INITIALIZER;
static void timer_handler(int fd, int events, void *data)
{
@@ -93,12 +92,8 @@ int init_event(int nr)
static struct event_info *lookup_event(int fd)
{
struct event_info key = { .fd = fd };
- struct event_info *ret;
- sd_read_lock(&events_lock);
- ret = rb_search(&events_tree, &key, rb, event_cmp);
- sd_rw_unlock(&events_lock);
- return ret;
+ return rb_search(&events_tree, &key, rb, event_cmp);
}
int register_event_prio(int fd, event_handler_t h, void *data, int prio)
@@ -121,11 +116,8 @@ int register_event_prio(int fd, event_handler_t h, void *data, int prio)
if (ret) {
sd_err("failed to add epoll event: %m");
free(ei);
- } else {
- sd_write_lock(&events_lock);
+ } else
rb_insert(&events_tree, ei, rb, event_cmp);
- sd_rw_unlock(&events_lock);
- }
return ret;
}
@@ -143,9 +135,7 @@ void unregister_event(int fd)
if (ret)
sd_err("failed to delete epoll event for fd %d: %m", fd);
- sd_write_lock(&events_lock);
rb_erase(&ei->rb, &events_tree);
- sd_rw_unlock(&events_lock);
free(ei);
/*
--
1.8.1.2
More information about the sheepdog
mailing list