From: Sven M. Hallberg Date: Tue, 26 Aug 2014 19:39:24 +0000 (+0200) Subject: use closesocket() on windows X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=4fe2472f5302b74df5dbb43822711487f1fd9851;p=catta use closesocket() on windows --- diff --git a/src/internal.h b/src/internal.h index 6c602d7..b74ce25 100644 --- a/src/internal.h +++ b/src/internal.h @@ -48,6 +48,10 @@ typedef struct CattaEntry CattaEntry; #define CATTA_RR_HOLDOFF_MSEC_RATE_LIMIT 20000 #define CATTA_RR_RATE_LIMIT_COUNT 15 +#ifndef _WIN32 +#define closesocket close +#endif + typedef struct CattaLegacyUnicastReflectSlot CattaLegacyUnicastReflectSlot; struct CattaLegacyUnicastReflectSlot { diff --git a/src/server.c b/src/server.c index a726310..1dda8b4 100644 --- a/src/server.c +++ b/src/server.c @@ -1515,14 +1515,14 @@ void catta_server_free(CattaServer* s) { /* Free sockets */ if (s->fd_ipv4 >= 0) - close(s->fd_ipv4); + closesocket(s->fd_ipv4); if (s->fd_ipv6 >= 0) - close(s->fd_ipv6); + closesocket(s->fd_ipv6); if (s->fd_legacy_unicast_ipv4 >= 0) - close(s->fd_legacy_unicast_ipv4); + closesocket(s->fd_legacy_unicast_ipv4); if (s->fd_legacy_unicast_ipv6 >= 0) - close(s->fd_legacy_unicast_ipv6); + closesocket(s->fd_legacy_unicast_ipv6); /* Free other stuff */ diff --git a/src/socket.c b/src/socket.c index f381561..4c991e7 100644 --- a/src/socket.c +++ b/src/socket.c @@ -364,7 +364,7 @@ int catta_open_socket_ipv4(int no_reuse) { fail: if (fd >= 0) - close(fd); + closesocket(fd); return -1; } @@ -434,7 +434,7 @@ int catta_open_socket_ipv6(int no_reuse) { fail: if (fd >= 0) - close(fd); + closesocket(fd); return -1; } @@ -942,7 +942,7 @@ int catta_open_unicast_socket_ipv4(void) { fail: if (fd >= 0) - close(fd); + closesocket(fd); return -1; } @@ -987,7 +987,7 @@ int catta_open_unicast_socket_ipv6(void) { fail: if (fd >= 0) - close(fd); + closesocket(fd); return -1; } diff --git a/src/wide-area.c b/src/wide-area.c index 2ae6d2d..26a4e7a 100644 --- a/src/wide-area.c +++ b/src/wide-area.c @@ -584,10 +584,10 @@ CattaWideAreaLookupEngine *catta_wide_area_engine_new(CattaServer *s) { catta_log_error(__FILE__": Failed to create wide area sockets: %s", strerror(errno)); if (e->fd_ipv6 >= 0) - close(e->fd_ipv6); + closesocket(e->fd_ipv6); if (e->fd_ipv4 >= 0) - close(e->fd_ipv4); + closesocket(e->fd_ipv4); catta_free(e); return NULL; @@ -637,10 +637,10 @@ void catta_wide_area_engine_free(CattaWideAreaLookupEngine *e) { e->server->poll_api->watch_free(e->watch_ipv6); if (e->fd_ipv6 >= 0) - close(e->fd_ipv6); + closesocket(e->fd_ipv6); if (e->fd_ipv4 >= 0) - close(e->fd_ipv4); + closesocket(e->fd_ipv4); catta_free(e); }