correct mq latency test
authorLaurent MAZET <laurent.mazet@thalesgroup.com>
Mon, 6 Oct 2025 09:52:42 +0000 (11:52 +0200)
committerLaurent MAZET <laurent.mazet@thalesgroup.com>
Mon, 6 Oct 2025 09:52:42 +0000 (11:52 +0200)
mq_lat.c

index 63b1145769d87876b4d11ed75479a35785552ad4..f7873976131a5f560046fce506fe0b9ed654e211 100644 (file)
--- 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);