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

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


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.

Diffing otp_src_R11B-3 otp_src_R11B-4:

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

prim_inet
---------
+fdopen(Protocol, Fd, inet)  -> fdopen1(Protocol, ?INET_AF_INET, Fd);
+fdopen(Protocol, Fd, inet6) -> fdopen1(Protocol, ?INET_AF_INET6, Fd);
+fdopen(_, _, _)             -> {error, einval}.

Mikael



More information about the erlang-questions mailing list