On Tuesday, October 18, 2016 at 11:52:22 PM UTC+2, Saúl Ibarra Corretgé 
wrote:
>
>
> > One thing is that when I control-C out of the running server, it prints 
> > the following and then hangs: 
> > ^C[INFO] (../src/server.c:16) Received SIGINT, stopping... 
> > [INFO] (../src/server.c:107) Stopping workers... 
> > [INFO] (../src/worker.c:81) [Worker #0] stopped 
> > [INFO] (../src/worker.c:81) [Worker #1] stopped 
> > [INFO] (../src/worker.c:81) [Worker #3] stopped 
> > [INFO] (../src/worker.c:81) [Worker #2] stopped 
> > 
> > I have to kill -9 the process to terminate it. This is on CentOS 6.8 
> > using kernel 2.6.32 (hangs head in shame...). Perhaps too old to support 
> > SO_REUSEPORT? The #define is there and the compilation doesn't throw any 
> > warnings, but there. 
> > 
>
> Maybe it got backported? No idea, AFAIK it appeared on 3.7 or 3.9. It 
> used to work, though it may require an adjustment or 2 :-) At any rate 
> is more of a toy example than a functioning one... 
>

I got it to respect Ctrl-C with this patch, although I am not sure the 
semantics are right:

diff --git a/src/worker.c b/src/worker.c
index 99e4297..92ac32a 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -56,7 +56,7 @@ static void uttp__worker_close(uttp_worker_t* worker) {
     }
     ASSERT(QUEUE_EMPTY(&worker->conn_queue));

-    r = uv_run(&worker->loop, UV_RUN_DEFAULT);
+    r = uv_run(&worker->loop, UV_RUN_NOWAIT);
     ASSERT(r == 0);

     r = uv_loop_close(&worker->loop);

What exactly do you mean by your code being "more of a toy example than a 
functioning one"? It seems quite good to me as the basis for a 
multi-threaded HTTP server. What would you say is missing here?

Cheers,
Gonzalo

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to