... | ... |
@@ -18,6 +18,10 @@ |
18 | 18 |
* MA 02110-1301, USA. |
19 | 19 |
*/ |
20 | 20 |
|
21 |
+#if HAVE_CONFIG_H |
|
22 |
+#include "clamav-config.h" |
|
23 |
+#endif |
|
24 |
+ |
|
21 | 25 |
#include <stdio.h> |
22 | 26 |
#include <stdlib.h> |
23 | 27 |
#include <string.h> |
... | ... |
@@ -40,6 +44,8 @@ |
40 | 40 |
#include <netdb.h> |
41 | 41 |
#endif |
42 | 42 |
|
43 |
+#include "platform.h" |
|
44 |
+ |
|
43 | 45 |
#include <openssl/ssl.h> |
44 | 46 |
#include <openssl/err.h> |
45 | 47 |
#include "libclamav/crypto.h" |
... | ... |
@@ -81,7 +87,7 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
81 | 81 |
if (useAsync) { |
82 | 82 |
flags = fcntl(sockfd, F_GETFL, 0); |
83 | 83 |
if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) < 0) { |
84 |
- close(sockfd); |
|
84 |
+ closesocket(sockfd); |
|
85 | 85 |
continue; |
86 | 86 |
} |
87 | 87 |
} |
... | ... |
@@ -89,9 +95,7 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
89 | 89 |
if ((error = connect(sockfd, p->ai_addr, p->ai_addrlen))) { |
90 | 90 |
if (useAsync) { |
91 | 91 |
if (errno != EINPROGRESS) { |
92 |
-#ifndef _WIN32 |
|
93 |
- close(sockfd); |
|
94 |
-#endif |
|
92 |
+ closesocket(sockfd); |
|
95 | 93 |
continue; |
96 | 94 |
} |
97 | 95 |
errno = 0; |
... | ... |
@@ -105,22 +109,22 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
105 | 105 |
tv.tv_sec = timeout; |
106 | 106 |
tv.tv_usec = 0; |
107 | 107 |
if (select(sockfd + 1, &read_fds, &write_fds, NULL, &tv) <= 0) { |
108 |
- close(sockfd); |
|
108 |
+ closesocket(sockfd); |
|
109 | 109 |
continue; |
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
if (FD_ISSET(sockfd, &read_fds) || FD_ISSET(sockfd, &write_fds)) { |
113 | 113 |
len = sizeof(error); |
114 | 114 |
if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { |
115 |
- close(sockfd); |
|
115 |
+ closesocket(sockfd); |
|
116 | 116 |
continue; |
117 | 117 |
} |
118 | 118 |
} else { |
119 |
- close(sockfd); |
|
119 |
+ closesocket(sockfd); |
|
120 | 120 |
continue; |
121 | 121 |
} |
122 | 122 |
} else { |
123 |
- close(sockfd); |
|
123 |
+ closesocket(sockfd); |
|
124 | 124 |
continue; |
125 | 125 |
} |
126 | 126 |
} |
... | ... |
@@ -132,10 +136,8 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
132 | 132 |
|
133 | 133 |
if (!(p)) { |
134 | 134 |
freeaddrinfo(servinfo); |
135 |
-#ifndef _WIN32 |
|
136 | 135 |
if (sockfd >= 0) |
137 |
- close(sockfd); |
|
138 |
-#endif |
|
136 |
+ closesocket(sockfd); |
|
139 | 137 |
return -1; |
140 | 138 |
} |
141 | 139 |
|
... | ... |
@@ -144,7 +146,7 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
144 | 144 |
/* Return to using a synchronous socket to make Linux happy */ |
145 | 145 |
if (useAsync) { |
146 | 146 |
if (fcntl(sockfd, F_SETFL, flags) < 0) { |
147 |
- close(sockfd); |
|
147 |
+ closesocket(sockfd); |
|
148 | 148 |
return -1; |
149 | 149 |
} |
150 | 150 |
} |
... | ... |
@@ -261,7 +263,7 @@ void submit_post(const char *host, const char *port, const char *method, const c |
261 | 261 |
cli_dbgmsg("stats - Connected to %s:%s\n", host, port); |
262 | 262 |
|
263 | 263 |
if (send(sockfd, buf, strlen(buf), 0) != strlen(buf)) { |
264 |
- close(sockfd); |
|
264 |
+ closesocket(sockfd); |
|
265 | 265 |
free(buf); |
266 | 266 |
return; |
267 | 267 |
} |
... | ... |
@@ -296,6 +298,6 @@ void submit_post(const char *host, const char *port, const char *method, const c |
296 | 296 |
} |
297 | 297 |
} |
298 | 298 |
|
299 |
- close(sockfd); |
|
299 |
+ closesocket(sockfd); |
|
300 | 300 |
free(buf); |
301 | 301 |
} |