From 4b31f7bcf438461cf9dadae703729c178a8ffee0 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Wed, 20 Jul 2005 16:50:43 +0000 Subject: [PATCH] 2005-07-20 [colin] 1.9.12cvs87 * src/folder.c * src/textview.c Gcc 2.9x compilation fixes, thanks to Darko * src/plugins/clamav/clamav_plugin.c Little optimisation: load virus database only once * src/plugins/spamassassin/spamassassin.c Big optimisation: filtering one mail took at least 1 second, now it takes at least 50ms. Doesn't speed up spamassassin itself, but should already be much more tolerable. --- ChangeLog-gtk2.claws | 12 ++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/folder.c | 2 +- src/plugins/clamav/clamav_plugin.c | 31 ++++++++++++------------- src/plugins/spamassassin/spamassassin.c | 2 +- src/textview.c | 10 ++++---- 7 files changed, 36 insertions(+), 24 deletions(-) diff --git a/ChangeLog-gtk2.claws b/ChangeLog-gtk2.claws index dd5caa797..06ea27e46 100644 --- a/ChangeLog-gtk2.claws +++ b/ChangeLog-gtk2.claws @@ -1,3 +1,15 @@ +2005-07-20 [colin] 1.9.12cvs87 + + * src/folder.c + * src/textview.c + Gcc 2.9x compilation fixes, thanks to Darko + * src/plugins/clamav/clamav_plugin.c + Little optimisation: load virus database only once + * src/plugins/spamassassin/spamassassin.c + Big optimisation: filtering one mail took at least 1 second, + now it takes at least 50ms. Doesn't speed up spamassassin + itself, but should already be much more tolerable. + 2005-07-20 [colin] 1.9.12cvs86 * src/summaryview.c diff --git a/PATCHSETS b/PATCHSETS index 666b178dd..f622e8de0 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -681,3 +681,4 @@ ( cvs diff -u -r 1.654.2.718 -r 1.654.2.719 configure.ac; cvs diff -u -r 1.8.2.3 -r 1.8.2.4 src/plugins/Makefile.am; diff -u /dev/null src/plugins/pgpinline/.cvsignore; diff -u /dev/null src/plugins/pgpinline/Makefile.am; diff -u /dev/null src/plugins/pgpinline/pgpinline.c; diff -u /dev/null src/plugins/pgpinline/pgpinline.deps; diff -u /dev/null src/plugins/pgpinline/pgpinline.h; diff -u /dev/null src/plugins/pgpinline/plugin.c; ) > 1.9.12cvs84.patchset ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/pgpinline/plugin.c; ) > 1.9.12cvs85.patchset ( cvs diff -u -r 1.395.2.96 -r 1.395.2.97 src/summaryview.c; ) > 1.9.12cvs86.patchset +( cvs diff -u -r 1.213.2.41 -r 1.213.2.42 src/folder.c; cvs diff -u -r 1.96.2.64 -r 1.96.2.65 src/textview.c; cvs diff -u -r 1.13.2.6 -r 1.13.2.7 src/plugins/clamav/clamav_plugin.c; cvs diff -u -r 1.18.2.7 -r 1.18.2.8 src/plugins/spamassassin/spamassassin.c; ) > 1.9.12cvs87.patchset diff --git a/configure.ac b/configure.ac index 3e002ac72..4194d3566 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=12 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=86 +EXTRA_VERSION=87 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/folder.c b/src/folder.c index 7ba9420b7..baf243d85 100644 --- a/src/folder.c +++ b/src/folder.c @@ -2766,9 +2766,9 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour relation); } for (l = msglist; l != NULL; l = g_slist_next(l)) { + GTuples *tuples; msginfo = (MsgInfo *) l->data; item = msginfo->folder; - GTuples *tuples; tuples = g_relation_select(relation, msginfo, 0); num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1)); diff --git a/src/plugins/clamav/clamav_plugin.c b/src/plugins/clamav/clamav_plugin.c index 482464b39..488fbaf9c 100644 --- a/src/plugins/clamav/clamav_plugin.c +++ b/src/plugins/clamav/clamav_plugin.c @@ -60,11 +60,12 @@ static PrefParam param[] = { {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} }; +static struct cl_node *cl_database; struct scan_parameters { gboolean is_infected; - struct cl_node *root; struct cl_limits limits; + struct cl_node *root; gboolean scan_archive; }; @@ -104,7 +105,6 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data) MsgInfo *msginfo = mail_filtering_data->msginfo; MimeInfo *mimeinfo; - int ret, no = 0; struct scan_parameters params; if (!config.clamav_enable) @@ -118,7 +118,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data) message_callback(_("ClamAV: scanning message...")); params.is_infected = FALSE; - params.root = NULL; + params.root = cl_database; params.limits.maxfiles = 1000; /* max files */ params.limits.maxfilesize = config.clamav_max_size * 1048576; /* maximum archived file size */ @@ -127,15 +127,6 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data) if (config.clamav_enable_arc) params.scan_archive = TRUE; - if ((ret = cl_loaddbdir(cl_retdbdir(), ¶ms.root, &no))) { - debug_print("cl_loaddbdir: %s\n", cl_strerror(ret)); - return FALSE; - } - - debug_print("Database loaded (containing in total %d signatures)\n", no); - - cl_buildtrie(params.root); - g_node_traverse(mimeinfo->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, scan_func, ¶ms); if (params.is_infected) { @@ -154,7 +145,6 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data) } } - cl_freetrie(params.root); procmime_mimeinfo_free_all(mimeinfo); return params.is_infected; @@ -196,7 +186,7 @@ void clamav_set_message_callback(MessageCallback callback) gint plugin_init(gchar **error) { gchar *rcpath; - + int no, ret; if ((sylpheed_get_version() > VERSION_NUMERIC)) { *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with"); return -1; @@ -217,7 +207,16 @@ gint plugin_init(gchar **error) rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL); prefs_read_config(param, "ClamAV", rcpath, NULL); g_free(rcpath); - + + if ((ret = cl_loaddbdir(cl_retdbdir(), &cl_database, &no)) != 0) { + debug_print("cl_loaddbdir: %s\n", cl_strerror(ret)); + return -1; + } + + debug_print("Database loaded (containing in total %d signatures)\n", no); + + cl_buildtrie(cl_database); + debug_print("ClamAV plugin loaded\n"); return 0; @@ -228,7 +227,7 @@ void plugin_done(void) { hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id); g_free(config.clamav_save_folder); - + cl_freetrie(cl_database); debug_print("ClamAV plugin unloaded\n"); } diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c index c35607158..13e484fd9 100644 --- a/src/plugins/spamassassin/spamassassin.c +++ b/src/plugins/spamassassin/spamassassin.c @@ -195,7 +195,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data) running |= CHILD_RUNNING; - g_timeout_add(1000, timeout_func, &running); + g_timeout_add(50, timeout_func, &running); running |= TIMEOUT_RUNNING; while(running & CHILD_RUNNING) { diff --git a/src/textview.c b/src/textview.c index ac22ffec6..09c59dc35 100644 --- a/src/textview.c +++ b/src/textview.c @@ -1160,11 +1160,6 @@ static void textview_make_clickable_parts(TextView *textview, GtkTextIter iter; gchar *mybuf = g_strdup(linebuf); - if (!g_utf8_validate(linebuf, -1, NULL)) { - mybuf = g_malloc(strlen(linebuf)*2 +1); - conv_localetodisp(mybuf, strlen(linebuf)*2 +1, linebuf); - } - /* parse table - in order of priority */ struct table { const gchar *needle; /* token */ @@ -1201,6 +1196,11 @@ static void textview_make_clickable_parts(TextView *textview, struct txtpos *next; /* next */ } head = {NULL, NULL, 0, NULL}, *last = &head; + if (!g_utf8_validate(linebuf, -1, NULL)) { + mybuf = g_malloc(strlen(linebuf)*2 +1); + conv_localetodisp(mybuf, strlen(linebuf)*2 +1, linebuf); + } + gtk_text_buffer_get_end_iter(buffer, &iter); /* parse for clickable parts, and build a list of begin and end positions */ -- 2.25.1