]> git.meshlink.io Git - utcp/commitdiff
Add more debug messages.
authorGuus Sliepen <guus@meshlink.io>
Fri, 30 Oct 2015 22:42:35 +0000 (23:42 +0100)
committerGuus Sliepen <guus@sliepen.org>
Sun, 2 Jul 2017 10:14:14 +0000 (12:14 +0200)
test.c
utcp.c

diff --git a/test.c b/test.c
index 15d57720ec19d709f6b86ac6d1eed4c6b7fea1f1..a078e1f9584ab756db68ef0357a17ba051aa314b 100644 (file)
--- a/test.c
+++ b/test.c
@@ -215,7 +215,8 @@ int main(int argc, char *argv[]) {
                        inpktno++;
                        if(inpktno >= dropto || inpktno < dropfrom || drand48() >= dropin) {
                                total_in += len;
-                               utcp_recv(u, buf, len);
+                               if(utcp_recv(u, buf, len) == -1)
+                                       debug("Error receiving UTCP packet: %s\n", strerror(errno));
                        } else {
                                debug("Dropped incoming packet\n");
                        }
diff --git a/utcp.c b/utcp.c
index 026fb31bf340f74db204ab1f68ad6cfe27c4977c..9bae7b9f87b10b81fee0e700e48c40b462043dae 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -857,8 +857,10 @@ ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) {
        // In case this is for a CLOSED connection, ignore the packet.
        // TODO: make it so incoming packets can never match a CLOSED connection.
 
-       if(c->state == CLOSED)
+       if(c->state == CLOSED) {
+               debug("Got packet for closed connection\n");
                return 0;
+       }
 
        // It is for an existing connection.