Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ecd9649

Browse files
committed
check that dmq can attach dsm before destroying old dsm and queue
1 parent c020830 commit ecd9649

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/dmq.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ dmq_reattach_shm_mq(int handle_id)
12741274
dsm_handle receiver_dsm;
12751275
int i;
12761276

1277+
dsm_segment *new_segmap;
1278+
12771279
LWLockAcquire(dmq_state->lock, LW_SHARED);
12781280
for (i = 0; i < DMQ_MAX_RECEIVERS; i++)
12791281
{
@@ -1310,6 +1312,14 @@ dmq_reattach_shm_mq(int handle_id)
13101312
dmq_local.inhandles[handle_id].name,
13111313
receiver_dsm);
13121314

1315+
/* try to attch new segment before destroying old ones */
1316+
new_segmap = dsm_attach(receiver_dsm);
1317+
if (new_segmap == NULL)
1318+
{
1319+
mtm_log(DmqTraceShmMq, "unable to map dynamic shared memory segment");
1320+
return false;
1321+
}
1322+
13131323
if (dmq_local.inhandles[handle_id].dsm_seg)
13141324
{
13151325
if (dmq_local.inhandles[handle_id].mqh)
@@ -1323,13 +1333,7 @@ dmq_reattach_shm_mq(int handle_id)
13231333
dsm_detach(dmq_local.inhandles[handle_id].dsm_seg);
13241334
}
13251335

1326-
dmq_local.inhandles[handle_id].dsm_seg = dsm_attach(receiver_dsm);
1327-
if (dmq_local.inhandles[handle_id].dsm_seg == NULL)
1328-
{
1329-
mtm_log(DmqTraceShmMq, "unable to map dynamic shared memory segment");
1330-
return false;
1331-
}
1332-
1336+
dmq_local.inhandles[handle_id].dsm_seg = new_segmap;
13331337
dsm_pin_mapping(dmq_local.inhandles[handle_id].dsm_seg);
13341338

13351339
toc = shm_toc_attach(DMQ_MQ_MAGIC,

src/include/logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef enum MtmLogTag
2626
DmqStateFinal = LOG,
2727
DmqTraceOutgoing = DEBUG2,
2828
DmqTraceIncoming = DEBUG2,
29-
DmqTraceShmMq = DEBUG1,
29+
DmqTraceShmMq = LOG,
3030
DmqPqTiming = LOG,
3131

3232
/* resolver */

0 commit comments

Comments
 (0)