Skip to content

Commit 2daa422

Browse files
maksm90akorotkov
authored andcommitted
Add detach after unsuccessful receives and checks on their after sends
1 parent 46e09bc commit 2daa422

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

collector.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,25 @@ send_history(History *observations, shm_mq_handle *mqh)
210210
{
211211
Size count,
212212
i;
213+
shm_mq_result mq_result;
213214

214215
if (observations->wraparound)
215216
count = observations->count;
216217
else
217218
count = observations->index;
218219

219-
shm_mq_send(mqh, sizeof(count), &count, false);
220+
mq_result = shm_mq_send(mqh, sizeof(count), &count, false);
221+
if (mq_result == SHM_MQ_DETACHED)
222+
return;
220223
for (i = 0; i < count; i++)
221-
shm_mq_send(mqh, sizeof(HistoryItem), &observations->items[i], false);
224+
{
225+
mq_result = shm_mq_send(mqh,
226+
sizeof(HistoryItem),
227+
&observations->items[i],
228+
false);
229+
if (mq_result == SHM_MQ_DETACHED)
230+
return;
231+
}
222232
}
223233

224234
/*

pg_wait_sampling.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,14 @@ receive_array(SHMRequest request, Size item_size, Size *count)
540540
{
541541
res = shm_mq_receive(mqh, &len, &data, false);
542542
if (res != SHM_MQ_SUCCESS || len != item_size)
543+
{
544+
#if PG_VERSION_NUM >= 100000
545+
shm_mq_detach(mqh);
546+
#else
547+
shm_mq_detach(mq);
548+
#endif
543549
elog(ERROR, "Error reading mq.");
550+
}
544551
memcpy(ptr, data, item_size);
545552
ptr += item_size;
546553
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy