Bug 46632 - mod_jk's sockets close prematurely when the server forks a child
Summary: mod_jk's sockets close prematurely when the server forks a child
Status: RESOLVED FIXED
Alias: None
Product: Tomcat Connectors
Classification: Unclassified
Component: mod_jk (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-29 14:52 UTC by John Leslie
Modified: 2010-04-06 22:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.