Skip to contentSkip to conversation

mq_timedreceive01: fails sometimes with EEXIST. When run in parallel you can sometimes get the following error: TBROK: mq_open(/test_mqueue, 194, 0700, (nil)) failed: EEXIST (17)

PATCH In review Stephen Bertram via ltp 1 participant 2 messages Feb 9

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mq_timedreceive01: fails sometimes with EEXIST. When run in parallel you can sometimes get the following error: TBROK: mq_open(/test_mqueue, 194, 0700, (nil)) failed: EEXIST (17)

This change allows for unique queue names per
process, when executed in parallel with -w #.

---
 testcases/kernel/syscalls/utils/mq.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/utils/mq.h +9 -6
index da45d2daf..eb66328d5 100644
@@ -12,9 +12,9 @@
 
 #define MAX_MSGSIZE	8192
 #define MSG_LENGTH	10
-#define QUEUE_NAME	"/test_mqueue"
-#define QUEUE_NAME_NONBLOCK	"/test_mqueue_nonblock"
 
+static char queue_name[64];
+static char queue_name_nonblock[64];
 static char smsg[MAX_MSGSIZE];
 static struct sigaction act;
 
@@ -29,8 +29,8 @@ static void cleanup_common(void)
 	if (fd_nonblock > 0)
 		SAFE_CLOSE(fd_nonblock);
 
-	mq_unlink(QUEUE_NAME);
-	mq_unlink(QUEUE_NAME_NONBLOCK);
+	mq_unlink(queue_name);
+	mq_unlink(queue_name_nonblock);
 }
 
 static void sighandler(int sig LTP_ATTRIBUTE_UNUSED) { }
@@ -39,14 +39,17 @@ static void setup_common(void)
 {
 	int i;
 
+	snprintf(queue_name, sizeof(queue_name), "/test_mqueue_%d", getpid());
+	snprintf(queue_name_nonblock, sizeof(queue_name_nonblock), "/test_mqueue_nonblock_%d", getpid());
+
 	act.sa_handler = sighandler;
 	sigaction(SIGINT, &act, NULL);
 
 	cleanup_common();
 
 	fd_root = SAFE_OPEN("/", O_RDONLY);
-	fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, 0700, NULL);
-	fd_nonblock = SAFE_MQ_OPEN(QUEUE_NAME_NONBLOCK, O_CREAT | O_EXCL | O_RDWR |
+	fd = SAFE_MQ_OPEN(queue_name, O_CREAT | O_EXCL | O_RDWR, 0700, NULL);
+	fd_nonblock = SAFE_MQ_OPEN(queue_name_nonblock, O_CREAT | O_EXCL | O_RDWR |
 		O_NONBLOCK, 0700, NULL);
 
 	for (i = 0; i < MAX_MSGSIZE; i++)
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Team,

I saw my issue after sending the email. Can you please close this one? I cleaned up and submitted this to replace it,
https://lists.linux.it/pipermail/ltp/2026-February/046485.html.

thank you,

stephen
He/His/Him

Quoted 64 lines · Stephen Bertram

This change allows for unique queue names per
process, when executed in parallel with -w #.

---
 testcases/kernel/syscalls/utils/mq.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/utils/mq.h +7 -6
index da45d2daf..eb66328d5 100644
@@ -12,9 +12,9 @@
 
 #define MAX_MSGSIZE    8192
 #define MSG_LENGTH     10
-#define QUEUE_NAME     "/test_mqueue"
-#define QUEUE_NAME_NONBLOCK    "/test_mqueue_nonblock"
 
+static char queue_name[64];
+static char queue_name_nonblock[64];
 static char smsg[MAX_MSGSIZE];
 static struct sigaction act;
 
@@ -29,8 +29,8 @@ static void cleanup_common(void)
        if (fd_nonblock > 0)
                SAFE_CLOSE(fd_nonblock);
 
-       mq_unlink(QUEUE_NAME);
-       mq_unlink(QUEUE_NAME_NONBLOCK);
+       mq_unlink(queue_name);
+       mq_unlink(queue_name_nonblock);
 }
 
 static void sighandler(int sig LTP_ATTRIBUTE_UNUSED) { }
@@ -39,14 +39,17 @@ static void setup_common(void)
 {
        int i;
 
+       snprintf(queue_name, sizeof(queue_name), "/test_mqueue_%d",
 getpid());
+       snprintf(queue_name_nonblock, sizeof(queue_name_nonblock),
 "/test_mqueue_nonblock_%d", getpid());
+
        act.sa_handler = sighandler;
        sigaction(SIGINT, &act, NULL);
 
        cleanup_common();
 
        fd_root = SAFE_OPEN("/", O_RDONLY);
-       fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, 0700,
 NULL);
-       fd_nonblock = SAFE_MQ_OPEN(QUEUE_NAME_NONBLOCK, O_CREAT | O_EXCL |

O_RDWR |
+ fd = SAFE_MQ_OPEN(queue_name, O_CREAT | O_EXCL | O_RDWR, 0700,
NULL);
+ fd_nonblock = SAFE_MQ_OPEN(queue_name_nonblock, O_CREAT | O_EXCL |
O_RDWR |

                O_NONBLOCK, 0700, NULL);

        for (i = 0; i < MAX_MSGSIZE; i++)

--
2.52.0

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp