Yes, my debug results show that it's messageToFileblob(), which is itself a complex function. Maybe a race with temporary files ? Locking the codepath to messageToFileblob fixes the problem too ... I'm still working on it ...

Ok. After hours if debugging I found that this part of the export code is
responsable but I've got no idea why. If this part is serialised clamd works best with freebsds libpthread.so

--- libclamav/message.c Mon Feb 12 21:58:30 2007
+++ libclamav/message.c Sun Mar 11 17:30:33 2007
@@ -89,6 +89,8 @@
 static char    *rfc2231(const char *in);
 static int     simil(const char *str1, const char *str2);

+static pthread_mutex_t export_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 /*
  * These maps are ordered in decreasing likelyhood of their appearance
  * in an e-mail. Probably these should be in a table...
@@ -1471,6 +1475,9 @@
                }

                size = 0;
+#ifdef  CL_THREAD_SAFE
+               pthread_mutex_lock(&export_mutex);
+#endif
                do {
                        unsigned char smallbuf[1024];
                        unsigned char *uptr, *data;
@@ -1529,6 +1536,9 @@
                                t_line->t_line = NULL;
                        }
                } while((t_line = t_line->t_next) != NULL);
+#ifdef  CL_THREAD_SAFE
+               pthread_mutex_unlock(&export_mutex);
+#endif

                cli_dbgmsg("Exported %lu bytes using enctype %d\n",
                        (unsigned long)size, enctype);
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net

Reply via email to