comparison 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
comparison
equal deleted inserted replaced
939:12fa2ae6445d 940:fc30221b952d
189 FD_SET(jc->fd, &fds); 189 FD_SET(jc->fd, &fds);
190 190
191 tv.tv_sec = 60; 191 tv.tv_sec = 60;
192 tv.tv_usec = 0; 192 tv.tv_usec = 0;
193 193
194 time(&now);
195
194 if (KeepaliveDelay) { 196 if (KeepaliveDelay) {
195 time(&now); 197 if (now >= LastPingTime + (time_t)KeepaliveDelay) {
196 if (now > LastPingTime + (time_t)KeepaliveDelay) {
197 tv.tv_sec = 0; 198 tv.tv_sec = 0;
198 } else { 199 } else {
199 tv.tv_sec = LastPingTime + (time_t)KeepaliveDelay - now; 200 tv.tv_sec = LastPingTime + (time_t)KeepaliveDelay - now;
200 } 201 }
201 } 202 }
202 203
203 autoaway_timeout = scr_GetAutoAwayTimeout(); 204 autoaway_timeout = scr_GetAutoAwayTimeout(now);
204 if (tv.tv_sec > autoaway_timeout) 205 if (tv.tv_sec > autoaway_timeout) {
205 tv.tv_sec = autoaway_timeout; 206 tv.tv_sec = autoaway_timeout;
206 207 }
208
209 if (!tv.tv_sec)
210 tv.tv_usec = 350000;
211
212 scr_DoUpdate();
207 if (select(jc->fd + 1, &fds, NULL, NULL, &tv) > 0) { 213 if (select(jc->fd + 1, &fds, NULL, NULL, &tv) > 0) {
208 if (FD_ISSET(jc->fd, &fds)) 214 if (FD_ISSET(jc->fd, &fds))
209 jab_poll(jc, 0); 215 jab_poll(jc, 0);
210 } 216 }
211 217