From 762dc69a59900ee0ebacce07a32a04ab22d760b0 Mon Sep 17 00:00:00 2001 From: lemoer Date: Wed, 18 May 2016 21:25:31 +0200 Subject: [PATCH] pong handler: rtt and timestamps are always positive --- src/protocol_misc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 8e6b1de7..7480f4d8 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -123,8 +123,9 @@ bool send_pong(connection_t *c) { } bool pong_h(connection_t *c, const char *request) { - int current_rtt = 0; - int tv_sec, tv_usec, ret; + int ret; + long current_rtt = 0; + long tv_sec, tv_usec; struct timeval _now; if (!c->status.pinged) { @@ -134,7 +135,7 @@ bool pong_h(connection_t *c, const char *request) { c->status.pinged = false; - ret = sscanf(request, "%*d %d %d", &tv_sec, &tv_usec); + ret = sscanf(request, "%*d %ld %ld", &tv_sec, &tv_usec); gettimeofday(&_now, NULL); if (ret != 2) {