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

    微信公众号:

                          

     

  • 相关阅读:
    基本技能训练之线程
    关于UEditor的使用配置(图片上传配置)
    PAT 乙级练习题1002. 写出这个数 (20)
    codeforces 682C Alyona and the Tree DFS
    codeforces 681D Gifts by the List dfs+构造
    codeforces 678E Another Sith Tournament 概率dp
    codeforces 680E Bear and Square Grid 巧妙暴力
    codeforces 678D Iterated Linear Function 矩阵快速幂
    codeforces 679A Bear and Prime 100 交互
    XTUOJ 1248 TC or CF 搜索
  • 原文地址:https://www.cnblogs.com/saaav/p/6341100.html
Copyright © 2011-2022 走看看