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;