-
Notifications
You must be signed in to change notification settings - Fork 357
Sockets leak in half-close state (lsof: can't identify protocol) #34
Comments
I can confirm this leak, we also have a growing number of "can't identify protocol" open sockets, until the FD limit is hit. |
It seems that sockets are not closed properly if the connection can't be established. |
Should server.c be using httpDestroyConnection? What is httpDestroyConnection there for? |
Lookes like the same bug as #61. |
We are having this issue too. Are there any workarounds? |
Hi @jech, We keep seeing this issue, though a regular restart of polipo mitigates it. Any fixes coming up? Thanks, |
Btw, it looks like the leaked connections are stuck in this state (proxy client is also on localhost):
|
Debian bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756572 seems to describe the same problem. |
post your "uname -a && sysctl -a" output please, it seems that I've fixed this problem on Ubuntu |
Hi @netsafe, Output below. Polipo version is 1.1.1-5 Thanks,
|
try this in a kernel with timer HZ=1000 and preemtion type "Server" without dynticks: /etc/sysctl.conf - Configuration file for setting system variablesSee /etc/sysctl.d/ for additonal system variablesSee sysctl.conf (5) for information.#kernel.domainname = example.com Uncomment the following to stop low-level messages on consolekernel.printk = 3 4 1 3 ##############################################################3 Functions previously found in netbaseUncomment the next two lines to enable Spoof protection (reverse-path filter)Turn on Source Address Verification in all interfaces toprevent some spoofing attacks#net.ipv4.conf.default.rp_filter=1 Uncomment the next line to enable TCP/IP SYN cookiesSee http://lwn.net/Articles/277146/Note: This may impact IPv6 TCP sessions too#net.ipv4.tcp_syncookies=1 Uncomment the next line to enable packet forwarding for IPv4#net.ipv4.ip_forward=1 Uncomment the next line to enable packet forwarding for IPv6Enabling this option disables Stateless Address Autoconfigurationbased on Router Advertisements for this host#net.ipv6.conf.all.forwarding=1 ################################################################### Additional settings - these settings can improve the networksecurity of the host and prevent against some network attacksincluding spoofing attacks and man in the middle attacks throughredirection. Some network environments, however, require that thesesettings are disabled so review and enable them as needed.Do not accept ICMP redirects (prevent MITM attacks)#net.ipv4.conf.all.accept_redirects = 0 orAccept ICMP redirects only for gateways listed in our defaultgateway list (enabled by default)net.ipv4.conf.all.secure_redirects = 1Do not send ICMP redirects (we are not a router)#net.ipv4.conf.all.send_redirects = 0 Do not accept IP source route packets (we are not a router)#net.ipv4.conf.all.accept_source_route = 0 Log Martian Packets#net.ipv4.conf.all.log_martians = 1 rpi tweaksvm.swappiness=10 sysctl config#net.ipv4.ip_forward=1 ipv6 settings (no autoconfiguration)net.ipv6.conf.default.autoconf=0 net.ipv6.conf.default.disable_ipv6=1 net.ipv4.ip_local_port_range = 1024 65535 net.ipv4.tcp_rmem = 10240 87380 12582912 net.core.rmem_max=12582912 net.ipv4.tcp_rmem = 10240 87380 12582912 fs.file-max=6485045 net.core.netdev_max_backlog=5000 net.ipv4.tcp_dsack=0 kernel.core_uses_pid = 1 net.ipv4.conf.all.accept_redirects = 0 |
Hi @netsafe, Can you please provide an overview of what the problem is and how these kernel settings solve it? Also, is there a fix possible in polipo user-space? Thanks, |
@phraktle The fix was not just for polipo, actually. As far as I've figured it out, there are three vectors of solving this, but only in addition all three of them are solving problem:
The problem itself resides in resource-hanging, not leaking! Because if it was a leak, no tweaks could heal it. They're just hanged, "unable to being reused" + "awaiting some dumb timeout"... Please try this recipe and tell me if it works : I'm making my distro now(Linux) for Raspberry Pi, so this feedback will be vital. Thanks beforehand! |
@netsafe can't agree with you. Right now my proxy serves 200000+ active users every day (it was 10 times less when I opened this bug) with squid and it's running perfectly fine. No leaks with squid. |
Same story here. We've switched to squid and everything is fine now. |
@ValdikSS and @quetz : The problem in my case was also with Tor, that complained on almost-all-used connection limits, I2P used to be a slow-prank, polipo hanged the same way you've described here. Also if you'll do |
@jech, any thoughts on this? This occurs regularly enough to be an operational hazard with polipo :) |
Looks like the leak is happening with connections to unreachable HTTPS servers (while I don't see the same pattern for plain HTTP). For a while, the socket is in SYN_SENT state (as reported by lsof):
After a period of timeout, it transitions to this (and remains until polipo is restarted):
|
@phraktle @jech @netsafe I am also facing the exact same issue. Though it looks like some issue with the system configuration also can lead to this issue. I have the same jar deployed on multiples(~5) servers. But this FD leakage is happening only on 1 server. All other servers are working absolutely fine. I didn't find any difference in sysctl on the servers as well. Any thoughts on this ? |
@phraktle Second issue I spotted is in httpTimeoutHandler (http.c:276), where a socket is shutdown for reads and writes but the filedescriptor is not freed. Adding a close in here (after the shutdown to avoid lingering), I've not observed any more socket leaks. |
Hello. I'm running polipo with 20000+ active users. Polipo is allowed only to access certain IP addresses, all other addresses are closed with TCP Reset (this is done with iptables).
Number of used file descriptors is increased over time and it never gets less.
lsof -n | grep polipo | grep sock
After some time, polipo will reach open descriptors limit (8192 on my setup) and would fail on opening any connections.
The text was updated successfully, but these errors were encountered: