Bug 46632

Summary: mod_jk's sockets close prematurely when the server forks a child
Product: Tomcat Connectors Reporter: John Leslie <jleslie>
Component: mod_jkAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description John Leslie 2009-01-29 14:52:42 UTC
mod_jk registers its cleanup handler to be called both during plain_cleanup and child_cleanup:

  apr_pool_cleanup_register(p, s, jk_apr_pool_cleanup, jk_apr_pool_cleanup);

So, whenever a server forks a child, ie, when mod_cgi creates its child process, jk_apr_pool_cleanup() gets called.  jk_apr_pool_cleanup() does a shutdown() on its sockets, which closes down the socket for the parent process.

Maybe it should use close() instead of shutdown(), or be registered as apr_pool_cleanup_register(p, s, jk_apr_pool_cleanup, jk_apr_pool_cleanup_null); ?

Note, with mod_jk 1.2.18, a load balancing worker isn't able to recover from this, and it brings down the whole LB worker for awhile.  1.2.27 seems to be able to recover.

After a CGI is hit and jk's sockets get closed underneath it, the logs look like:

[Wed Jan 28 21:39:50 2009] [22841:42432] [info]  ajp_send_request::jk_ajp_common.c (1178): Socket 75 is not connected any more (errno=-1)
[Wed Jan 28 21:39:50 2009] [22841:42432] [info]  ajp_send_request::jk_ajp_common.c (1202): Error sending request. Will try another pooled connection
[Wed Jan 28 21:39:50 2009] [22841:42432] [info]  ajp_send_request::jk_ajp_common.c (1224): All endpoints are disconnected or dead
[Wed Jan 28 21:39:50 2009] [22841:42432] [info]  ajp_service::jk_ajp_common.c (1783): Sending request to tomcat failed,  recoverable operation attempt=1
Comment 1 Mladen Turk 2009-12-21 03:26:27 UTC
Fixed in the SVN.

If needed the child cleanup certainly cannot be the same as standard pool cleanup we are using currently.
Comment 2 Rainer Jung 2010-02-23 02:48:07 UTC
Will be part of 1.2.29.
Comment 3 Mark Thomas 2010-04-06 15:00:58 UTC
Spam removal
Comment 4 Konstantin Kolinko 2010-04-06 22:52:25 UTC
Restoring the original value of OS/Version field.