diff mcabber/src/jabglue.c @ 940:fc30221b952d

Fix an autoaway problem This patch fixes an autoaway related issue introduced in the previous changeset. scr_GetAutoAwayTimeout() should not return a null timeout when the user status do not need auto-away (i.e. status != online,free). This patch also tries to save a few time() calls.
author Mikael Berthe <mikael@lilotux.net>
date Fri, 14 Jul 2006 19:32:23 +0200
parents 12fa2ae6445d
children 819396bebdf5
line wrap: on
line diff
--- a/mcabber/src/jabglue.c	Tue Jul 11 22:50:48 2006 +0200
+++ b/mcabber/src/jabglue.c	Fri Jul 14 19:32:23 2006 +0200
@@ -191,19 +191,25 @@
   tv.tv_sec = 60;
   tv.tv_usec = 0;
 
+  time(&now);
+
   if (KeepaliveDelay) {
-    time(&now);
-    if (now > LastPingTime + (time_t)KeepaliveDelay) {
+    if (now >= LastPingTime + (time_t)KeepaliveDelay) {
       tv.tv_sec = 0;
     } else {
       tv.tv_sec = LastPingTime + (time_t)KeepaliveDelay - now;
     }
   }
 
-  autoaway_timeout = scr_GetAutoAwayTimeout();
-  if (tv.tv_sec > autoaway_timeout)
+  autoaway_timeout = scr_GetAutoAwayTimeout(now);
+  if (tv.tv_sec > autoaway_timeout) {
     tv.tv_sec = autoaway_timeout;
+  }
 
+  if (!tv.tv_sec)
+    tv.tv_usec = 350000;
+
+  scr_DoUpdate();
   if (select(jc->fd + 1, &fds, NULL, NULL, &tv) > 0) {
     if (FD_ISSET(jc->fd, &fds))
       jab_poll(jc, 0);