pong handler: rtt and timestamps are always positive

This commit is contained in:
lemoer 2016-05-18 21:25:31 +02:00
parent 25317983c7
commit 762dc69a59

View file

@ -123,8 +123,9 @@ bool send_pong(connection_t *c) {
} }
bool pong_h(connection_t *c, const char *request) { bool pong_h(connection_t *c, const char *request) {
int current_rtt = 0; int ret;
int tv_sec, tv_usec, ret; long current_rtt = 0;
long tv_sec, tv_usec;
struct timeval _now; struct timeval _now;
if (!c->status.pinged) { if (!c->status.pinged) {
@ -134,7 +135,7 @@ bool pong_h(connection_t *c, const char *request) {
c->status.pinged = false; 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); gettimeofday(&_now, NULL);
if (ret != 2) { if (ret != 2) {