git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@100 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2003/11/06 00:44:33... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Wed Nov 5 15:43:15 GMT 2003 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamav-milter: tidied up the calls to pthread_cond_timedwait |
|
4 |
+ |
|
1 | 5 |
Wed Nov 5 11:35:22 CET 2003 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* clamscan.1: fixed a typo (thanks to Damien Curtain) |
... | ... |
@@ -141,6 +141,8 @@ Changes |
141 | 141 |
0.60n 22/10/03 Call pthread_cont_broadcast more often |
142 | 142 |
0.60o 31/10/03 Optionally accept all mails if scanning procedure |
143 | 143 |
fails (Joe Talbott <josepht@cstone.net>) |
144 |
+0.60p 5/11/03 Only call mutex_unlock when max_children is set |
|
145 |
+ Tidy up the call to pthread_cond_timedwait |
|
144 | 146 |
|
145 | 147 |
BUG REPORTS |
146 | 148 |
|
... | ... |
@@ -146,9 +146,14 @@ |
146 | 146 |
* 0.60n 22/10/03 Call pthread_cont_broadcast more often |
147 | 147 |
* 0.60o 31/10/03 Optionally accept all mails if scanning procedure |
148 | 148 |
* fails (Joe Talbott <josepht@cstone.net>) |
149 |
+ * 0.60p 5/11/03 Only call mutex_unlock when max_children is set |
|
150 |
+ * Tidy up the call to pthread_cond_timedwait |
|
149 | 151 |
* |
150 | 152 |
* Change History: |
151 | 153 |
* $Log: clamav-milter.c,v $ |
154 |
+ * Revision 1.17 2003/11/05 15:41:11 nigelhorne |
|
155 |
+ * Tidyup pthread_cond_timewait call |
|
156 |
+ * |
|
152 | 157 |
* Revision 1.16 2003/10/31 13:33:40 nigelhorne |
153 | 158 |
* Added dont scan on error flag |
154 | 159 |
* |
... | ... |
@@ -183,9 +188,9 @@ |
183 | 183 |
* Added -f flag use MaxThreads if --max-children not set |
184 | 184 |
* |
185 | 185 |
*/ |
186 |
-static char const rcsid[] = "$Id: clamav-milter.c,v 1.16 2003/10/31 13:33:40 nigelhorne Exp $"; |
|
186 |
+static char const rcsid[] = "$Id: clamav-milter.c,v 1.17 2003/11/05 15:41:11 nigelhorne Exp $"; |
|
187 | 187 |
|
188 |
-#define CM_VERSION "0.60o" |
|
188 |
+#define CM_VERSION "0.60p" |
|
189 | 189 |
|
190 | 190 |
/*#define CONFDIR "/usr/local/etc"*/ |
191 | 191 |
|
... | ... |
@@ -825,7 +830,12 @@ clamfi_envfrom(SMFICTX *ctx, char **argv) |
825 | 825 |
|
826 | 826 |
pthread_mutex_lock(&n_children_mutex); |
827 | 827 |
|
828 |
- while((n_children >= max_children) && (rc != ETIMEDOUT)) { |
|
828 |
+ /* |
|
829 |
+ * Not a while since sendmail doesn't like it if we |
|
830 |
+ * take too long replying. Effectively this means that |
|
831 |
+ * max_children is more of a hint than a rule |
|
832 |
+ */ |
|
833 |
+ if(n_children >= max_children) { |
|
829 | 834 |
struct timeval now; |
830 | 835 |
struct timespec timeout; |
831 | 836 |
struct timezone tz; |
... | ... |
@@ -848,41 +858,9 @@ clamfi_envfrom(SMFICTX *ctx, char **argv) |
848 | 848 |
syslog(LOG_NOTICE, |
849 | 849 |
"hit max-children limit (%u >= %u): waiting for some to exit", |
850 | 850 |
n_children, max_children); |
851 |
- rc = pthread_cond_timedwait(&n_children_cond, &n_children_mutex, &timeout); |
|
852 |
-#ifdef CL_DEBUG |
|
853 |
- if(rc != 0) { |
|
854 |
-#else |
|
855 |
- if((rc != 0) && use_syslog) { |
|
856 |
-#endif |
|
857 |
- char message[64]; |
|
858 |
- |
|
859 |
-#ifdef TARGET_OS_SOLARIS /* no strerror_r */ |
|
860 |
- snprintf(message, sizeof(message), "pthread_cond_timedwait: %s", strerror(rc)); |
|
861 |
-#else |
|
862 |
- if(strerror_r(rc, buf, sizeof(buf)) == NULL) |
|
863 |
- switch(rc) { |
|
864 |
- case EINTR: |
|
865 |
- strcpy(buf, "Interrupted system call"); |
|
866 |
- break; |
|
867 |
- case ETIMEDOUT: |
|
868 |
- strcpy(buf, "Timedout"); |
|
869 |
- break; |
|
870 |
- default: |
|
871 |
- strcpy(buf, "Unknown error"); |
|
872 |
- break; |
|
873 |
- } |
|
874 |
- snprintf(message, sizeof(message), "pthread_cond_timedwait: (rc = %d) %s", rc, buf); |
|
875 |
-#endif |
|
876 |
- if(use_syslog) { |
|
877 |
- if(rc == ETIMEDOUT) |
|
878 |
- syslog(LOG_NOTICE, message); |
|
879 |
- else |
|
880 |
- syslog(LOG_ERR, message); |
|
881 |
- } |
|
882 |
-#ifdef CL_DEBUG |
|
883 |
- puts(message); |
|
884 |
-#endif |
|
885 |
- } |
|
851 |
+ do |
|
852 |
+ rc = pthread_cond_timedwait(&n_children_cond, &n_children_mutex, &timeout); |
|
853 |
+ while(rc != ETIMEDOUT); |
|
886 | 854 |
} |
887 | 855 |
n_children++; |
888 | 856 |
|
... | ... |
@@ -1311,7 +1289,8 @@ clamfi_abort(SMFICTX *ctx) |
1311 | 1311 |
* |
1312 | 1312 |
* TODO: There *must* be a tidier way of doing this! |
1313 | 1313 |
*/ |
1314 |
- (void)pthread_mutex_unlock(&n_children_mutex); |
|
1314 |
+ if(max_children > 0) |
|
1315 |
+ (void)pthread_mutex_unlock(&n_children_mutex); |
|
1315 | 1316 |
|
1316 | 1317 |
clamfi_cleanup(ctx); |
1317 | 1318 |
|
... | ... |
@@ -1402,8 +1381,7 @@ clamfi_cleanup(SMFICTX *ctx) |
1402 | 1402 |
#ifdef CL_DEBUG |
1403 | 1403 |
puts("pthread_cond_broadcast"); |
1404 | 1404 |
#endif |
1405 |
- if(pthread_cond_broadcast(&n_children_cond) < 0) |
|
1406 |
- perror("pthread_cond_broadcast"); |
|
1405 |
+ pthread_cond_broadcast(&n_children_cond); |
|
1407 | 1406 |
#ifdef CL_DEBUG |
1408 | 1407 |
printf("<n_children = %d\n", n_children); |
1409 | 1408 |
#endif |