From 61aa3994b6dddb7498b5132770d71676cb22d790 Mon Sep 17 00:00:00 2001 From: gardners Date: Thu, 3 May 2012 13:29:48 +0930 Subject: [PATCH] try to force accept to be non-blocking. --- monitor.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index 98527f26..e42796a1 100644 --- a/monitor.c +++ b/monitor.c @@ -166,9 +166,13 @@ int monitor_poll() } /* Check for new connections */ - fcntl(monitor_named_socket,F_SETFL, - fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK); - while((s=accept(monitor_named_socket,&ignored_address,&ignored_length))>-1) { + while(( +#ifdef HAVE_LINUX_IF_H + s=accept4(monitor_named_socket,&ignored_address,&ignored_length,O_NONBLOCK) +#else + s=accept(monitor_named_socket,&ignored_address,&ignored_length) +#endif +)>-1) { int res = fcntl(s,F_SETFL, O_NONBLOCK); if (res) { close(s); continue; } struct ucred ucred; @@ -196,6 +200,9 @@ int monitor_poll() } ignored_length=sizeof(ignored_address); + WHY("look for next new client ..."); + fcntl(monitor_named_socket,F_SETFL, + fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK); } /* Read from any open connections */