]> git.meshlink.io Git - catta/commitdiff
use closesocket() on windows
authorSven M. Hallberg <pesco@khjk.org>
Tue, 26 Aug 2014 19:39:24 +0000 (21:39 +0200)
committerSven M. Hallberg <pesco@khjk.org>
Tue, 26 Aug 2014 19:39:24 +0000 (21:39 +0200)
src/internal.h
src/server.c
src/socket.c
src/wide-area.c

index 6c602d7deb3deb33eeaa41f27a3981d76800b893..b74ce25d3418e2c2a86189554a20b161e07c79a2 100644 (file)
@@ -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 {
index a726310d494e94f582338c8adcff490611228aa3..1dda8b4545edfe6481557873588365b878fe00bb 100644 (file)
@@ -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 */
 
index f381561fcb4b5a8d11c25820f4b6127a1dfd21e1..4c991e7dd3ee899957ac7256828116efa5d94033 100644 (file)
@@ -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;
 }
index 2ae6d2d655dd691ef41ab0d43bdbf52f6e4bcf2e..26a4e7a4549064b8c91174208f70572b56056bb6 100644 (file)
@@ -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);
 }