[sheepdog] [PATCH 5/5] sheep: move the init_eventfd() out of init_work_queue()
Liu Yuan
namei.unix at gmail.com
Tue Dec 4 13:20:31 CET 2012
From: Liu Yuan <tailai.ly at taobao.com>
Then we don't need the trick to work around multiple entry of this function.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/sheep.c | 3 +++
sheep/work.c | 12 +-----------
sheep/work.h | 1 +
3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 74acaa4..dcffba3 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -332,6 +332,9 @@ static void init_journal_arg(char *arg)
static int init_work_queues(void)
{
+ if (init_wqueue_eventfd())
+ return -1;
+
sys->gateway_wqueue = init_work_queue("gway", false);
sys->io_wqueue = init_work_queue("io", false);
sys->recovery_wqueue = init_work_queue("rw", false);
diff --git a/sheep/work.c b/sheep/work.c
index 0ef169d..49eac9a 100644
--- a/sheep/work.c
+++ b/sheep/work.c
@@ -184,13 +184,9 @@ retest:
pthread_exit(NULL);
}
-static int init_eventfd(void)
+int init_wqueue_eventfd(void)
{
int ret;
- static bool done;
-
- if (done)
- return 0;
efd = eventfd(0, EFD_NONBLOCK);
if (efd < 0) {
@@ -205,8 +201,6 @@ static int init_eventfd(void)
return 1;
}
- done = true;
-
return 0;
}
@@ -215,10 +209,6 @@ struct work_queue *init_work_queue(const char *name, bool ordered)
int ret;
struct worker_info *wi;
- ret = init_eventfd();
- if (ret)
- return NULL;
-
wi = zalloc(sizeof(*wi));
if (!wi)
return NULL;
diff --git a/sheep/work.h b/sheep/work.h
index 4d45dd6..0d125dc 100644
--- a/sheep/work.h
+++ b/sheep/work.h
@@ -47,5 +47,6 @@ extern int total_ordered_workers;
/* if 'ordered' is true, the work queue are processes in order. */
struct work_queue *init_work_queue(const char *name, bool ordered);
void queue_work(struct work_queue *q, struct work *work);
+int init_wqueue_eventfd(void);
#endif
--
1.7.9.5
More information about the sheepdog
mailing list