aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/iocp_windows.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib/iomgr/iocp_windows.cc')
-rw-r--r--src/core/lib/iomgr/iocp_windows.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc
index 336cc86c75..78185cc084 100644
--- a/src/core/lib/iomgr/iocp_windows.cc
+++ b/src/core/lib/iomgr/iocp_windows.cc
@@ -21,6 +21,7 @@
#ifdef GRPC_WINSOCK_SOCKET
#include <winsock2.h>
+#include <limits>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -43,11 +44,14 @@ static HANDLE g_iocp;
static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx,
grpc_millis deadline) {
- gpr_timespec timeout;
if (deadline == GRPC_MILLIS_INF_FUTURE) {
return INFINITE;
}
- return (DWORD)GPR_MAX(0, deadline - grpc_exec_ctx_now(exec_ctx));
+ grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ if (deadline < now) return 0;
+ grpc_millis timeout = deadline - now;
+ if (timeout > std::numeric_limits<DWORD>::max()) return INFINITE;
+ return static_cast<DWORD>(deadline - now);
}
grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
@@ -63,6 +67,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
success =
GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped,
deadline_to_millis_timeout(exec_ctx, deadline));
+ grpc_exec_ctx_invalidate_now(exec_ctx);
if (success == 0 && overlapped == NULL) {
return GRPC_IOCP_WORK_TIMEOUT;
}