Fix stat_update_cb for UDP packets

This commit is contained in:
Max Lv
2017-05-06 07:24:12 +08:00
parent 6c5142a2de
commit 0313c8bcc6
2 changed files with 6 additions and 6 deletions
+4 -6
View File
@@ -832,11 +832,12 @@ server_send_cb(EV_P_ ev_io *w, int revents)
}
#ifdef ANDROID
static void
void
stat_update_cb()
{
LOGI("stat: %" PRId64 ", %" PRId64 "", tx, rx);
ev_tstamp now = ev_time();
if (now - last > 1.0) {
if (now - last > 0.5) {
send_traffic_stat(tx, rx);
last = now;
}
@@ -870,10 +871,6 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
ev_timer_again(EV_A_ & remote->recv_ctx->watcher);
#ifdef ANDROID
stat_update_cb();
#endif
ssize_t r = recv(remote->fd, server->buf->data, BUF_SIZE, 0);
if (r == 0) {
@@ -899,6 +896,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
if (!remote->direct) {
#ifdef ANDROID
rx += server->buf->len;
stat_update_cb();
#endif
int err = crypto->decrypt(server->buf, server->d_ctx, BUF_SIZE);
if (err == CRYPTO_ERROR) {
+2
View File
@@ -89,6 +89,7 @@ static remote_ctx_t *new_remote(int fd, server_ctx_t *server_ctx);
extern uint64_t tx;
extern uint64_t rx;
extern int vpn;
extern void stat_update_cb();
#endif
extern int verbose;
@@ -737,6 +738,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
#else
#ifdef ANDROID
rx += buf->len;
stat_update_cb();
#endif
// Construct packet
brealloc(buf, buf->len + 3, buf_size);