日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

内嵌Tomcat的Connector对象的静态代码块

發布時間:2023/12/13 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 内嵌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 ofpending connections for sockfd may grow. If a connection requestarrives when the queue is full, the client may receive an error with anindication of ECONNREFUSED or, if the underlying protocol supportsretransmission, the request may be ignored so that a later reattempt atconnection succeeds

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

Now it specifies the queue length for completely establishedsockets waiting to be accepted, instead of the number of incompleteconnection requests. The maximum length of the queue for incompletesockets can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog. Whensyncookies 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 thatvalue; the default value in this file is 128. In kernels before2.4.25, this limit was a hard coded value, SOMAXCONN, with the value128.

  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

微信公眾號:

                      

?

?

轉載于:https://www.cnblogs.com/saaav/p/6341100.html

總結

以上是生活随笔為你收集整理的内嵌Tomcat的Connector对象的静态代码块的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。