Compare commits

...

2 Commits

Author SHA1 Message Date
pstratem
ca2b4d498c run lagcheck even if gui is disabled 2015-03-15 18:15:06 -07:00
pstratem
085d9c368c fix timeout logic
remove broken hex_net_ping_timeout logic

use timestamps in lag_check instead of relying on the function being called every 30 seconds

use prefs.hex_net_ping_timeout if available

fix whitespace

fix whitespace
2015-03-14 18:22:07 -07:00
3 changed files with 29 additions and 21 deletions

View File

@ -257,35 +257,39 @@ lag_check (void)
GSList *list = serv_list; GSList *list = serv_list;
unsigned long tim; unsigned long tim;
char tbuf[128]; char tbuf[128];
time_t now = time (0); time_t now = time(NULL);
time_t lag;
tim = make_ping_time (); tim = make_ping_time ();
time_t ping_interval = 15;
time_t ping_timeout = 30;
if (prefs.hex_net_ping_timeout != 0)
{
ping_timeout = prefs.hex_net_ping_timeout;
ping_interval = ping_timeout/2;
}
while (list) while (list)
{ {
serv = list->data; serv = list->data;
if (serv->connected && serv->end_of_motd) if (serv->connected && serv->end_of_motd)
{ {
lag = now - serv->ping_recv; if(!serv->lag_sent && (now - serv->ping_recv) > ping_interval)
if (prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0)
{
sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag);
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
NULL, NULL, 0);
if (prefs.hex_net_auto_reconnect)
serv->auto_reconnect (serv, FALSE, -1);
}
else
{ {
g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
serv->p_ping (serv, "", tbuf); serv->p_ping (serv, "", tbuf);
serv->lag_sent = tim;
if (!serv->lag_sent) fe_set_lag (serv, -1);
{ }
serv->lag_sent = tim;
fe_set_lag (serv, -1); if (prefs.hex_net_ping_timeout != 0 && (now - serv->socket_recv) > ping_timeout)
} {
sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) now - serv->socket_recv);
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
NULL, NULL, 0);
if (prefs.hex_net_auto_reconnect)
serv->auto_reconnect (serv, FALSE, -1);
} }
} }
list = list->next; list = list->next;
@ -366,10 +370,11 @@ hexchat_misc_checks (void) /* this gets called every 1/2 second */
if (count % 2) if (count % 2)
dcc_check_timeouts (); /* every 1 second */ dcc_check_timeouts (); /* every 1 second */
if (count >= 60) /* every 30 seconds */ if (count % 2) /* every 1 second*/
lag_check ();
if (count > 3600)
{ {
if (prefs.hex_gui_lagometer)
lag_check ();
count = 0; count = 0;
} }

View File

@ -530,6 +530,7 @@ typedef struct server
/*time_t connect_time;*/ /* when did it connect? */ /*time_t connect_time;*/ /* when did it connect? */
unsigned long lag_sent; /* we are still waiting for this ping response*/ unsigned long lag_sent; /* we are still waiting for this ping response*/
time_t ping_recv; /* when we last got a ping reply */ time_t ping_recv; /* when we last got a ping reply */
time_t socket_recv; /* when we last received something from the socket */
time_t away_time; /* when we were marked away */ time_t away_time; /* when we were marked away */
char *encoding; char *encoding;

View File

@ -313,6 +313,8 @@ server_read (GIOChannel *source, GIOCondition condition, server *serv)
} }
return TRUE; return TRUE;
} }
serv->socket_recv = time (NULL);
i = 0; i = 0;