Re: [PATCH] typo in the idle_sleep comment



El jue, 06-11-2008 a las 19:58 +0100, Philip Van Hoof escribió:
> José, can you pick this up?
> 
> It's IDLE code ;-)
> 
> Note that the ideal IDLE sleep time is 27 minutes as default, indeed.
> 
> That's because most IMAP servers have a timeout of 30 minutes.

	Yes, it's interesting, as this timeout of 6.75 minutes has been there
for more than a year. I assumed that it was there for an special reason
(you know, IMAP, standards and implementations unfortunately don't match
always).

	As discussed in IRC, it seems a typo. For avoiding future problems, I'm
sending this patch to clarify the default times and ticks for IDLE
implementation. It should set again 28 minutes, but also show clearly
the way it's calculated. It should also fix the idle delay parameter
processing.

Changelog would be:
* Specify with defines the IDLE tick time (time between iterations in
  idle loop) and IDLE default delay (time between IDLE/DONE cycles if no
  event happens).
* Fix the IDLE delay account parameter to take into account the tick
  time.


-- 
José Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c	(revisión: 3796)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c	(copia de trabajo)
@@ -485,7 +485,7 @@
 	imap_store->dontdistridlehack = FALSE;
 
 	imap_store->idle_sleep_set = FALSE;
-	imap_store->idle_sleep = 810; /* default of 27m */
+	imap_store->idle_sleep = IDLE_DEFAULT_SLEEP_TIME * (1000000/IDLE_TICK_TIME);
 	imap_store->getsrv_sleep = 100; /* default of 100s */
 
 	imap_store->in_idle = FALSE;
@@ -1405,11 +1405,12 @@
 	if (ex)
 		camel_exception_clear (ex);
 
+	/* idle_delay is in seconds, so we have to adjust it to the tick */
 	if ((idle_sleep = camel_url_get_param (service->url, "idle_delay")))
 	{
 		int tmp = atoi (idle_sleep);
 		if (tmp != -1) {
-			CAMEL_IMAP_STORE (service)->idle_sleep = tmp;
+			CAMEL_IMAP_STORE (service)->idle_sleep = tmp * (1000000 / IDLE_TICK_TIME);
 			CAMEL_IMAP_STORE (service)->idle_sleep_set = TRUE;
 		}
 	}
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c	(revisión: 3796)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c	(copia de trabajo)
@@ -4222,7 +4222,7 @@
 		 * for this usleep() and cnt stuff. */
 
 		if (my_cont)
-			usleep (500000);
+			usleep (IDLE_TICK_TIME);
 
 		cnt++;
 	}
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store-priv.h
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store-priv.h	(revisión: 3796)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store-priv.h	(copia de trabajo)
@@ -27,6 +27,14 @@
 
 G_BEGIN_DECLS
 
+/* This is the tick time for IDLE loop, the time we sleep in microseconds */
+#define IDLE_TICK_TIME 500000
+
+/* Default sleep time in seconds for IDLE for sending DONE and IDLE again to avoid
+ * TCP timeouts. As IMAP recommends 30 minutes, and we get some processing between
+ * each tick, we set 28 minutes */
+#define IDLE_DEFAULT_SLEEP_TIME 28*60
+
 void _camel_imap_store_current_folder_finalize (CamelObject *stream, gpointer event_data, gpointer user_data);
 void _camel_imap_store_old_folder_finalize (CamelObject *stream, gpointer event_data, gpointer user_data);
 void _camel_imap_store_last_folder_finalize (CamelObject *stream, gpointer event_data, gpointer user_data);
Index: libtinymail-camel/tny-camel-account.c
===================================================================
--- libtinymail-camel/tny-camel-account.c	(revisión: 3796)
+++ libtinymail-camel/tny-camel-account.c	(copia de trabajo)
@@ -471,7 +471,7 @@
  * pending events for the IDLE state. This improve responsibility of the Push 
  * E-mail and expunge events, although it will cause a little bit more continuous
  * bandwidth consumption (each delayth second). For example idle_delay=20. The
- * defualt value is 20.
+ * defualt value is 28 minutes.
  *
  * Another option is getsrv_delay, also for IMAP accounts, which allows you to 
  * specify the delay before the connection that gets created for receiving 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]