X-Git-Url: https://git.librecmc.org/?p=oweals%2Ftinc.git;a=blobdiff_plain;f=src%2Fprotocol_misc.c;h=8f56aee50aff918a20f6a0791aa0c9acd7323a6b;hp=52e97e5448193f9260a86d605e80e4996cebd89b;hb=43fa7283ac01f2ecc95381b519ef6b3342546f35;hpb=d5b56bbba56480b5565ffb38496175a7c1df60ac diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 52e97e5..8f56aee 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -155,9 +155,10 @@ bool send_tcppacket(connection_t *c, vpn_packet_t *packet) { cp(); - /* If there already is a lot of data in the outbuf buffer, discard this packet. */ + /* If there already is a lot of data in the outbuf buffer, discard this packet. + We use a very simple Random Early Drop algorithm. */ - if(c->outbuflen > maxoutbufsize) + if(2.0 * c->outbuflen / (double)maxoutbufsize - 1 > drand48()) return true; if(!send_request(c, "%d %hd", PACKET, packet->len))