[erlang-questions] inet_db:lookup_socket/1 failing for gen_tcp:controlling_process with mochiweb socket server

2 views
Skip to first unread message

Paul Oliver

unread,
Nov 24, 2008, 4:08:07 PM11/24/08
to erlang-q...@erlang.org
Hi all,

I have a curious bug that I've tracked down to a call to gen_tcp:controlling_process.  From the stack trace (simple example reproduced below) it seems that the port in question definitely exists, but the call to inet_db:lookup fails.  Has anyone seen this before or got any advice?

Thanks!
Paul.

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

Eshell V5.6.5  (abort with ^G)
1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection, start}}, {name, badger}, {port, 8888}]).
{ok,<0.32.0>}
2> Sock = gen_tcp:connect('127.0.0.1', 8888,  [binary, {packet, line}, {nodelay, true}], 3000000).
{ok,#Port<0.496>}
3> gen_tcp:controlling_process(Sock, self()).

=ERROR REPORT==== 24-Nov-2008::20:59:12 ===
** Generic server badger terminating
** Last message in was {'EXIT',<0.30.0>,
                           {function_clause,
                               [{inet_db,lookup_socket,[{ok,#Port<0.496>}]},
                                {gen_tcp,controlling_process,2},
                                {erl_eval,do_apply,5},
                                {shell,exprs,6},
                                {shell,eval_exprs,6},
                                {shell,eval_loop,3}]}}
** When Server state == {mochiweb_socket_server,8888,
                            {connection,start},
                            {local,badger},
                            2047,
                            {127,0,0,1},
                            #Port<0.488>,<0.37.0>,30}
** Reason for termination ==
** {function_clause,[{inet_db,lookup_socket,[{ok,#Port<0.496>}]},
                     {gen_tcp,controlling_process,2},
                     {erl_eval,do_apply,5},
                     {shell,exprs,6},
                     {shell,eval_exprs,6},
                     {shell,eval_loop,3}]}
** exception exit: function_clause
     in function  inet_db:lookup_socket/1
        called as inet_db:lookup_socket({ok,#Port<0.496>})
     in call from gen_tcp:controlling_process/2
4>

Paul Oliver

unread,
Nov 24, 2008, 5:28:10 PM11/24/08
to Matthias Lang, erlang-q...@erlang.org


On Mon, Nov 24, 2008 at 10:18 PM, Matthias Lang <matt...@corelatus.se> wrote:
On Monday, November 24, Paul Oliver wrote:
> Hi all,
>
> I have a curious bug that I've tracked down to a call to
> gen_tcp:controlling_process.  From the stack trace (simple example
> reproduced below) it seems that the port in question definitely exists, but
> the call to inet_db:lookup fails.  Has anyone seen this before or got any
> advice?

This seems too obvious to be your real problem, but just in case,
the second command isn't handling the return correctly. You probably
meant:

{ok, Sock} = gen_tcp:connect(...

Matt

Hi Matt,

Ah yes.  Thanks for pointing that out!  Yes, seems fine now:


1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection, start}}, {name, badger}, {port, 8888}]).
{ok,<0.32.0>}
2> {ok, Sock} = gen_tcp:connect('127.0.0.1', 8888,  [binary, {packet, line}, {nodelay, true}], 3000000).
{ok,#Port<0.496>}
3> Sock.
#Port<0.496>
4> gen_tcp:controlling_process(Sock, self()).
ok
5>

Back to the drawing board!

Cheers,
Paul.
> _______________________________________________
> erlang-questions mailing list
> erlang-q...@erlang.org
> http://www.erlang.org/mailman/listinfo/erlang-questions

Matthias Lang

unread,
Nov 24, 2008, 5:18:25 PM11/24/08
to Paul Oliver, erlang-q...@erlang.org
On Monday, November 24, Paul Oliver wrote:
> Hi all,
>
> I have a curious bug that I've tracked down to a call to
> gen_tcp:controlling_process. From the stack trace (simple example
> reproduced below) it seems that the port in question definitely exists, but
> the call to inet_db:lookup fails. Has anyone seen this before or got any
> advice?

This seems too obvious to be your real problem, but just in case,

the second command isn't handling the return correctly. You probably
meant:

{ok, Sock} = gen_tcp:connect(...

Matt

>

> _______________________________________________

Reply all
Reply to author
Forward
0 new messages