From 9d4d48e703fc0c22b7f3a8e75d77641bc37bc12e Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 13 Mar 2012 21:17:03 +0000 Subject: [PATCH] Using mg_sleep() instead of sleep() --- mongoose.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mongoose.c b/mongoose.c index b6b0bf9b..e9a5d59d 100644 --- a/mongoose.c +++ b/mongoose.c @@ -113,7 +113,7 @@ typedef long off_t; #define SHUT_WR 1 #define snprintf _snprintf #define vsnprintf _vsnprintf -#define sleep(x) Sleep((x) * 1000) +#define mg_sleep(x) Sleep(x) #define pipe(x) _pipe(x, BUFSIZ, _O_BINARY) #define popen(x, y) _popen(x, y) @@ -206,6 +206,7 @@ typedef struct DIR { #define mg_mkdir(x, y) mkdir(x, y) #define mg_remove(x) remove(x) #define mg_rename(x, y) rename(x, y) +#define mg_sleep(x) usleep((x) * 1000) #define ERRNO errno #define INVALID_SOCKET (-1) #define INT64_FMT PRId64 @@ -4079,7 +4080,7 @@ static void master_thread(struct mg_context *ctx) { // On windows, if read_set and write_set are empty, // select() returns "Invalid parameter" error // (at least on my Windows XP Pro). So in this case, we sleep here. - sleep(1); + mg_sleep(1000); #endif // _WIN32 } else { for (sp = ctx->listening_sockets; sp != NULL; sp = sp->next) { @@ -4148,7 +4149,7 @@ void mg_stop(struct mg_context *ctx) { // Wait until mg_fini() stops while (ctx->stop_flag != 2) { - (void) sleep(0); + mg_sleep(10); } free_context(ctx);