tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sven Köhler <skoeh...@upb.de>
Subject Re: socket errors in catalina.out and mod_jk.log
Date Wed, 26 Feb 2003 18:19:07 GMT
>     void processConnection(MsgContext ep) {
>         try {
>             MsgAjp recv=new MsgAjp();
>             while( running ) {
>                 int status= this.receive( recv, ep );

i looked into these sources, and i am shocked!!!
this.receive() uses this.read(), and this method finally calls the 
InputStream.read(). as everybody should know, InputStrean.read() returns 
-1 if the end of the inputstream is reached.

this case is checked, but instead of doing something useful, the case is 
not really handled.

i suggest throwing an EOSException (EOS=EndOfStream) which is derived 
from IOException.
as this.read() is supposed to read exactly len bytes, it should only 
throw the EOSException, if the first call of InputStream.read() in the 
loop returns -1.

This exception can be catched down below, to more gracefully handle a 
connection-close.

BTW: there's also a comment that this improvement should be in AJP14. 
This has nothing to do with AJP14 (which is a protocol) but it's just 
bad programmed.

>                 if( status <= 0 ) {
>                     if( status==-3)
>                         log.debug( "server has been restarted or reset 
> this connection" );
>                     else
>                         log.warn("Closing ajp connection " + status );
>                     break;
>                 }
>                 ep.setLong( MsgContext.TIMER_RECEIVED, 
> System.currentTimeMillis());
> 
>                 ep.setType( 0 );
>                 // Will call next
>                 status= this.invoke( recv, ep );
>                 if( status!= JkHandler.OK ) {
>                     log.warn("processCallbacks status " + status );
>                     break;
>                 }
>             }
>         } catch( Exception ex ) {
>             if( ex.getMessage().indexOf( "Connection reset" ) >= 0)
>                 log.debug( "Server has been restarted or reset this 
> connection");
>             else if (ex.getMessage().indexOf( "Read timed out" ) >=0 )
>                 log.info( "connection timeout reached");
>             else
>                 log.error( "Error, processing connection", ex);



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message