From 4d21dbe1c6b3fe98a5c24516e8d839df59bd6040 Mon Sep 17 00:00:00 2001 From: Matthew Kent Date: Thu, 29 Jul 2021 14:54:40 -0700 Subject: [PATCH] Only wait when necessary. --- ext/rbtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/rbtrace.c b/ext/rbtrace.c index 2a1a05e..3eae216 100644 --- a/ext/rbtrace.c +++ b/ext/rbtrace.c @@ -1067,7 +1067,7 @@ rbtrace__receive(void *data) // wait up to a second for the message to arrive for (n=0; n<10 && ret==-1; n++) { ret = msgrcv(rbtracer.mqi_id, &msg, sizeof(msg)-sizeof(long), 0, IPC_NOWAIT); - nanosleep((const struct timespec[]){{0, (100 % 1000) * 1000000}}, NULL); // 100ms + if (ret == -1) nanosleep((const struct timespec[]){{0, (100 % 1000) * 1000000}}, NULL); // 100ms } if (ret == -1) {