小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

內(nèi)嵌Tomcat的Connector對象的靜態(tài)代碼塊

 WindySky 2017-07-23

  在排查問題的過程中發(fā)現(xiàn)Connector對象有一個靜態(tài)代碼塊:

復(fù)制代碼
    static {
        replacements.put("acceptCount", "backlog");
        replacements.put("connectionLinger", "soLinger");
        replacements.put("connectionTimeout", "soTimeout");
        replacements.put("rootFile", "rootfile");
    }
復(fù)制代碼

  其中backlog在linux里可以通過man listen > listen.txt導(dǎo)出看到:

復(fù)制代碼
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
復(fù)制代碼

  TCP連接過程中有三個結(jié)構(gòu)分別用于保存:每一個客戶端的連接,握手成功的連接,正在握手中但尚未成功的連接。內(nèi)核為任何一個給定的監(jiān)聽套接口維護(hù)兩個隊列:1、未完成連接隊列(incomplete connection queue),每個這樣的SYN分節(jié)對應(yīng)其中一項:已由某個客戶發(fā)出并到達(dá)服務(wù)器,而服務(wù)器正在等待完成相應(yīng)的TCP三路握手過程。這些套接口處于SYN_RCVD狀態(tài);2、已完成連接隊列(completed connection queue),每個已完成TCP三路握手過程的客戶對應(yīng)其中一項。這些套接口處于ESTABLISHED狀態(tài)。

復(fù)制代碼
 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.
復(fù)制代碼

  backlog是調(diào)用listen方法時傳入的參數(shù),指定可以握手成功的最大連接數(shù)量,但是對于linux如果這個值大于/proc/sys/net/core/somaxconn設(shè)置的值,將會取somaxconn的值替代它。所以要注意,somaxconn值如果設(shè)置的不夠大,Tomcat配置中的連接數(shù)值是不會起作用的,可以通過sysctl -w net.core.somaxconn=***來修改這個值;對應(yīng)的/proc/sys/net/ipv4/tcp_max_syn_backlog設(shè)置的是最大未完成連接隊列的值,但是這個值會在/proc/sys/net/ipv4/tcp_syncookies是1的時候失效。具體實現(xiàn)過程可參考:http://blog.csdn.net/raintungli/article/details/37913765

  soLinger用于指定socket在關(guān)閉TCP連接時如何操作。內(nèi)核缺省close操作是立即返回,如果有數(shù)據(jù)殘留在套接口緩沖區(qū)中則系統(tǒng)將試著將這些數(shù)據(jù)發(fā)送給對方。自定義了這項設(shè)置可以選擇是緩沖區(qū)數(shù)據(jù)全部丟棄立即關(guān)閉、發(fā)送完或超時再關(guān)閉或延遲指定時間后關(guān)閉。參考:http://blog.csdn.net/factor2000/article/details/3929816

  soTimeout用于指定數(shù)據(jù)超時時間,單位是毫秒,就是說在連續(xù)的數(shù)據(jù)傳輸過程中,兩個包之間可接受的最大間隔的時間,如果設(shè)置為0則認(rèn)為不限制間隔時間。

  rootfile由于和我的問題關(guān)系不大,所以暫時沒有細(xì)看,會在整理容器的時候看看。應(yīng)該是指根文件系統(tǒng),參考:http://www./article/index/id/1358.html

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

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

微信公眾號:

                      

 

 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多