Patch: optimize gmsgstore wait for die to avoid wakeups
- From: José Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: optimize gmsgstore wait for die to avoid wakeups
- Date: Wed, 30 Sep 2009 11:12:48 +0200
Hi,
Currently, IMAP gmsgstore dies with a timeout of 100 seconds. To check
this timeout, we add a timeout every second that decrease a ticker,
until it gets the timeout. This is, then, causing modest to wakeup (and
wakeup cpu) every second while this wait lasts.
This patch replaces the old timeout handling with a new one that avoids
wakeups unless it's really required.
--
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index de76588..af4bde5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-30 Jose Dapena Paz <jdapena igalia com>
+
+ Don't wake everysecond to check the timeout of IMAP gmsgstore
+
2009-09-25 Carl Simonson <simonsonc gmail com>
The *mm helper helper scripts expect enums to be of the following form:
diff --git a/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c b/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
index 00042a4..f7e2e56 100644
--- a/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
+++ b/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
@@ -257,7 +257,6 @@ camel_imap_folder_init (gpointer object, gpointer klass)
imap_folder->cancel_occurred = FALSE;
imap_folder->gmsgstore = NULL;
- imap_folder->gmsgstore_ticks = 0;
imap_folder->do_push_email = TRUE;
folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_DELETED |
@@ -4641,30 +4640,26 @@ static gboolean
check_gmsgstore_die (gpointer user_data)
{
CamelImapFolder *imap_folder = user_data;
- gboolean retval = TRUE;
if (g_static_rec_mutex_trylock (&gmsgstore_lock))
{
- imap_folder->gmsgstore_ticks--;
- if (imap_folder->gmsgstore_ticks <= 0)
- {
- if (imap_folder->gmsgstore) {
- imap_debug ("Get-Message service dies\n");
- /* camel_imap_store_stop_idle_connect_lock (imap_folder->gmsgstore); */
- camel_service_disconnect (CAMEL_SERVICE (imap_folder->gmsgstore),
- imap_folder->gmsgstore->clean_exit, NULL);
- /* camel_imap_store_connect_unlock_start_idle (imap_folder->gmsgstore); */
- camel_object_unref (CAMEL_OBJECT (imap_folder->gmsgstore));
- imap_folder->gmsgstore = NULL;
- camel_object_unref (imap_folder);
- }
- retval = FALSE;
+ if (imap_folder->gmsgstore) {
+ imap_debug ("Get-Message service dies\n");
+ /* camel_imap_store_stop_idle_connect_lock (imap_folder->gmsgstore); */
+ camel_service_disconnect (CAMEL_SERVICE (imap_folder->gmsgstore),
+ imap_folder->gmsgstore->clean_exit, NULL);
+ /* camel_imap_store_connect_unlock_start_idle (imap_folder->gmsgstore); */
+ camel_object_unref (CAMEL_OBJECT (imap_folder->gmsgstore));
+ imap_folder->gmsgstore = NULL;
+ camel_object_unref (imap_folder);
}
+ imap_folder->gmsgstore_signal = 0;
g_static_rec_mutex_unlock (&gmsgstore_lock);
- } else
- retval = TRUE;
+ } else {
+ imap_folder->gmsgstore_signal = g_timeout_add (1, check_gmsgstore_die, imap_folder);
+ }
- return retval;
+ return FALSE;
}
static CamelImapStore *
@@ -4680,7 +4675,10 @@ create_gmsgstore (CamelImapFolder *imap_folder, gboolean *ctchecker, CamelExcept
if (imap_folder->gmsgstore) {
imap_debug ("Get-Message service reused\n");
store = imap_folder->gmsgstore;
- imap_folder->gmsgstore_ticks = store->getsrv_sleep;
+ if (imap_folder->gmsgstore_signal > 0) {
+ g_source_remove (imap_folder->gmsgstore_signal);
+ imap_folder->gmsgstore_signal = g_timeout_add_seconds (store->getsrv_sleep, check_gmsgstore_die, imap_folder);
+ }
*ctchecker=FALSE;
} else
{
@@ -4744,7 +4742,6 @@ create_gmsgstore (CamelImapFolder *imap_folder, gboolean *ctchecker, CamelExcept
camel_operation_end (NULL);
imap_folder->gmsgstore = store;
- imap_folder->gmsgstore_ticks = store->getsrv_sleep;;
*ctchecker=TRUE;
}
@@ -4757,16 +4754,21 @@ stop_gmsgstore (CamelImapFolder *imap_folder, gboolean ctchecker, gboolean quick
{
if (quick) {
imap_folder->gmsgstore->clean_exit = FALSE;
- imap_folder->gmsgstore_ticks = 0;
if (ctchecker) {
- camel_object_ref (imap_folder);
+ if (imap_folder->gmsgstore_signal > 0)
+ g_source_remove (imap_folder->gmsgstore_signal);
+ else
+ camel_object_ref (imap_folder);
imap_folder->gmsgstore_signal = g_timeout_add (1,
check_gmsgstore_die, imap_folder);
}
} else {
if (ctchecker) {
- camel_object_ref (imap_folder);
- imap_folder->gmsgstore_signal = g_timeout_add (1000,
+ if (imap_folder->gmsgstore_signal > 0)
+ g_source_remove (imap_folder->gmsgstore_signal);
+ else
+ camel_object_ref (imap_folder);
+ imap_folder->gmsgstore_signal = g_timeout_add_seconds (imap_folder->gmsgstore->getsrv_sleep,
check_gmsgstore_die, imap_folder);
}
}
@@ -4781,7 +4783,6 @@ stop_gmsgstore_from_idle (CamelImapFolder *imap_folder)
g_static_rec_mutex_lock (&gmsgstore_lock); /* A */
if (imap_folder->gmsgstore) {
imap_folder->gmsgstore->clean_exit = FALSE;
- imap_folder->gmsgstore_ticks = 0;
camel_object_ref (imap_folder);
imap_folder->gmsgstore_signal = g_timeout_add (1,
check_gmsgstore_die, imap_folder);
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]