List Info

Thread: to fix the issues with FreeBSD and clamd0.90




to fix the issues with FreeBSD and clamd0.90
country flaguser name
Switzerland
2007-03-10 05:27:01
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, <mbimp.ch> <mbrFreeBSD.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 mbrfreebsd.org>
PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22
D300 551E
------------------------------------------------------------
------
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in
the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpengu
in.com
MIMEDefang mailing list MIMEDefanglists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mime
defang

Re: to fix the issues with FreeBSD and clamd0.90
country flaguser name
Switzerland
2007-03-10 07:11:41
And here the race window is even more narrowed down ...

--- libclamav/mbox.c.orig	Tue Feb 13 14:06:57 2007
+++ libclamav/mbox.c	Sat Mar 10 14:09:09 2007
 -413,6
+413,7 

  #ifdef	CL_THREAD_SAFE
  static	pthread_mutex_t	tables_mutex =
PTHREAD_MUTEX_INITIALIZER;
+static  pthread_mutex_t body_mutex =
PTHREAD_MUTEX_INITIALIZER;
  #endif

  #ifndef	O_BINARY
 -1494,6
+1495,7 
  		/*
  		 * Write out the last entry in the mailbox
  		 */
+		pthread_mutex_lock(&body_mutex);
  		if((retcode == CL_SUCCESS) &&
messageGetBody(body)) {
  			messageSetCTX(body, ctx);
  			switch(parseEmailBody(body, NULL, &mctx, 0)) {
 -1505,6
+1507,7 
  					break;
  			}
  		}
+		pthread_mutex_unlock(&body_mutex);

  		/*
  		 * Tidy up and quit

Martin Blapp, <mbimp.ch> <mbrFreeBSD.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 mbrfreebsd.org>
PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22
D300 551E
------------------------------------------------------------
------

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in
the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpengu
in.com
MIMEDefang mailing list MIMEDefanglists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mime
defang

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )