From: Christian Heller Date: Mon, 14 Apr 2014 12:24:53 +0000 (+0200) Subject: Server: Use nanosleep() instead of POSIX-obsolete usleep() in io.c. X-Git-Tag: tce~765 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7B%20deck_id%20%7D%7D/feed.xml?a=commitdiff_plain;h=4948c10c3a64bf76c977614ae735af2f8f9b2c2c;p=plomrogue Server: Use nanosleep() instead of POSIX-obsolete usleep() in io.c. --- diff --git a/src/server/io.c b/src/server/io.c index 8e7f9e9..4fbf6ed 100644 --- a/src/server/io.c +++ b/src/server/io.c @@ -1,6 +1,6 @@ /* src/server/io.c */ -#define _BSD_SOURCE /* usleep() */ +#define _POSIX_C_SOURCE 199309L #include "io.h" #include /* global errno */ #include /* PIPE_BUF */ @@ -10,8 +10,7 @@ #include /* free() */ #include /* strlen(), memcpy() */ #include /* time_t */ -#include /* time() */ -#include /* usleep() */ +#include /* time(), nanosleep() */ #include "../common/readwrite.h" /* try_fopen(), try_fclose_unlink_rename(), * try_fwrite(), try_fputc(), try_fgetc() */ @@ -92,10 +91,13 @@ static void read_file_into_queue() char * f_name = "read_file_into_queue()"; uint8_t wait_seconds = 5; time_t now = time(0); + struct timespec dur; + dur.tv_sec = 0; + dur.tv_nsec = 33333333; int test; while (EOF == (test = try_fgetc(world.file_in, f_name))) { - usleep(33); + nanosleep(&dur, NULL); if (time(0) > now + wait_seconds) { return;