]> git.meshlink.io Git - utcp/commitdiff
Fix garbage being sent at start of UDP connection.
authorGuus Sliepen <guus@sliepen.org>
Sat, 8 Feb 2020 14:59:41 +0000 (15:59 +0100)
committerGuus Sliepen <guus@sliepen.org>
Sat, 8 Feb 2020 14:59:41 +0000 (15:59 +0100)
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.

utcp.c

diff --git a/utcp.c b/utcp.c
index c57a5ccfc5b90964bec0ad31ebebbed240adf5f3..5d630694df96100f57e780f855a32cc63f7674bc 100644 (file)
--- 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) {