[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

Török Edvin edwin at clamav.net
Sun Apr 4 01:18:20 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 1514794c4902ce35be9b2438c817b99ac263ec66
Author: Török Edvin <edwin at clamav.net>
Date:   Mon Feb 1 14:38:36 2010 +0200

    make STATS a non-bulk command (bb #1732).
    
    This is needed to allow clamdtop to watch in realtime what is happening in
    clamd, otherwise STATS would always lag behind 50 other multiscan commands.

diff --git a/clamd/scanner.c b/clamd/scanner.c
index 24b331c..ddb8572 100644
--- a/clamd/scanner.c
+++ b/clamd/scanner.c
@@ -163,7 +163,7 @@ int scan_callback(struct stat *sb, char *filename, const char *msg, enum cli_ftw
 		pthread_mutex_lock(&reload_mutex);
 		client_conn->engine_timestamp = reloaded_time;
 		pthread_mutex_unlock(&reload_mutex);
-		if(!thrmgr_group_dispatch(scandata->thr_pool, scandata->group, client_conn)) {
+		if(!thrmgr_group_dispatch(scandata->thr_pool, scandata->group, client_conn, 1)) {
 		    logg("!thread dispatch failed\n");
 		    free(filename);
 		    return CL_EMEM;
diff --git a/clamd/session.c b/clamd/session.c
index 4dbad16..8fa2f3d 100644
--- a/clamd/session.c
+++ b/clamd/session.c
@@ -368,6 +368,7 @@ int command(client_conn_t *conn, int *virus)
 static int dispatch_command(client_conn_t *conn, enum commands cmd, const char *argument)
 {
     int ret = 0;
+    int bulk;
     client_conn_t *dup_conn = (client_conn_t *) malloc(sizeof(struct client_conn_tag));
 
     if(!dup_conn) {
@@ -382,6 +383,7 @@ static int dispatch_command(client_conn_t *conn, enum commands cmd, const char *
 	return -1;
     }
     dup_conn->scanfd = -1;
+    bulk = 1;
     switch (cmd) {
 	case COMMAND_FILDES:
 	    if (conn->scanfd == -1) {
@@ -407,10 +409,14 @@ static int dispatch_command(client_conn_t *conn, enum commands cmd, const char *
 	    break;
 	case COMMAND_STREAM:
 	case COMMAND_STATS:
+	    /* not a scan command, don't queue to bulk */
+	    bulk = 0;
 	    /* just dispatch the command */
 	    break;
     }
-    if(!ret && !thrmgr_group_dispatch(dup_conn->thrpool, dup_conn->group, dup_conn)) {
+    if (!dup_conn->group)
+	bulk = 0;
+    if(!ret && !thrmgr_group_dispatch(dup_conn->thrpool, dup_conn->group, dup_conn, bulk)) {
 	logg("!thread dispatch failed\n");
 	ret = -2;
     }
diff --git a/clamd/thrmgr.c b/clamd/thrmgr.c
index 65e8b5f..8c920e2 100644
--- a/clamd/thrmgr.c
+++ b/clamd/thrmgr.c
@@ -745,7 +745,7 @@ int thrmgr_dispatch(threadpool_t *threadpool, void *user_data)
     return thrmgr_dispatch_internal(threadpool, user_data, 0);
 }
 
-int thrmgr_group_dispatch(threadpool_t *threadpool, jobgroup_t *group, void *user_data)
+int thrmgr_group_dispatch(threadpool_t *threadpool, jobgroup_t *group, void *user_data, int bulk)
 {
     int ret;
     if (group) {
@@ -754,7 +754,7 @@ int thrmgr_group_dispatch(threadpool_t *threadpool, jobgroup_t *group, void *use
 	logg("$THRMGR: active jobs for %p: %d\n", group, group->jobs);
 	pthread_mutex_unlock(&group->mutex);
     }
-    if (!(ret = thrmgr_dispatch_internal(threadpool, user_data, group ? 1 : 0)) && group) {
+    if (!(ret = thrmgr_dispatch_internal(threadpool, user_data, bulk)) && group) {
 	pthread_mutex_lock(&group->mutex);
 	group->jobs--;
 	logg("$THRMGR: active jobs for %p: %d\n", group, group->jobs);
diff --git a/clamd/thrmgr.h b/clamd/thrmgr.h
index ddf575f..109b4e1 100644
--- a/clamd/thrmgr.h
+++ b/clamd/thrmgr.h
@@ -99,7 +99,7 @@ enum thrmgr_exit {
 threadpool_t *thrmgr_new(int max_threads, int idle_timeout, int max_queue, void (*handler)(void *));
 void thrmgr_destroy(threadpool_t *threadpool);
 int thrmgr_dispatch(threadpool_t *threadpool, void *user_data);
-int thrmgr_group_dispatch(threadpool_t *threadpool, jobgroup_t *group, void *user_data);
+int thrmgr_group_dispatch(threadpool_t *threadpool, jobgroup_t *group, void *user_data, int bulk);
 void thrmgr_group_waitforall(jobgroup_t *group, unsigned *ok, unsigned *error, unsigned *total);
 int thrmgr_group_finished(jobgroup_t *group, enum thrmgr_exit exitc);
 int thrmgr_group_need_terminate(jobgroup_t *group);

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list