Skip to content

Commit 915d268

Browse files
committed
Fix wsapoll usage on windows
We didn't correctly handle POLLHUP or POLLERR on win32. Do it right now
1 parent ad2baa8 commit 915d268

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/mongoc/mongoc-socket.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "mongoc-socket.h"
2525
#include "mongoc-trace.h"
2626

27-
2827
#undef MONGOC_LOG_DOMAIN
2928
#define MONGOC_LOG_DOMAIN "socket"
3029

@@ -148,14 +147,18 @@ _mongoc_socket_wait (int sd, /* IN */
148147
ret = WSAPoll (&pfd, 1, timeout);
149148
if (ret == SOCKET_ERROR) {
150149
MONGOC_WARNING ("WSAGetLastError(): %d", WSAGetLastError ());
151-
ret = -1;
150+
ret = false;
152151
}
153152
#else
154153
ret = poll (&pfd, 1, timeout);
155154
#endif
156155

157156
if (ret > 0) {
157+
#ifdef _WIN32
158+
RETURN (0 != (pfd.revents & (events | POLLHUP | POLLERR)));
159+
#else
158160
RETURN (0 != (pfd.revents & events));
161+
#endif
159162
}
160163

161164
RETURN (false);
@@ -412,6 +415,7 @@ mongoc_socket_close (mongoc_socket_t *sock) /* IN */
412415

413416
#ifdef _WIN32
414417
if (sock->sd != INVALID_SOCKET) {
418+
shutdown (sock->sd, SD_BOTH);
415419
ret = closesocket (sock->sd);
416420
}
417421
#else

0 commit comments

Comments
 (0)