MINOR: channel: don't use co_set_data() to decrement output
The use of co_set_data() should be strictly limited to setting the amount
of existing data to be transmitted. It ought not be used to decrement the
output after the data have left the buffer, because doing so involves
performing incorrect calculations using co_data() that still comprises
data that are not in the buffer anymore. Let's use c_rew() for this, which
is made exactly for this purpose, i.e. decrement c->output by as much as
requested. This is cleaner, faster, and will permit stricter checks.
diff --git a/src/stream_interface.c b/src/stream_interface.c
index ecbd7b0..4442b22 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -792,7 +792,7 @@
ret = conn->mux->snd_buf(cs, &oc->buf, co_data(oc), send_flag);
if (ret > 0) {
did_send = 1;
- co_set_data(oc, co_data(oc) - ret);
+ c_rew(oc, ret);
c_realign_if_empty(oc);
if (!co_data(oc)) {