inets ftp bug

Ingela Anderton ingela@REDACTED
Wed Aug 24 08:39:54 CEST 2005


Actually this is an already known and fixed problem in inets-4.5.2

Realeasnotes says:

[ftp, client] Calling ftp:recv/2 twice on the same connection failed
due to that the last message on the ctrl channel was not appropriately
taken care of. This could potentially cause a problem for any
operation performed on the same connection where there had previously
been an ftp:recv/2 call. Also, in some cases, when the process tries
to close the data connection, it does not take into account that the
data connection may actually not have been established.

This will definitely be part of the next open source release. We are
actually working on inets-4.5.3 at the moment that will fix some more
bugs and add some new nice features to the inets components (not only
ftp). The aim is that this version should be the one in the next open
source release.


Serge Aleynikov wrote:
> OTP team:
> 
> I found a bug in the inets' ftp.erl client that can be patched by 
> applying the ftp.erl.patch file to the source.
> 
> The bug is seen when you try to download more than one file in a row 
> using ftp:recv/2 function.  For some reason this bug doesn't occur when 
> tracing is enabled (and/or debugger application is running).
> 
> Use the following to reproduce the bug:
> 
> ftp_test:test(Host, User, Password, RemoteDir, RemoteFile).
> 
> ~/tmp/dirtest>erl -pa ~/Projects/DRP/lib/drpdb-1.0/ebin
> Erlang (BEAM) emulator version 5.4.8 [source] [hipe] [threads:0]
> 
> Eshell V5.4.8  (abort with ^G)
> 1> ftp_test:test("localhost", "serge", "...", "/home/serge", "tt.txt").
> "220 ProFTPD 1.2.6 Server (DevLinuxPro FTP) [devlinuxpro.mis.idt.net]"
> "331 Password required for serge."
> "230 User serge logged in."
> "250 CWD command successful."
> "500 EPSV not understood."
> "200 PORT command successful"
> "150 Opening ASCII mode data connection for tt.txt (7487 bytes)"
> "226 Transfer complete."
> "200 PORT command successful"
> ** exited: {{function_clause,[{inet,tcp_close,[{lsock,#Port<0.123>}]},
>                                {ftp,do_termiante,2},
>                                {gen_server,terminate,6},
>                                {proc_lib,init_p,5}]},
>              {gen_server,call,
>                          [<0.42.0>,
>                           {recv,"tt.txt","tt.txt"},
>                           infinity]}} **
> 
> Hope that it can make it in the next OTP release.
> 
> Regards,
> 
> Serge
> 
> -- 
> Serge Aleynikov
> R&D Telecom, IDT Corp.
> Tel: (973) 438-3436
> Fax: (973) 438-1464
> serge@REDACTED
> -module(ftp_test).
> 
> -export([test/5]).
> 
> test(Host, User, Password, Dir, File) ->
>     application:start(inets),
>     {ok, Pid} = ftp:open(Host, [verbose]),
>     ok = ftp:user(Pid, User, Password),
>     ok = ftp:cd(Pid, Dir),
>     ok = ftp:recv(Pid, File),
>     ok = ftp:recv(Pid, File),
>     ftp:close(Pid).
> --- /usr/local/lib/erlang/lib/inets-4.5/src/ftp.erl	Tue Aug 23 13:28:08 2005
> +++ ftp.erl	Tue Aug 23 16:39:43 2005
> @@ -790,11 +790,11 @@
>  %% terminate/2 and code_change/3
>  %%--------------------------------------------------------------------------
>  terminate(normal, State) ->
> -    do_termiante({error, econn}, State);
> +    do_terminate({error, econn}, State);
>  terminate(Reason, State) ->
> -    do_termiante({error, Reason}, State).
> +    do_terminate({error, Reason}, State).
>  
> -do_termiante(ErrorMsg, State) ->
> +do_terminate(ErrorMsg, State) ->
>      close_data_connection(State),
>      close_ctrl_connection(State),
>      case State#state.client of
> @@ -1313,6 +1313,8 @@
>  
>  close_data_connection(#state{dsock = undefined}) ->
>      ok;
> +close_data_connection(#state{dsock = {lsock, Socket}}) ->
> +    close_connection(Socket);
>  close_data_connection(#state{dsock = Socket}) ->
>      close_connection(Socket).
>  

-- 
/Ingela - OTP team









More information about the erlang-questions mailing list