Browse code

fix mutex handling

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1269 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2005/01/25 01:57:19
Showing 2 changed files
... ...
@@ -1,7 +1,13 @@
1
+Mon Jan 24 17:54:14 CET 2005 (tk)
2
+---------------------------------
3
+  * clamd/thrmgr.c: unlock mutex if thread->state != POOL_VALID in
4
+		    thrmgr_dispatch() (thanks to "Andrey J. Melnikoff
5
+		    (TEMHOTA)" <temnota*kmv.ru>)
6
+
1 7
 Mon Jan 24 13:56:19 GMT 2005 (njh)
2 8
 ----------------------------------
3 9
   * libclamav/message.c:	Some Exploit.IE.CrashSOS were not being caught,
4
-			found by Carsten.Borchardt@drs-systemberatung.de
10
+			found by Carsten.Borchardt*drs-systemberatung.de
5 11
 
6 12
 Sat Jan 22 13:45:42 GMT 2005 (njh)
7 13
 ----------------------------------
... ...
@@ -12,7 +18,7 @@ Sat Jan 22 13:45:42 GMT 2005 (njh)
12 12
 			Redirect stdout and stderr to LogFile, if that is set
13 13
 			--quarantine didn't redirect to the given email address
14 14
 				if --internal was used (reported by N Fung
15
-				<nsfung@yahoo.com>)
15
+				<nsfung*yahoo.com>)
16 16
 
17 17
 Thu Jan 20 01:22:48 CET 2005 (tk)
18 18
 ---------------------------------
... ...
@@ -222,22 +222,26 @@ void *thrmgr_worker(void *arg)
222 222
 int thrmgr_dispatch(threadpool_t *threadpool, void *user_data)
223 223
 {
224 224
 	pthread_t thr_id;
225
-	
225
+
226 226
 	if (!threadpool) {
227 227
 		return FALSE;
228 228
 	}
229
-	
229
+
230 230
 	/* Lock the threadpool */
231 231
 	if (pthread_mutex_lock(&(threadpool->pool_mutex)) != 0) {
232 232
 		logg("!Mutex lock failed\n");
233 233
 		return FALSE;
234 234
 	}
235
-	
235
+
236 236
 	if (threadpool->state != POOL_VALID) {
237
+		if (pthread_mutex_unlock(&(threadpool->pool_mutex)) != 0) {
238
+			logg("!Mutex unlock failed\n");
239
+			return FALSE;
240
+		}
237 241
 		return FALSE;
238 242
 	}
239 243
 	work_queue_add(threadpool->queue, user_data);
240
-	
244
+
241 245
 	if ((threadpool->thr_idle == 0) &&
242 246
 			(threadpool->thr_alive < threadpool->thr_max)) {
243 247
 		/* Start a new thread */
... ...
@@ -249,7 +253,7 @@ int thrmgr_dispatch(threadpool_t *threadpool, void *user_data)
249 249
 		}
250 250
 	}
251 251
 	pthread_cond_signal(&(threadpool->pool_cond));
252
-	
252
+
253 253
 	if (pthread_mutex_unlock(&(threadpool->pool_mutex)) != 0) {
254 254
 		logg("!Mutex unlock failed\n");
255 255
 		return FALSE;