proxy: fix potential corruption on partial write
If a command was partially sent we were not decrementing the byte sum
cache. This would lead to listening on the wrong event and potentially
causing corruption.
It might be better to remove the cache to avoid mistakes like
this and for loop it each time.
@@ -885,6 +885,7 @@ static int _flush_pending_write(mcp_backend_t *be) {
// short circuit for common case.
sent -= io->iovbytes;
} else {
+ io->iovbytes -= sent;
for (int x = 0; x < io->iovcnt; x++) {
struct iovec *iov = &io->iov[x];
if (sent >= iov->iov_len) {
