why gen_tcp:controlling_process() can failed with badarg?

Hi.

I have a problem with one module of ejabberd. It is http_bind. But when I debug deeply I found that after accept socket and spawning hadling process and when reasign process for recieve data for new created process by calling gen_tcp:controlling_process() failed with badarg, WHY?

...

{ok, Socket} = get_tcp:accept(ListenSocket),
Opts = [{active, false}, ...],

% here function return result of proc_lib:spawn_link(handler, ...)
{ok, Pid} = ejabberd_http:start({gen_tcp, Socket}, Opts),

gen_tcp:controlling_process(Socket, Pid),

: {badarg, [
{erlang, port_connect, [#Port<0.140743856>, <0.5939.4350>]},
{inet, tcp_controlling_process, 2},
{ejabberd_socket,start,4},
{ejabberd_listener,accept,3},
{proc_lib,init_p,5}
]}
any help?

Quote: I have a problem with

Quote:

I have a problem with one module of ejabberd. It is http_bind.

Do you mean the file src/web/ejabberd_http_bind.erl included in ejabberd? I didn't find anywhere in ejabberd source code the lines you mention.

Quote:

{badarg, [
{erlang, port_connect, [#Port<0.140743856>, <0.5939.4350>]},
{inet, tcp_controlling_process, 2},
{ejabberd_socket,start,4},
{ejabberd_listener,accept,3},
{proc_lib,init_p,5}
]}

The error message indicates that the call to erlang:port_connect failed due to badarg.

The erlang documentation about that function http://www.erlang.org/doc/man/erlang.html says:

Quote:

port_connect(Port, Pid) -> true

...

Failure: badarg if Port is not an open port or the registered name of an open port, or if Pid is not an existing local pid.

Syndicate content