waxmiguelito / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Mongosse does not exit after mg_stop when keep-alive is enabled and requests are still received #265

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enable keep-alive
2. Do HTTP request and keep connection open ("keep-alive")
3. Call mg_stop
4. Repeat HTTP requests

What is the expected output? What do you see instead?
After the mg_stop Mongoose should stop. Due to the fact that keep-alive is 
active the thread stays in process_new_connection, without returning to the 
worker_thread function where the stop_flag is checked.

What version of the product are you using? On what operating system?
3.1

Please provide any additional information below.

The following change fixes the problem. It will exit process_new_connection the 
next time a request is handled.

--- mongoose.c  ma jul  4 09:18:12 2011
+++ mongoose_new.c  ma jul  4 13:01:22 2011
@@ -3872,7 +3872,8 @@
       discard_current_request_from_buffer(conn);
     }
     // conn->peer is not NULL only for SSL-ed proxy connections
-  } while (conn->peer || (keep_alive_enabled && should_keep_alive(conn)));
+  } while ((conn->peer || (keep_alive_enabled && should_keep_alive(conn))) &&
+           (conn->ctx->stop_flag == 0));
 }

 // Worker threads take accepted socket from the queue

Original issue reported on code.google.com by borkh...@gmail.com on 4 Jul 2011 at 11:10

GoogleCodeExporter commented 9 years ago
Submitted 
https://code.google.com/p/mongoose/source/detail?r=d28a3269d2fbef4d7d801236b4c69
f089fa83d86, thank you

Original comment by valenok on 4 Jul 2011 at 12:02