zoukankan      html  css  js  c++  java
  • 内嵌Tomcat的Connector对象的静态代码块

      在排查问题的过程中发现Connector对象有一个静态代码块:

        static {
            replacements.put("acceptCount", "backlog");
            replacements.put("connectionLinger", "soLinger");
            replacements.put("connectionTimeout", "soTimeout");
            replacements.put("rootFile", "rootfile");
        }

      其中backlog在linux里可以通过man listen > listen.txt导出看到:

    The backlog argument defines the maximum length to which the  queue  of
           pending  connections  for  sockfd  may  grow.   If a connection request
           arrives when the queue is full, the client may receive an error with an
           indication  of  ECONNREFUSED  or,  if  the underlying protocol supports
           retransmission, the request may be ignored so that a later reattempt at
           connection succeeds

      TCP连接过程中有三个结构分别用于保存:每一个客户端的连接,握手成功的连接,正在握手中但尚未成功的连接。内核为任何一个给定的监听套接口维护两个队列:1、未完成连接队列(incomplete connection queue),每个这样的SYN分节对应其中一项:已由某个客户发出并到达服务器,而服务器正在等待完成相应的TCP三路握手过程。这些套接口处于SYN_RCVD状态;2、已完成连接队列(completed connection queue),每个已完成TCP三路握手过程的客户对应其中一项。这些套接口处于ESTABLISHED状态。

     Now it specifies the  queue  length  for  completely  established
           sockets  waiting  to  be  accepted, instead of the number of incomplete
           connection requests.  The maximum length of the  queue  for  incomplete
           sockets  can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog.  When
           syncookies are enabled there is no logical maximum length and this set‐
           ting is ignored.  See tcp(7) for more information.
    
           If    the   backlog   argument   is   greater   than   the   value   in
           /proc/sys/net/core/somaxconn, then it is  silently  truncated  to  that
           value;  the  default  value  in  this  file  is 128.  In kernels before
           2.4.25, this limit was a hard coded value, SOMAXCONN,  with  the  value
           128.

      backlog是调用listen方法时传入的参数,指定可以握手成功的最大连接数量,但是对于linux如果这个值大于/proc/sys/net/core/somaxconn设置的值,将会取somaxconn的值替代它。所以要注意,somaxconn值如果设置的不够大,Tomcat配置中的连接数值是不会起作用的,可以通过sysctl -w net.core.somaxconn=***来修改这个值;对应的/proc/sys/net/ipv4/tcp_max_syn_backlog设置的是最大未完成连接队列的值,但是这个值会在/proc/sys/net/ipv4/tcp_syncookies是1的时候失效。具体实现过程可参考:http://blog.csdn.net/raintungli/article/details/37913765

      soLinger用于指定socket在关闭TCP连接时如何操作。内核缺省close操作是立即返回,如果有数据残留在套接口缓冲区中则系统将试着将这些数据发送给对方。自定义了这项设置可以选择是缓冲区数据全部丢弃立即关闭、发送完或超时再关闭或延迟指定时间后关闭。参考:http://blog.csdn.net/factor2000/article/details/3929816

      soTimeout用于指定数据超时时间,单位是毫秒,就是说在连续的数据传输过程中,两个包之间可接受的最大间隔的时间,如果设置为0则认为不限制间隔时间。

      rootfile由于和我的问题关系不大,所以暂时没有细看,会在整理容器的时候看看。应该是指根文件系统,参考:http://www.eeskill.com/article/index/id/1358.html

    ==========================================================

    咱最近用的github:https://github.com/saaavsaaa

    微信公众号:

                          

     

  • 相关阅读:
    Linux 学习 step by step (2)
    公共建筑能耗监测平台的GPRS通讯服务器的开发方法分享
    幸福框架:可扩展的、动态的、万能的 编号生成器
    C++ Data Member内存布局
    .NET程序集强命名删除与再签名技术 源代码剖析
    hdu 2191(多重背包)
    五种情况下会刷新控件状态(刷新所有子FWinControls的显示)——从DFM读取数据时、新增加子控件时、重新创建当前控件的句柄时、设置父控件时、显示状态被改变时
    终于懂了:Delphi消息的Result域出现的原因——要代替回调函数的返回值!(MakeObjectInstance不会帮助处理(接收)消息回调函数的返回值)
    Firemonkey实现Mac OS程序中内嵌浏览器的功能(自己动手翻译,调用苹果提供的webkit框架)
    感悟:市场经济看得就是主观能动性,有则富贵可及,无则无限趋于零
  • 原文地址:https://www.cnblogs.com/saaav/p/6341100.html
Copyright © 2011-2022 走看看