[erlang-questions] Sockets leak in ssl_esock

Sergei Golovan <>
Thu Jul 17 13:47:02 CEST 2008


Hi!

Appears that ssl_esock leaks sockets in case when a remote server
drops an already established connection. The following output was
obtained by enabling debug in ssl_esock:

Erlang (BEAM) emulator version 5.6.3 [source] [smp:2]
[async-threads:0] [kernel-poll:false]

Eshell V5.6.3  (abort with ^G)
1> ssl:start().
ok
2> ssl:connect("localhost",636,[]).


  fd = 4
Local proxy listen socket: fd = 4, port = 39302
==========LOOP=============
MASKS SET FOR FD:
Before poll/select: 1 descriptor (total 4)
[CONNECT_CMD] intref = 1, lipstring = 0.0.0.0 lport = 0, fipstring =
127.0.0.1 fport = 636, flags =
  fd = 5
  fd = 5
-> WAIT_CONNECT fd = 5
==========LOOP=============
MASKS SET FOR FD: 5 (write)
Before poll/select: 2 descriptors (total 5)
-----------------------------------
WAIT_CONNECT fd = 5
-> SSL_CONNECT
==========LOOP=============
MASKS SET FOR FD: 5 (write)
Before poll/select: 2 descriptors (total 5)
-----------------------------------
SSL_CONNECT fd = 5
==========LOOP=============
MASKS SET FOR FD: 5 (read)
Before poll/select: 2 descriptors (total 5)
-----------------------------------
SSL_CONNECT fd = 5
==========LOOP=============
MASKS SET FOR FD: 5 (read)
Before poll/select: 2 descriptors (total 5)
-----------------------------------
SSL_CONNECT fd = 5
-> CONNECTED
==========LOOP=============
MASKS SET FOR FD:
Before poll/select: 2 descriptors (total 5)
-----------------------------------
[PROXY_LISTEN_SOCK] conn accepted: proxyfd = 6, peer port = 41525
Error calling accept()
CONNECTED[PROXY_JOIN_CMD] fd = 5 portnum = 41525
{ok,{sslsocket,5,<0.43.0>}}
3>
-----------------------------------------------------------------------------------------------
(Here connection is established successfully.)

lsof shows the following:

ssl_esock  4313      sergei    4u     IPv4           12163520
        TCP 127.0.0.1:39302 (LISTEN)
ssl_esock  4313      sergei    5u     IPv4           12163527
        TCP 127.0.0.1:59963->127.0.0.1:ldaps (ESTABLISHED)
ssl_esock  4313      sergei    6u     IPv4           12163530
        TCP 127.0.0.1:39302->127.0.0.1:41525 (ESTABLISHED)
-----------------------------------------------------------------------------------------------
 -> JOINED
==========LOOP=============
MASKS SET FOR FD: 6 (read) 5 (read)
Before poll/select: 2 descriptors (total 6)

3> -----------------------------------
JOINED: read from ssl fd = 5
read from fd = 5, cc = 0
SSL eof
==========LOOP=============
MASKS SET FOR FD: 6 (read)
Before poll/select: 2 descriptors (total 6)
-----------------------------------
JOINED: reading from proxy, proxyfd = 6
read from proxyfd = 6, cc = 0
-----------------------------------------------------------------------------------------------
(Here I've shutdown the remote server.)
-----------------------------------------------------------------------------------------------
proxy eof or error
-> DEFUNCT
==========LOOP=============
MASKS SET FOR FD:
Before poll/select: 2 descriptors (total 6)
-----------------------------------------------------------------------------------------------

lsof shows the following:

ssl_esock  4313      sergei    4u     IPv4           12163520
        TCP 127.0.0.1:39302 (LISTEN)
ssl_esock  4313      sergei    5u     sock                0,5
   12163527 can't identify protocol
ssl_esock  4313      sergei    6u     sock                0,5
   12163530 can't identify protocol

Note the two last sockets. They are stuck forever (until ssl_esock is running).

Is this a known bug? Is there a way to fix it?

Cheers!
-- 
Sergei Golovan



More information about the erlang-questions mailing list