While testing the behavior of clamav-milter to see what would happen if
max-children was reached, I discovered a bug.
Apparently it is supposed to wait for a thread to become available, or
for 60 seconds to pass, whichever comes sooner. Instead, it waits for
60 seconds *even if* a thread becomes available. I expect this is
probably a bug.
Looking to the code, the wait is performed by:
do
rc = pthread_cond_timedwait(&n_children_cond, &n_children_mutex, &timeout);
while(rc != ETIMEDOUT);
The pthread_cond_timedwait tells it to wait until n_children_cond is
signaled, or until timeout is reached. Then it will regain the lock on
n_children_mutex.
But the while(rc != ETIMEDOUT) tells it to repeat that loop UNLESS it
timed out. So if pthread_cond_timedwait exits successfully, due
n_children being decremented and n_children_cond being flagged, it will
just go back into the loop!
The fix is pretty trivial: change the while() clause to read:
while(n_children >= max_children && rc != ETIMEDOUT);
(It's on line 1689 of clamav-milter/clamav-milter.c if you're using
clamav-milter 0.70j that was part of clamav-0.70.) I've tested this and
it seems to work for me. Gotta love patches that change less than one
line. ;)
Disclaimer: use this patch at your own risk. Everything I know about
pthreads was learned in the past 2-3 hours using Google and manpages.
Damian Menscher
--
-=#| Physics Grad Student & SysAdmin @ U Illinois Urbana-Champaign |#=-
-=#| 488 LLP, 1110 W. Green St, Urbana, IL 61801 Ofc:(217)333-0038 |#=-
-=#| <[EMAIL PROTECTED]> www.uiuc.edu/~menscher/ Fax:(217)333-9819 |#=-
-=#| The above opinions are not necessarily those of my employers: |#=-
-=#| UIUC CITES Security Group || Beckman Imaging Technology Group |#=-
-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
Clamav-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/clamav-users