Browse code

bb#11028 - fixed a deadlock issue with fanotify and logg_mutex

Kevin Lin authored on 2014/06/06 01:20:57
Showing 1 changed files
... ...
@@ -71,6 +71,7 @@ int reload = 0;
71 71
 time_t reloaded_time = 0;
72 72
 pthread_mutex_t reload_mutex = PTHREAD_MUTEX_INITIALIZER;
73 73
 int sighup = 0;
74
+extern pthread_mutex_t logg_mutex;
74 75
 static struct cl_stat dbstat;
75 76
 
76 77
 void *event_wake_recv = NULL;
... ...
@@ -1392,7 +1393,9 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
1392 1392
 #if defined(FANOTIFY) || defined(CLAMAUTH)
1393 1393
 	    if(optget(opts, "ScanOnAccess")->enabled && tharg) {
1394 1394
 		logg("Restarting on-access scan\n");
1395
+		pthread_mutex_lock(&logg_mutex);
1395 1396
 		pthread_kill(fan_pid, SIGUSR1);
1397
+		pthread_mutex_unlock(&logg_mutex);
1396 1398
 		pthread_join(fan_pid, NULL);
1397 1399
 	    }
1398 1400
 #endif
... ...
@@ -1438,7 +1441,9 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
1438 1438
 #if defined(FANOTIFY) || defined(CLAMAUTH)
1439 1439
     if(optget(opts, "ScanOnAccess")->enabled && tharg) {
1440 1440
 	logg("Stopping on-access scan\n");
1441
+	pthread_mutex_lock(&logg_mutex);
1441 1442
 	pthread_kill(fan_pid, SIGUSR1);
1443
+	pthread_mutex_unlock(&logg_mutex);
1442 1444
 	pthread_join(fan_pid, NULL);
1443 1445
     }
1444 1446
 #endif