From: Laurent MAZET Date: Mon, 6 Oct 2025 09:52:42 +0000 (+0200) Subject: correct mq latency test X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=6817c75cd191fb941dc05d591fbba3acde160b87;p=benchmarks.git correct mq latency test --- diff --git a/mq_lat.c b/mq_lat.c index 63b1145..f787397 100644 --- a/mq_lat.c +++ b/mq_lat.c @@ -62,11 +62,12 @@ void *ping (__attribute__((unused)) void *arg) while (try < nb_measurements) { + char *msg = get_msg (MSGLEN); + pthread_mutex_lock (&mutex); pthread_mutex_unlock (&mutex); sys_timestamp (&ts1); - char *msg = get_msg (MSGLEN); if (mq_send (mq, msg, MSGLEN, 0) == -1) { fprintf (stderr, "ping error: mq_send (%d)\n", try); rc = 1; @@ -107,7 +108,7 @@ void *pong (__attribute__((unused)) void *arg) pthread_mutex_unlock (&mutex); char buffer[MAXBUF] = { 0 }; - if (mq_receive (mq, buffer, sizeof(buffer), NULL) == -1) { + if (mq_receive (mq, buffer, sizeof(buffer) - 1, NULL) == -1) { fprintf (stderr, "pong error: mq_receive (%d)\n", try); rc = 1; pthread_exit (NULL);