[Mimedefang] [PATCH] to fix the issues with FreeBSD and clamd0.90
Martin Blapp
mb at imp.ch
Sat Mar 10 06:27:01 EST 2007
Hi all,
Please use this patch until the underlaying problem has been
fixed. There seems to be a race in cli_mbox() which deadlocks
some workers until the maximum threads count is reached. The
effects are well known :-)
--
Martin
--- libclamav/scanners.c Tue Feb 13 02:06:28 2007
+++ libclamav/scanners.c Sat Mar 10 12:00:16 2007
@@ -38,6 +38,9 @@
#include <netinet/in.h>
#endif
+# include <pthread.h>
+static pthread_mutex_t extractmail_mutex = PTHREAD_MUTEX_INITIALIZER;
+
#if HAVE_MMAP
#if HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -1652,12 +1655,16 @@
/*
* Extract the attachments into the temporary directory
*/
+ pthread_mutex_lock(&extractmail_mutex);
if((ret = cli_mbox(dir, desc, ctx))) {
- if(!cli_leavetemps_flag)
+ if(!cli_leavetemps_flag) {
+ pthread_mutex_unlock(&extractmail_mutex);
cli_rmdirs(dir);
+ }
free(dir);
return ret;
}
+ pthread_mutex_unlock(&extractmail_mutex);
ret = cli_scandir(dir, ctx);
Martin Blapp, <mb at imp.ch> <mbr at FreeBSD.org>
------------------------------------------------------------------
ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH
Phone: +41 61 826 93 00 Fax: +41 61 826 93 01
PGP: <finger -l mbr at freebsd.org>
PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E
------------------------------------------------------------------
More information about the MIMEDefang
mailing list