From c088f85b7306a3fcf2251c2cc9060d3948d7ade4 Mon Sep 17 00:00:00 2001 From: Brian Cloutier Date: Wed, 11 Apr 2018 11:25:07 -0700 Subject: [PATCH] Fix crash in multi_copy test --- src/backend/distributed/connection/remote_commands.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/connection/remote_commands.c b/src/backend/distributed/connection/remote_commands.c index 06ffb27a0..6ecb9bee6 100644 --- a/src/backend/distributed/connection/remote_commands.c +++ b/src/backend/distributed/connection/remote_commands.c @@ -992,13 +992,17 @@ BuildWaitEventSet(MultiConnection **allConnections, int totalConnectionCount, WaitEventSet *waitEventSet = NULL; int connectionIndex = 0; - /* we subtract 2 to make room for the WL_POSTMASTER_DEATH and WL_LATCH_SET events */ - if (pendingConnectionCount > FD_SETSIZE - 2) + /* + * subtract 3 to make room for WL_POSTMASTER_DEATH, WL_LATCH_SET, and + * pgwin32_signal_event. + */ + if (pendingConnectionCount > FD_SETSIZE - 3) { - pendingConnectionCount = FD_SETSIZE - 2; + pendingConnectionCount = FD_SETSIZE - 3; } /* allocate pending connections + 2 for the signal latch and postmaster death */ + /* (CreateWaitEventSet makes room for pgwin32_signal_event automatically) */ waitEventSet = CreateWaitEventSet(CurrentMemoryContext, pendingConnectionCount + 2); for (connectionIndex = 0; connectionIndex < pendingConnectionCount; connectionIndex++)