git-svn: trunk@4387
Török Edvin authored on 2008/11/13 03:02:33... | ... |
@@ -1,3 +1,10 @@ |
1 |
+Wed Nov 12 19:03:36 EET 2008 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * clamd/thrmgr.c, unit_tests/check_clamav.c, |
|
4 |
+ unit_tests/check_regex.c: update unit tests to new API. |
|
5 |
+ Initialization order changed, make sure stats_tls_key is |
|
6 |
+ initialized. |
|
7 |
+ |
|
1 | 8 |
Wed Nov 12 17:52:12 EET 2008 (edwin) |
2 | 9 |
------------------------------------ |
3 | 10 |
* contrib/clamdtop/TODO, contrib/clamdtop/clamdtop.c: refactor, minor fixes |
... | ... |
@@ -433,7 +433,9 @@ static const char *IDLE_TASK = "IDLE"; |
433 | 433 |
/* no mutex is needed, we are using thread local variable */ |
434 | 434 |
void thrmgr_setactivetask(const char *filename, const char* command) |
435 | 435 |
{ |
436 |
- struct task_desc *desc = pthread_getspecific(stats_tls_key); |
|
436 |
+ struct task_desc *desc; |
|
437 |
+ pthread_once(&stats_tls_key_once, stats_tls_key_alloc); |
|
438 |
+ desc = pthread_getspecific(stats_tls_key); |
|
437 | 439 |
if(!desc) |
438 | 440 |
return; |
439 | 441 |
desc->filename = filename; |
... | ... |
@@ -447,7 +449,9 @@ void thrmgr_setactivetask(const char *filename, const char* command) |
447 | 447 |
|
448 | 448 |
void thrmgr_setactiveengine(const struct cl_engine *engine) |
449 | 449 |
{ |
450 |
- struct task_desc *desc = pthread_getspecific(stats_tls_key); |
|
450 |
+ struct task_desc *desc; |
|
451 |
+ pthread_once(&stats_tls_key_once, stats_tls_key_alloc); |
|
452 |
+ desc = pthread_getspecific(stats_tls_key); |
|
451 | 453 |
if(!desc) |
452 | 454 |
return; |
453 | 455 |
desc->engine = engine; |
... | ... |
@@ -483,6 +487,7 @@ static void stats_destroy(threadpool_t *pool) |
483 | 483 |
if(pool->tasks == desc) |
484 | 484 |
pool->tasks = desc->nxt; |
485 | 485 |
free(desc); |
486 |
+ pthread_setspecific(stats_tls_key, NULL); |
|
486 | 487 |
} |
487 | 488 |
|
488 | 489 |
static void *thrmgr_worker(void *arg) |
... | ... |
@@ -502,6 +507,7 @@ static void *thrmgr_worker(void *arg) |
502 | 502 |
stats_init(threadpool); |
503 | 503 |
stats_inited = TRUE; |
504 | 504 |
} |
505 |
+ thrmgr_setactiveengine(NULL); |
|
505 | 506 |
thrmgr_setactivetask(NULL, IDLE_TASK); |
506 | 507 |
timeout.tv_sec = time(NULL) + threadpool->idle_timeout; |
507 | 508 |
timeout.tv_nsec = 0; |
... | ... |
@@ -281,10 +281,11 @@ static void psetup_impl(int load2) |
281 | 281 |
{ |
282 | 282 |
FILE *f; |
283 | 283 |
int rc; |
284 |
- rc = cli_initengine(&engine, CL_DB_STDOPT); |
|
285 |
- fail_unless(rc == 0, "cl_initengine"); |
|
284 |
+ engine = cl_engine_new(CL_DB_STDOPT); |
|
285 |
+ fail_unless(!!engine , "cl_engine_new"); |
|
286 | 286 |
|
287 |
- fail_unless(!!engine->phishcheck, "engine->phishcheck"); |
|
287 |
+ phishing_init(engine); |
|
288 |
+ fail_unless(!!engine->phishcheck, "phishing_init"); |
|
288 | 289 |
|
289 | 290 |
rc = init_domainlist(engine); |
290 | 291 |
fail_unless(rc == 0,"init_domainlist"); |
... | ... |
@@ -338,7 +339,7 @@ static void psetup2(void) |
338 | 338 |
static void pteardown(void) |
339 | 339 |
{ |
340 | 340 |
if(engine) { |
341 |
- cl_free(engine); |
|
341 |
+ cl_engine_free(engine); |
|
342 | 342 |
} |
343 | 343 |
engine = NULL; |
344 | 344 |
} |