[Icecast-dev] [PATCH] nonblocking: remove usleep

Rosen Penev rosenp at gmail.com
Mon Oct 5 22:40:52 UTC 2020


usleep is removed in POSIX 2008 and is optionally unavailable with
uClibc-ng.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 examples/nonblocking.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/examples/nonblocking.c b/examples/nonblocking.c
index 8e38a94..27845ee 100644
--- a/examples/nonblocking.c
+++ b/examples/nonblocking.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <unistd.h>
 
 #include <shout/shout.h>
@@ -70,8 +71,10 @@ int main()
     if (ret == SHOUTERR_BUSY)
         printf("Connection pending...\n");
 
+    const struct timespec req = {0, 10 * 1000 * 1000};
+    struct timespec rem;
     while (ret == SHOUTERR_BUSY) {
-        usleep(10000);
+        nanosleep(&req, &rem);
         ret = shout_get_connected(shout);
     }
 
-- 
2.26.2



More information about the Icecast-dev mailing list