From 9ee23992c0e56c50b01b932692c6da407665b426 Mon Sep 17 00:00:00 2001 From: frekky Date: Sat, 3 Oct 2015 22:13:15 +0800 Subject: [PATCH] Added user ping flag, all_users_waiting_to_send now makes sense --- src/user.c | 10 +++++----- src/user.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/user.c b/src/user.c index 7588de4..d6324e6 100644 --- a/src/user.c +++ b/src/user.c @@ -128,14 +128,14 @@ user_active(int i) int all_users_waiting_to_send() /* If this returns true, then reading from tun device is blocked. - So only return true when all clients have at least one fragment in - the outgoing buffer, so that sending back-to-back is possible - without going through another select loop. -*/ + So only return true when all clients have insufficient space in + outgoing buffer, so that sending back-to-back is possible + without going through another select loop. */ { for (int i = 0; i < usercount; i++) if (user_active(i)) - if (!user_sending(i)) return 0; + if (users[i].outgoing->length - users[i].outgoing->numitems > 8) + return 0; return 1; } diff --git a/src/user.h b/src/user.h index 1acf8a9..00dd68a 100644 --- a/src/user.h +++ b/src/user.h @@ -40,6 +40,7 @@ struct tun_user { struct frag_buffer *incoming; struct frag_buffer *outgoing; int next_upstream_ack; + int send_ping_next; struct encoder *encoder; char downenc; int downenc_bits;