diff options
author | 2019-03-28 11:18:56 +0000 | |
---|---|---|
committer | 2019-03-28 11:18:56 +0000 | |
commit | ec043492c6f37fceab1ea6fd1cb551ad1d4d0368 (patch) | |
tree | 262b8a85c9235b3273a443804f5d5c305f41abb5 | |
parent | Wait until server disconnects before closing the socket. Otherwise, (diff) | |
download | wireguard-openbsd-ec043492c6f37fceab1ea6fd1cb551ad1d4d0368.tar.xz wireguard-openbsd-ec043492c6f37fceab1ea6fd1cb551ad1d4d0368.zip |
Don't send MIDI-related flow control messages until at least
half of the client buffer space is consumed. This avoids sending
unnecessary/redundant messages on the network.
-rw-r--r-- | usr.bin/sndiod/midi.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.bin/sndiod/midi.c b/usr.bin/sndiod/midi.c index c45024ed490..2af5dd04757 100644 --- a/usr.bin/sndiod/midi.c +++ b/usr.bin/sndiod/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.16 2017/01/03 06:53:20 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.17 2019/03/28 11:18:56 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -238,6 +238,16 @@ midi_tickets(struct midi *iep) int i, tickets, avail, maxavail; struct midi *oep; + /* + * don't request iep->ops->fill() too often as it generates + * useless network traffic: wait until we reach half of the + * max tickets count. As in the worst case (see comment below) + * one ticket may consume two bytes, the max ticket count is + * BUFSZ / 2 and halt of it is simply BUFSZ / 4. + */ + if (iep->tickets >= MIDI_BUFSZ / 4) + return; + maxavail = MIDI_BUFSZ; for (i = 0; i < MIDI_NEP ; i++) { if ((iep->txmask & (1 << i)) == 0) |