java处理请求的流程_Tomcat处理请求流程的源代码研究

publicvoidprocessConnection(TcpConnection connection,

Object thData[]) {

Socket socket=null;

Http11Processor  processor=null;try{

processor=(Http11Processor)thData[Http11BaseProtocol.THREAD_DATA_PROCESSOR];if(processorinstanceofActionHook) {

((ActionHook) processor).action(ActionCode.ACTION_START,null);

}

socket=connection.getSocket();

InputStream in=socket.getInputStream();

OutputStream out=socket.getOutputStream();if( proto.secure ) {

SSLSupport sslSupport=null;if(proto.sslImplementation!=null)

sslSupport=proto.sslImplementation.getSSLSupport(socket);

processor.setSSLSupport(sslSupport);

}else{

processor.setSSLSupport(null);

}

processor.setSocket( socket );

processor.process(in, out);//If unread input arrives after the shutdownInput() call//below and before or during the socket.close(), an error//may be reported to the client.  To help troubleshoot this//type of error, provide a configurable delay to give the//unread input time to arrive so it can be successfully read//and discarded by shutdownInput().if( proto.socketCloseDelay>=0) {try{

Thread.sleep(proto.socketCloseDelay);

}catch(InterruptedException ie) {/*ignore*/}

}

TcpConnection.shutdownInput( socket );

}catch(java.net.SocketException e) {//SocketExceptions are normalHttp11BaseProtocol.log.debug

(sm.getString

("http11protocol.proto.socketexception.debug"), e);

}catch(IOException e) {//IOExceptions are normalHttp11BaseProtocol.log.debug

(sm.getString

("http11protocol.proto.ioexception.debug"), e);

}//Future developers: if you discover any other//rare-but-nonfatal exceptions, catch them here, and log as//above.catch(Throwable e) {//any other exception or error is odd. Here we log it//with "ERROR" level, so it will show up even on//less-than-verbose logs.Http11BaseProtocol.log.error

(sm.getString("http11protocol.proto.error"), e);

}finally{//if(proto.adapter != null) proto.adapter.recycle();//processor.recycle();if(processorinstanceofActionHook) {

((ActionHook) processor).action(ActionCode.ACTION_STOP,null);

}//recycle kernel sockets ASAPtry{if(socket!=null) socket.close (); }catch(IOException e) {/*ignore*/}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值