X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Futcp.c;h=7ac96c626d6dedbf9849d4fe41eb11e7a24763ac;hb=f84fc9da827afbc7bc7bd14fa94b84ee9922e575;hp=d2a929bf734a598b51ff8d2dd309b08c3383516c;hpb=f13b47a184094c6c9c22faf22c4e6b1117a1d758;p=meshlink diff --git a/src/utcp.c b/src/utcp.c index d2a929bf..7ac96c62 100644 --- a/src/utcp.c +++ b/src/utcp.c @@ -17,16 +17,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" #include #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); } @@ -2052,6 +2044,10 @@ void utcp_abort_all_connections(struct utcp *utcp) { } int utcp_close(struct utcp_connection *c) { + if(c->rcvbuf.used) { + return reset_connection(c) ? 0 : -1; + } + if(utcp_shutdown(c, SHUT_RDWR) && errno != ENOTCONN) { return -1; }