From: Guus Sliepen Date: Sat, 8 Feb 2020 14:59:41 +0000 (+0100) Subject: Fix garbage being sent at start of UDP connection. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=96b97ab1291e339a36952532db8ce72e7efc45a1;p=utcp Fix garbage being sent at start of UDP connection. If utcp_send() was called right after utcp_connect_ex(..., UTCP_UDP), and the handshake phase hadn't completed yet, we left some garbage in the send buffer which wasn't cleared until two more calls to utcp_send() were made. --- diff --git a/utcp.c b/utcp.c index c57a5cc..5d63069 100644 --- a/utcp.c +++ b/utcp.c @@ -629,6 +629,8 @@ ssize_t utcp_send(struct utcp_connection *c, const void *data, size_t len) { if(is_reliable(c) || (c->state != SYN_SENT && c->state != SYN_RECEIVED)) { len = buffer_put(&c->sndbuf, data, len); + } else { + return 0; } if(len <= 0) {