fix-wait-for-writable-socket-on-windows.patch
text/x-patch
Filename: fix-wait-for-writable-socket-on-windows.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/storage/ipc/latch.c | 31 | 0 |
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index ea7f930..300b866 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -1401,6 +1401,37 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
WaitEventAdjustWin32(set, cur_event);
cur_event->reset = false;
}
+
+ if (cur_event->events & WL_SOCKET_WRITEABLE)
+ {
+ char c;
+ WSABUF buf;
+ DWORD sent;
+ int r;
+
+ buf.buf = &c;
+ buf.len = 0;
+
+ r = WSASend(cur_event->fd, &buf, 1, &sent, 0, NULL, NULL);
+ if (r == 0)
+ {
+ occurred_events->pos = cur_event->pos;
+ occurred_events->user_data = cur_event->user_data;
+ occurred_events->events = WL_SOCKET_WRITEABLE;
+ occurred_events->fd = cur_event->fd;
+ return 1;
+ }
+ else
+ {
+ if (WSAGetLastError() != WSAEWOULDBLOCK)
+ /*
+ * Not completed, and not just "would block", so an error
+ * occurred
+ */
+ elog(ERROR, "failed writability check on socket: error code %u",
+ WSAGetLastError());
+ }
+ }
}
/*