home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0dcbddd
)
Server: Use nanosleep() instead of POSIX-obsolete usleep() in io.c.
author
Christian Heller
<c.heller@plomlompom.de>
Mon, 14 Apr 2014 12:24:53 +0000
(14:24 +0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Mon, 14 Apr 2014 12:24:53 +0000
(14:24 +0200)
src/server/io.c
patch
|
blob
|
history
diff --git
a/src/server/io.c
b/src/server/io.c
index 8e7f9e9a2716fd632c55df8e6ec0e92083140b36..4fbf6ed07fad2dee6614a9f0f6843111f9ee7823 100644
(file)
--- a/
src/server/io.c
+++ b/
src/server/io.c
@@
-1,6
+1,6
@@
/* src/server/io.c */
/* src/server/io.c */
-#define _
BSD_SOURCE /* usleep() */
+#define _
POSIX_C_SOURCE 199309L
#include "io.h"
#include <errno.h> /* global errno */
#include <limits.h> /* PIPE_BUF */
#include "io.h"
#include <errno.h> /* global errno */
#include <limits.h> /* PIPE_BUF */
@@
-10,8
+10,7
@@
#include <stdlib.h> /* free() */
#include <string.h> /* strlen(), memcpy() */
#include <sys/types.h> /* time_t */
#include <stdlib.h> /* free() */
#include <string.h> /* strlen(), memcpy() */
#include <sys/types.h> /* time_t */
-#include <time.h> /* time() */
-#include <unistd.h> /* usleep() */
+#include <time.h> /* time(), nanosleep() */
#include "../common/readwrite.h" /* try_fopen(), try_fclose_unlink_rename(),
* try_fwrite(), try_fputc(), try_fgetc()
*/
#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);
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)))
{
int test;
while (EOF == (test = try_fgetc(world.file_in, f_name)))
{
-
usleep(33
);
+
nanosleep(&dur, NULL
);
if (time(0) > now + wait_seconds)
{
return;
if (time(0) > now + wait_seconds)
{
return;