[erlang-bugs] Bug in ssl:controlling_process?

Andrew Thompson andrew@REDACTED
Mon Sep 24 22:18:28 CEST 2012


3> {ok, S} = ssl:listen(0, [{certfile, "cert.pem"}]).
{ok,{sslsocket,new_ssl,
               {#Port<0.667>,
                {config,{ssl_options,[],verify_none,
                                     {#Fun<ssl.1.54384637>,[]},
                                     false,false,undefined,1,
                                     "cert.pem",
                                     undefined,
                                     "cert.pem",
                                     undefined,[],undefined,[],undefined,undefined,
                                     [<<0,...>>,<<...>>|...],
                                     #Fun<ssl.0.54384637>,true,...},
                        [],
                        {socket_options,list,0,0,0,true},
                        [{packet_size,0},
                         {packet,0},
                         {header,0},
                         {active,false},
                         {mode,binary}],
                        {gen_tcp,tcp,tcp_closed,tcp_error}}}}}
4> ssl:controlling_process(S, self()).
** exception error: no function clause matching ssl:controlling_process({sslsocket,new_ssl,
                                                                                   {#Port<0.667>,
                                                                                    {config,{ssl_options,[],verify_none,
                                                                                                         {#Fun<ssl.1.54384637>,[]},
                                                                                                         false,false,undefined,1,
                                                                                                         "cert.pem",
                                                                                                         undefined,
                                                                                                         "cert.pem",
                                                                                                         undefined,[],undefined,[],undefined,undefined,
                                                                                                         [<<0,57>>,<<0,...>>,<<...>>|...],
                                                                                                         #Fun<ssl.0.54384637>,true,268435456,...},
                                                                                            [],
                                                                                            {socket_options,list,0,0,0,true},
                                                                                            [{packet_size,0},
                                                                                             {packet,0},
                                                                                             {header,0},
                                                                                             {active,false},
                                                                                             {mode,binary}],
                                                                                            {gen_tcp,tcp,tcp_closed,tcp_error}}}},
                                                                        <0.36.0>) (ssl.erl, line 273)

ssl:controlling_process reads as follows:

controlling_process(#sslsocket{pid = Pid}, NewOwner) when is_pid(Pid) ->
    ssl_connection:new_user(Pid, NewOwner).

But, in the sslsocket, pid is NOT a pid, it is that giant tuple containing
state information.

Doing a connect() seems to give me a pid in the sslsocket:

ssl:connect("imap.gmail.com", 993, [{certfile, "cert.pem"}]).
{ok,{sslsocket,new_ssl,<0.56.0>}}

Yet, in the documentation, both listen() and connect() return type
sslsocket() which is a what controlling_process is documented as taking
as the first argument?

Maybe a new clause of controlling process that looks like this:

controlling_process(#sslsocket{pid = {ListenSocket, Config}}, NewOwner) ->
    #config{cb={CbModule, _, _, _}} = Config,
    CbModule:controlling_process(ListenSocket, NewOwner).

Seems like that'd let you change the controlling process for 'listen
sockets' as well, assuming the caller is the current owner?

Andrew




More information about the erlang-bugs mailing list