From b10b989865a830a03cdeb7ef06336401cd0cb380 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Mon, 20 Feb 2012 23:27:40 +0000 Subject: [PATCH] Increasing master thread priority on Windows --- mongoose.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mongoose.c b/mongoose.c index f95f85ad..457a2f62 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4029,13 +4029,15 @@ static void master_thread(struct mg_context *ctx) { struct socket *sp; int max_fd; -#if defined(ISSUE_317) // Increase priority of the master thread +#if defined(_WIN32) + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); +#endif + +#if defined(ISSUE_317) struct sched_param sched_param; - int policy; - pthread_getschedparam(pthread_self(), &policy, &sched_param); - sched_param.sched_priority = sched_get_priority_max(policy); - pthread_setschedparam(pthread_self(), policy, &sched_param); + sched_param.sched_priority = sched_get_priority_max(SCHED_RR); + pthread_setschedparam(pthread_self(), SCHED_RR, &sched_param); #endif while (ctx->stop_flag == 0) {