add some missing checks for pthread api calls - bb#384

git-svn: trunk@4004
0.95
aCaB 17 years ago
parent 9c9e55cacd
commit cc4232a3b1
  1. 4
      ChangeLog
  2. 23
      clamd/server-th.c
  3. 7
      clamd/thrmgr.c
  4. 7
      libclamav/mbox.c

@ -1,3 +1,7 @@
Sun Jul 27 23:18:47 CEST 2008 (acab)
------------------------------------
* misc fixes: add some missing checks for pthread api calls (bb#384)
Sun Jul 27 21:35:04 CEST 2008 (acab)
------------------------------------
* 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
if(cfgopt(copt, "ClamukoScanOnAccess")->enabled)
#ifdef CLAMUKO
{
pthread_attr_init(&clamuko_attr);
pthread_attr_setdetachstate(&clamuko_attr, PTHREAD_CREATE_JOINABLE);
tharg = (struct thrarg *) malloc(sizeof(struct thrarg));
if(tharg) {
tharg->copt = copt;
tharg->engine = engine;
tharg->limits = &limits;
tharg->options = options;
pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg);
} else logg("!Not enough memory to start Clamuko\n");
if(!pthread_attr_init(&clamuko_attr)) {
pthread_attr_setdetachstate(&clamuko_attr, PTHREAD_CREATE_JOINABLE);
tharg = (struct thrarg *) malloc(sizeof(struct thrarg));
if(tharg) {
tharg->copt = copt;
tharg->engine = engine;
tharg->limits = &limits;
tharg->options = options;
pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg);
} else logg("!Not enough memory to start Clamuko\n");
} else logg("!attr_init failed, cannot start Clamuko\n");
}
#else
logg("Clamuko is not available.\n");

@ -163,7 +163,12 @@ threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void
threadpool->idle_timeout = idle_timeout;
threadpool->handler = handler;
pthread_mutex_init(&(threadpool->pool_mutex), NULL);
if(pthread_mutex_init(&(threadpool->pool_mutex), NULL)) {
free(threadpool->queue);
free(threadpool);
return NULL;
}
if (pthread_cond_init(&(threadpool->pool_cond), NULL) != 0) {
pthread_mutex_destroy(&(threadpool->pool_mutex));
free(threadpool->queue);

@ -4133,7 +4133,12 @@ do_checkURLs(mbox_ctx *mctx, tag_arguments_t *hrefs)
args[n].url = cli_strdup(url);
args[n].filename = cli_strdup(name);
args[n].depth = 0;
pthread_create(&tid[n], NULL, getURL, &args[n]);
if(pthread_create(&tid[n], NULL, getURL, &args[n])) {
cli_warnmsg("thread creation failed\n");
free(arg.filename);
free(arg.url);
break;
}
#else
arg.url = cli_strdup(url);
arg.dir = dir;

Loading…
Cancel
Save