DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29208>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29208

start listening on port after everything has been initialized.

           Summary: start listening on port after everything has been
                    initialized.
           Product: Tomcat 5
           Version: 5.0.18
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Connector:HTTP
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


We have several startup servlets that take a very long time to start (15
minutes).  Tomcat binds the server socket before it's ready to process requests.
This causes all sorts of headaches for us. Ideally, the socket should be bound
only when tomcat is really ready to process requests. This can be achieved
relatively simply by changing org.apache.tomcat.util.net.PoolTcpEndpoint and
moving the server socket binding code from initEndpoint to startEndpoint:

    public void initEndpoint() throws IOException, InstantiationException {
            if(factory==null)
                factory=ServerSocketFactory.getDefault();
    }

    public void startEndpoint() throws IOException, InstantiationException {
        if (!initialized) {
            initEndpoint();
            if(serverSocket==null) {
                    try {
                        if (inet == null) {
                            serverSocket = factory.createSocket(port, backlog);
                        } else {
                            serverSocket = factory.createSocket(port, backlog,
inet);
                        }
                    } catch ( BindException be ) {
                        throw new BindException(be.getMessage() + ":" + port);
                    }
            }
                if( serverTimeout >= 0 )
            serverSocket.setSoTimeout( serverTimeout );
            initialized = true;
        }
        if(isPool) {
            tp.start();
        }
        ...

A corresponding change should be made to the reinitialization code in
acceptSocket. I'm not sure I understand the subtleties of the reinitialization
code, so I'll leave that for the experts. (To my uninitiated eyes,
reinitializtion should be as simple as stopEndpoint(); startEndpoint();).

Thanks
Moh

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to