]> git.meshlink.io Git - meshlink/blobdiff - src/utcp.c
Ensure the poll callback is called when a UDP channel has finished connecting.
[meshlink] / src / utcp.c
index f81150bf7ee7ec06a1aa9d0e88c2ab5751eb743a..7ac96c626d6dedbf9849d4fe41eb11e7a24763ac 100644 (file)
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#define _GNU_SOURCE
-
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <unistd.h>
+#include "system.h"
 #include <time.h>
 
 #include "utcp_priv.h"
@@ -423,7 +414,6 @@ static int compare(const void *va, const void *vb) {
        const struct utcp_connection *b = *(struct utcp_connection **)vb;
 
        assert(a && b);
-       assert(a->src && b->src);
 
        int c = (int)a->src - (int)b->src;
 
@@ -660,6 +650,7 @@ void utcp_accept(struct utcp_connection *c, utcp_recv_t recv, void *priv) {
        debug(c, "accepted %p %p\n", c, recv, priv);
        c->recv = recv;
        c->priv = priv;
+       c->do_poll = true;
        set_state(c, ESTABLISHED);
 }
 
@@ -1728,6 +1719,7 @@ skip_ack:
                                c->snd.last++;
                                set_state(c, FIN_WAIT_1);
                        } else {
+                               c->do_poll = true;
                                set_state(c, ESTABLISHED);
                        }
 
@@ -2053,7 +2045,6 @@ void utcp_abort_all_connections(struct utcp *utcp) {
 
 int utcp_close(struct utcp_connection *c) {
        if(c->rcvbuf.used) {
-               fprintf(stderr, "UTCP channel closed with stuff in receive buffer\n");
                return reset_connection(c) ? 0 : -1;
        }