Added user ping flag, all_users_waiting_to_send now makes sense

This commit is contained in:
frekky 2015-10-03 22:13:15 +08:00
parent faf7d277a8
commit 9ee23992c0
2 changed files with 6 additions and 5 deletions

View File

@ -128,14 +128,14 @@ user_active(int i)
int int
all_users_waiting_to_send() all_users_waiting_to_send()
/* If this returns true, then reading from tun device is blocked. /* If this returns true, then reading from tun device is blocked.
So only return true when all clients have at least one fragment in So only return true when all clients have insufficient space in
the outgoing buffer, so that sending back-to-back is possible outgoing buffer, so that sending back-to-back is possible
without going through another select loop. without going through another select loop. */
*/
{ {
for (int i = 0; i < usercount; i++) for (int i = 0; i < usercount; i++)
if (user_active(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; return 1;
} }

View File

@ -40,6 +40,7 @@ struct tun_user {
struct frag_buffer *incoming; struct frag_buffer *incoming;
struct frag_buffer *outgoing; struct frag_buffer *outgoing;
int next_upstream_ack; int next_upstream_ack;
int send_ping_next;
struct encoder *encoder; struct encoder *encoder;
char downenc; char downenc;
int downenc_bits; int downenc_bits;