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;
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);