git-svn: trunk@4327
Török Edvin authored on 2008/11/04 18:13:18... | ... |
@@ -46,12 +46,12 @@ |
46 | 46 |
static work_queue_t *work_queue_new(void) |
47 | 47 |
{ |
48 | 48 |
work_queue_t *work_q; |
49 |
- |
|
49 |
+ |
|
50 | 50 |
work_q = (work_queue_t *) malloc(sizeof(work_queue_t)); |
51 | 51 |
if (!work_q) { |
52 | 52 |
return NULL; |
53 | 53 |
} |
54 |
- |
|
54 |
+ |
|
55 | 55 |
work_q->head = work_q->tail = NULL; |
56 | 56 |
work_q->item_count = 0; |
57 | 57 |
return work_q; |
... | ... |
@@ -60,7 +60,7 @@ static work_queue_t *work_queue_new(void) |
60 | 60 |
static int work_queue_add(work_queue_t *work_q, void *data) |
61 | 61 |
{ |
62 | 62 |
work_item_t *work_item; |
63 |
- |
|
63 |
+ |
|
64 | 64 |
if (!work_q) { |
65 | 65 |
return FALSE; |
66 | 66 |
} |
... | ... |
@@ -68,11 +68,11 @@ static int work_queue_add(work_queue_t *work_q, void *data) |
68 | 68 |
if (!work_item) { |
69 | 69 |
return FALSE; |
70 | 70 |
} |
71 |
- |
|
71 |
+ |
|
72 | 72 |
work_item->next = NULL; |
73 | 73 |
work_item->data = data; |
74 | 74 |
gettimeofday(&(work_item->time_queued), NULL); |
75 |
- |
|
75 |
+ |
|
76 | 76 |
if (work_q->head == NULL) { |
77 | 77 |
work_q->head = work_q->tail = work_item; |
78 | 78 |
work_q->item_count = 1; |
... | ... |
@@ -88,7 +88,7 @@ static void *work_queue_pop(work_queue_t *work_q) |
88 | 88 |
{ |
89 | 89 |
work_item_t *work_item; |
90 | 90 |
void *data; |
91 |
- |
|
91 |
+ |
|
92 | 92 |
if (!work_q || !work_q->head) { |
93 | 93 |
return NULL; |
94 | 94 |
} |
... | ... |
@@ -245,9 +245,9 @@ void thrmgr_destroy(threadpool_t *threadpool) |
245 | 245 |
if (!threadpool) { |
246 | 246 |
return; |
247 | 247 |
} |
248 |
- if (pthread_mutex_lock(&threadpool->pool_mutex) != 0) { |
|
249 |
- logg("!Mutex lock failed\n"); |
|
250 |
- exit(-1); |
|
248 |
+ if (pthread_mutex_lock(&threadpool->pool_mutex) != 0) { |
|
249 |
+ logg("!Mutex lock failed\n"); |
|
250 |
+ exit(-1); |
|
251 | 251 |
} |
252 | 252 |
if(threadpool->state != POOL_VALID) { |
253 | 253 |
if (pthread_mutex_unlock(&threadpool->pool_mutex) != 0) { |
... | ... |
@@ -257,7 +257,7 @@ void thrmgr_destroy(threadpool_t *threadpool) |
257 | 257 |
return; |
258 | 258 |
} |
259 | 259 |
threadpool->state = POOL_EXIT; |
260 |
- |
|
260 |
+ |
|
261 | 261 |
/* wait for threads to exit */ |
262 | 262 |
if (threadpool->thr_alive > 0) { |
263 | 263 |
if (pthread_cond_broadcast(&(threadpool->pool_cond)) != 0) { |
... | ... |
@@ -272,11 +272,11 @@ void thrmgr_destroy(threadpool_t *threadpool) |
272 | 272 |
} |
273 | 273 |
} |
274 | 274 |
remove_frompools(threadpool); |
275 |
- if (pthread_mutex_unlock(&threadpool->pool_mutex) != 0) { |
|
276 |
- logg("!Mutex unlock failed\n"); |
|
277 |
- exit(-1); |
|
278 |
- } |
|
279 |
- |
|
275 |
+ if (pthread_mutex_unlock(&threadpool->pool_mutex) != 0) { |
|
276 |
+ logg("!Mutex unlock failed\n"); |
|
277 |
+ exit(-1); |
|
278 |
+ } |
|
279 |
+ |
|
280 | 280 |
pthread_mutex_destroy(&(threadpool->pool_mutex)); |
281 | 281 |
pthread_cond_destroy(&(threadpool)->idle_cond); |
282 | 282 |
pthread_cond_destroy(&(threadpool->pool_cond)); |
... | ... |
@@ -292,11 +292,11 @@ threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void |
292 | 292 |
#if defined(C_BIGSTACK) |
293 | 293 |
size_t stacksize; |
294 | 294 |
#endif |
295 |
- |
|
295 |
+ |
|
296 | 296 |
if (max_threads <= 0) { |
297 | 297 |
return NULL; |
298 | 298 |
} |
299 |
- |
|
299 |
+ |
|
300 | 300 |
threadpool = (threadpool_t *) malloc(sizeof(threadpool_t)); |
301 | 301 |
if (!threadpool) { |
302 | 302 |
return NULL; |
... | ... |
@@ -306,14 +306,14 @@ threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void |
306 | 306 |
if (!threadpool->queue) { |
307 | 307 |
free(threadpool); |
308 | 308 |
return NULL; |
309 |
- } |
|
309 |
+ } |
|
310 | 310 |
threadpool->thr_max = max_threads; |
311 | 311 |
threadpool->thr_alive = 0; |
312 | 312 |
threadpool->thr_idle = 0; |
313 | 313 |
threadpool->idle_timeout = idle_timeout; |
314 | 314 |
threadpool->handler = handler; |
315 | 315 |
threadpool->tasks = NULL; |
316 |
- |
|
316 |
+ |
|
317 | 317 |
if(pthread_mutex_init(&(threadpool->pool_mutex), NULL)) { |
318 | 318 |
free(threadpool->queue); |
319 | 319 |
free(threadpool); |
... | ... |
@@ -343,7 +343,7 @@ threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void |
343 | 343 |
free(threadpool); |
344 | 344 |
return NULL; |
345 | 345 |
} |
346 |
- |
|
346 |
+ |
|
347 | 347 |
if (pthread_attr_setdetachstate(&(threadpool->pool_attr), PTHREAD_CREATE_DETACHED) != 0) { |
348 | 348 |
pthread_attr_destroy(&(threadpool->pool_attr)); |
349 | 349 |
pthread_cond_destroy(&(threadpool->idle_cond)); |
... | ... |
@@ -426,7 +426,7 @@ static void *thrmgr_worker(void *arg) |
426 | 426 |
void *job_data; |
427 | 427 |
int retval, must_exit = FALSE, stats_inited = FALSE; |
428 | 428 |
struct timespec timeout; |
429 |
- |
|
429 |
+ |
|
430 | 430 |
/* loop looking for work */ |
431 | 431 |
for (;;) { |
432 | 432 |
if (pthread_mutex_lock(&(threadpool->pool_mutex)) != 0) { |