In write, buf_w was unchecked.

We already checked for room, so the buffer should have room.  We make this
a kind of assertion; this silences compiler warnings.  Later, if this
becomes a thread-level race condition, come back and actually use buf_w
more meaningfully to handle partial writes.
This commit is contained in:
Garrett D'Amore
2017-07-25 11:03:02 -07:00
parent 8a6d4820cc
commit 24fa0c9a6c

View File

@@ -746,6 +746,11 @@ namespace ZeroTier {
}
int buf_w = conn->TXbuf->write((const unsigned char*)data, len);
if (buf_w != len) {
// because we checked ZT_TCP_TX_BUF_SZ above, this should not happen
DEBUG_ERROR("TX wrote only %d but expected to write %d", buf_w, len);
exit(0);
}
//DEBUG_INFO("TXbuf->count() = %d", conn->TXbuf->count());
int txsz = conn->TXbuf->count();