From f64cb0b0ca7f95b86a7421f996ba7c248ac97b5e Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 12 Nov 2016 10:18:53 +0800 Subject: [PATCH] Refine the timer of traffic stat --- src/local.c | 6 +++--- src/udprelay.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/local.c b/src/local.c index 0a895966..4054a10f 100644 --- a/src/local.c +++ b/src/local.c @@ -729,9 +729,9 @@ server_send_cb(EV_P_ ev_io *w, int revents) #ifdef ANDROID static void -stat_update_cb(struct ev_loop *loop) +stat_update_cb() { - ev_tstamp now = ev_now(loop); + ev_tstamp now = ev_time(); if (now - last > 1.0) { send_traffic_stat(tx, rx); last = now; @@ -765,7 +765,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) ev_timer_again(EV_A_ & remote->recv_ctx->watcher); #ifdef ANDROID - stat_update_cb(loop); + stat_update_cb(); #endif ssize_t r = recv(remote->fd, server->buf->array, BUF_SIZE, 0); diff --git a/src/udprelay.c b/src/udprelay.c index b10f0cbb..57639f80 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -717,21 +717,21 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) // server may return using a different address type other than the type we // have used during sending - #if defined(MODULE_TUNNEL) || defined(MODULE_REDIR) // Construct packet buf->len -= len; memmove(buf->array, buf->array + len, buf->len); #else +#ifdef ANDROID + rx += buf->len; +#endif // Construct packet brealloc(buf, buf->len + 3, buf_size); memmove(buf->array + 3, buf->array, buf->len); memset(buf->array, 0, 3); buf->len += 3; -#ifdef ANDROID - rx += buf->len; -#endif #endif + #endif #ifdef MODULE_REMOTE