Skip to content

Commit d77c9e2

Browse files
maksm90akorotkov
authored andcommitted
Add check on shmq detach after shm_mq_wait_for_attach. Make light refactoring
1 parent cdbf9bd commit d77c9e2

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

collector.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,35 @@ collector_main(Datum main_arg)
438438

439439
if (request == HISTORY_REQUEST || request == PROFILE_REQUEST)
440440
{
441+
shm_mq_result mq_result;
442+
441443
/* Send history or profile */
442444
shm_mq_set_sender(collector_mq, MyProc);
443445
mqh = shm_mq_attach(collector_mq, NULL, NULL);
444-
shm_mq_wait_for_attach(mqh);
445-
if (shm_mq_get_receiver(collector_mq) != NULL)
446+
mq_result = shm_mq_wait_for_attach(mqh);
447+
switch (mq_result)
446448
{
447-
if (request == HISTORY_REQUEST)
448-
{
449-
send_history(&observations, mqh);
450-
}
451-
else if (request == PROFILE_REQUEST)
452-
{
453-
send_profile(profile_hash, mqh);
454-
}
449+
case SHM_MQ_SUCCESS:
450+
switch (request)
451+
{
452+
case HISTORY_REQUEST:
453+
send_history(&observations, mqh);
454+
break;
455+
case PROFILE_REQUEST:
456+
send_profile(profile_hash, mqh);
457+
break;
458+
default:
459+
AssertState(false);
460+
}
461+
break;
462+
case SHM_MQ_DETACHED:
463+
ereport(WARNING,
464+
(errmsg("pg_wait_sampling collector: "
465+
"receiver of message queue have been "
466+
"detached")));
467+
break;
468+
default:
469+
AssertState(false);
455470
}
456471
shm_mq_detach_compat(mqh, collector_mq);
457472
}

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