[erlang-questions] fd_server does not work with R11B-4

Mikael Magnusson mikma264@REDACTED
Wed May 9 10:26:47 CEST 2007


Mikael Magnusson wrote:
> Torbjorn Tornkvist wrote:
>> Hi,
>>
>> The fd_server (see jungerl) does not work with R11B-4.
>> I suspect it has to do with the following (excerpt from
>> the release notes):
>>
>>> http://www.erlang.org/download/otp_src_R11B-4.readme
>>>
>>>    OTP-6452  In the documentation of the driver entry field....
>> This is most unfortunate since fd_server is important for Yaws
>> users that want to open up privileged ports. The following is
>> what happends:
>>
>> )1> fdsrv:start().
>> {error,{error,{{error,driver_incorrect_version},
>>                 "/home/tobbe/blaha/lib/fd_server/priv"}}}
>>
>> A more complete testcase could be:
>>
>> fdsrv:start().
>> {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}).
>> gen_tcp:listen(81,[{fd, Fd}]).
>>
>> I've heard rumors that fd_server may be included in a future OTP 
>> releases. Could that be true ?
>>
>> Anyway, if anyone comes up with an updated driver, it would be
>> mighty good if it could be put into jungerl.
>>
>> Cheers, Tobbe
>> (Ps. Btw R11B-4 can't be built unless --disable-hipe is used [Debian 4. 
>> 0,Gentoo])
>>
> 
> It looks like inet_db:fdopen is at fault. The Family and Fd arguments 
> are swapped in the call to prim_inet:fdopen.

Correction, it's inet:fdopen, and the following patch solves the problem:

--- inet.erl.orig       2007-05-09 10:19:50.000000000 +0200
+++ inet.erl    2007-05-09 10:17:59.000000000 +0200
@@ -749,7 +749,7 @@
      fdopen(Fd, Opts, Protocol, Family, Module).

  fdopen(Fd, Opts, Protocol, Family, Module) ->
-    case prim_inet:fdopen(Protocol, Family, Fd) of
+    case prim_inet:fdopen(Protocol, Fd, Family) of
         {ok, S} ->
             case prim_inet:setopts(S, Opts) of
                 ok ->

Output from patched R11B-4:

1> fdsrv:start().
{ok,<0.33.0>}
2> {ok, Fd} = fdsrv:bind_socket(tcp, {{0,0,0,0}, 81}).
{ok,9}
3> gen_tcp:listen(81,[{fd, Fd}]).
{ok,#Port<0.107>}
4>

Mikael



More information about the erlang-questions mailing list