git-svn: trunk@4004
aCaB authored on 2008/07/28 06:38:35... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sun Jul 27 23:18:47 CEST 2008 (acab) |
|
2 |
+------------------------------------ |
|
3 |
+ * misc fixes: add some missing checks for pthread api calls (bb#384) |
|
4 |
+ |
|
1 | 5 |
Sun Jul 27 21:35:04 CEST 2008 (acab) |
2 | 6 |
------------------------------------ |
3 | 7 |
* libclamav/unzip: workaround for non-mmap builds (bb#900) |
... | ... |
@@ -476,17 +476,18 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigne |
476 | 476 |
if(cfgopt(copt, "ClamukoScanOnAccess")->enabled) |
477 | 477 |
#ifdef CLAMUKO |
478 | 478 |
{ |
479 |
- pthread_attr_init(&clamuko_attr); |
|
480 |
- pthread_attr_setdetachstate(&clamuko_attr, PTHREAD_CREATE_JOINABLE); |
|
481 |
- |
|
482 |
- tharg = (struct thrarg *) malloc(sizeof(struct thrarg)); |
|
483 |
- if(tharg) { |
|
484 |
- tharg->copt = copt; |
|
485 |
- tharg->engine = engine; |
|
486 |
- tharg->limits = &limits; |
|
487 |
- tharg->options = options; |
|
488 |
- pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg); |
|
489 |
- } else logg("!Not enough memory to start Clamuko\n"); |
|
479 |
+ if(!pthread_attr_init(&clamuko_attr)) { |
|
480 |
+ pthread_attr_setdetachstate(&clamuko_attr, PTHREAD_CREATE_JOINABLE); |
|
481 |
+ |
|
482 |
+ tharg = (struct thrarg *) malloc(sizeof(struct thrarg)); |
|
483 |
+ if(tharg) { |
|
484 |
+ tharg->copt = copt; |
|
485 |
+ tharg->engine = engine; |
|
486 |
+ tharg->limits = &limits; |
|
487 |
+ tharg->options = options; |
|
488 |
+ pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg); |
|
489 |
+ } else logg("!Not enough memory to start Clamuko\n"); |
|
490 |
+ } else logg("!attr_init failed, cannot start Clamuko\n"); |
|
490 | 491 |
} |
491 | 492 |
#else |
492 | 493 |
logg("Clamuko is not available.\n"); |
... | ... |
@@ -163,7 +163,12 @@ threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void |
163 | 163 |
threadpool->idle_timeout = idle_timeout; |
164 | 164 |
threadpool->handler = handler; |
165 | 165 |
|
166 |
- pthread_mutex_init(&(threadpool->pool_mutex), NULL); |
|
166 |
+ if(pthread_mutex_init(&(threadpool->pool_mutex), NULL)) { |
|
167 |
+ free(threadpool->queue); |
|
168 |
+ free(threadpool); |
|
169 |
+ return NULL; |
|
170 |
+ } |
|
171 |
+ |
|
167 | 172 |
if (pthread_cond_init(&(threadpool->pool_cond), NULL) != 0) { |
168 | 173 |
pthread_mutex_destroy(&(threadpool->pool_mutex)); |
169 | 174 |
free(threadpool->queue); |
... | ... |
@@ -4133,7 +4133,12 @@ do_checkURLs(mbox_ctx *mctx, tag_arguments_t *hrefs) |
4133 | 4133 |
args[n].url = cli_strdup(url); |
4134 | 4134 |
args[n].filename = cli_strdup(name); |
4135 | 4135 |
args[n].depth = 0; |
4136 |
- pthread_create(&tid[n], NULL, getURL, &args[n]); |
|
4136 |
+ if(pthread_create(&tid[n], NULL, getURL, &args[n])) { |
|
4137 |
+ cli_warnmsg("thread creation failed\n"); |
|
4138 |
+ free(arg.filename); |
|
4139 |
+ free(arg.url); |
|
4140 |
+ break; |
|
4141 |
+ } |
|
4137 | 4142 |
#else |
4138 | 4143 |
arg.url = cli_strdup(url); |
4139 | 4144 |
arg.dir = dir; |