[sheepdog] [PATCH] work: fix memory leak of shor thread creation
Liu Yuan
namei.unix at gmail.com
Tue Jul 3 06:15:55 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
- also use uatomic_add_return() for short thread idx
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/work.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sheep/work.c b/sheep/work.c
index 9deac01..618c9dd 100644
--- a/sheep/work.c
+++ b/sheep/work.c
@@ -57,14 +57,13 @@ struct short_work {
struct worker_info *wi;
};
-static void *run_short_thread(void * arg)
+static void *run_short_thread(void *arg)
{
struct short_work *sw = arg;
eventfd_t value = 1;
static uint64_t idx = 0;
- uatomic_inc(&idx);
- set_thread_name(sw->wi->name, idx);
+ set_thread_name(sw->wi->name, uatomic_add_return(&idx, 1));
sw->work->fn(sw->work);
@@ -73,6 +72,7 @@ static void *run_short_thread(void * arg)
pthread_mutex_unlock(&sw->wi->finished_lock);
eventfd_write(efd, value);
+ free(sw);
return NULL;
}
--
1.7.10.2
More information about the sheepdog
mailing list