summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
authorTingPing <TingPing@users.noreply.github.com>2014-02-04 17:29:27 -0800
committerTingPing <TingPing@users.noreply.github.com>2014-02-04 17:29:27 -0800
commit29e01daeae94281d5c21aba01dae9123f6aa34d5 (patch)
tree9660121007954778aa804a78206c5b4b8445b33e /src/common
parent9f01950bcbc85f8b3960724b6df77c3e9c111601 (diff)
parent9969282c72f838004fe3d75f06db48072b0fbfeb (diff)
Merge pull request #890 from orium/lagmeter-fixes
Lagmeter fixes
Diffstat (limited to 'src/common')
-rw-r--r--src/common/fe.h2
-rw-r--r--src/common/hexchat.c10
-rw-r--r--src/common/hexchat.h2
-rw-r--r--src/common/inbound.c6
-rw-r--r--src/common/util.c2
5 files changed, 13 insertions, 9 deletions
diff --git a/src/common/fe.h b/src/common/fe.h
index a7287c4d..cd8ecef9 100644
--- a/src/common/fe.h
+++ b/src/common/fe.h
@@ -118,7 +118,7 @@ void fe_set_nick (struct server *serv, char *newnick);
 void fe_ignore_update (int level);
 void fe_beep (session *sess);
 void fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_flags flags);
-void fe_set_lag (server *serv, int lag);
+void fe_set_lag (server *serv, long lag);
 void fe_set_throttle (server *serv);
 void fe_set_away (server *serv);
 void fe_serverlist_open (session *sess);
diff --git a/src/common/hexchat.c b/src/common/hexchat.c
index d44fa2f4..07f91cfb 100644
--- a/src/common/hexchat.c
+++ b/src/common/hexchat.c
@@ -286,12 +286,16 @@ lag_check (void)
 								 NULL, NULL, 0);
 				if (prefs.hex_net_auto_reconnect)
 					serv->auto_reconnect (serv, FALSE, -1);
-			} else if (!serv->lag_sent)
+			} else
 			{
 				snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
 				serv->p_ping (serv, "", tbuf);
-				serv->lag_sent = tim;
-				fe_set_lag (serv, -1);
+				
+				if (!serv->lag_sent)
+				{
+					serv->lag_sent = tim;
+					fe_set_lag (serv, -1);
+				}
 			}
 		}
 		list = list->next;
diff --git a/src/common/hexchat.h b/src/common/hexchat.h
index 219c4394..7143f8ab 100644
--- a/src/common/hexchat.h
+++ b/src/common/hexchat.h
@@ -577,7 +577,7 @@ typedef struct server
 	time_t msg_last_time;
 
 	/*time_t connect_time;*/				/* when did it connect? */
-	time_t lag_sent;
+	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 away_time;					/* when we were marked away */
 
diff --git a/src/common/inbound.c b/src/common/inbound.c
index d1c5b51a..47fe2e00 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -892,8 +892,8 @@ inbound_ping_reply (session *sess, char *timestring, char *from,
 	if (lag)
 	{
 		sess->server->lag_sent = 0;
-		sess->server->lag = dif / 1000;
-		fe_set_lag (sess->server, dif / 100000);
+		sess->server->lag = dif;
+		fe_set_lag (sess->server, dif);
 		return;
 	}
 
@@ -906,7 +906,7 @@ inbound_ping_reply (session *sess, char *timestring, char *from,
 										  tags_data->timestamp);
 	} else
 	{
-		snprintf (outbuf, sizeof (outbuf), "%ld.%ld%ld", dif / 1000000, (dif / 100000) % 10, dif % 10);
+		snprintf (outbuf, sizeof (outbuf), "%ld.%03ld", dif / 1000, dif % 1000);
 		EMIT_SIGNAL_TIMESTAMP (XP_TE_PINGREP, sess, from, outbuf, NULL, NULL, 0,
 									  tags_data->timestamp);
 	}
diff --git a/src/common/util.c b/src/common/util.c
index 6e912169..f999e61f 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1459,7 +1459,7 @@ make_ping_time (void)
 	GTimeVal timev;
 	g_get_current_time (&timev);
 #endif
-	return (timev.tv_sec - 50000) * 1000000 + timev.tv_usec;
+	return (timev.tv_sec - 50000) * 1000 + timev.tv_usec/1000;
 }