Net::FTP, GET transfers only a part of a file

Net::FTP, GET transfers only a part of a file

am 29.09.2005 10:02:00 von jussi.mononen-asdf

Hi all,

I'm having a mysterious problem with my script. I'm using
Net::FTP to transfer files from a remote server and only a
part of the file is transferred (2080 bytes vs. 12000 bytes).

After that I try to issue a PWD command which hangs in the
select, waiting for response which never arrives. The reason
for this is that the servers TCP window is full because GET
didn't read all available data from the FTP-DATA channel,
thus I end up in a deadlock, where my script waits for a
response and the server waits that the client would read
some data and make space into the TCP window.

Why GET reads only a part of the file? After the first
read data packet, GET returns OK and my script continues,
and eventually hangs waiting for the response of PWD.

Net::FTP version is 2.72

My perl is:

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi-64
uname='sunos sol8dev 5.8 generic_108528-14 sun4u sparc sunw,sun-fire '
config_args='-Dcc=cc -Duse64bitall -Dprefix=/vobs/prod/opensource/perl/SunOS'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=define uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -xarch=v9 -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-D_REENTRANT -xarch=v9 -I/usr/local/include'
ccversion='Sun WorkShop 6 update 1 C 5.2 2000/09/11', gccversion='', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=87654321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -xarch=v9 -L/usr/lib/sparcv9 -L/usr/ccs/lib/sparcv9 -L/opt/SUNWspro/WS6U1/lib/v9 -L/usr/local/lib '
libpth=/usr/lib/sparcv9 /usr/ccs/lib/sparcv9 /opt/SUNWspro/WS6U1/lib/v9 /usr/local/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lpthread -lc
perllibs=-lsocket -lnsl -ldl -lm -lpthread -lc
libc=/usr/lib/sparcv9/libc.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -R /vobs/prod/opensource/perl/SunOS/lib/5.8.3/sun4-solaris-thre ad-multi-64/CORE'
cccdlflags='-KPIC', lddlflags=' -G -xarch=v9 -L/usr/lib/sparcv9 -L/usr/ccs/lib/sparcv9 -L/opt/SUNWspro/WS6U1/lib/v9 -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT USE_64_BIT_ALL USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Built under solaris
Compiled at Mar 30 2004 15:09:51
%ENV:
PERL5LIB="/home/cpt2jmo/testing/ftp_collector/2.0/bin:"
@INC:
/home/cpt2jmo/testing/ftp_collector/2.0/bin
/vobs/prod/opensource/perl/SunOS/lib/5.8.3/sun4-solaris-thre ad-multi-64
/vobs/prod/opensource/perl/SunOS/lib/5.8.3
/vobs/prod/opensource/perl/SunOS/lib/site_perl/5.8.3/sun4-so laris-thread-multi-64
/vobs/prod/opensource/perl/SunOS/lib/site_perl/5.8.3
/vobs/prod/opensource/perl/SunOS/lib/site_perl

thanks,

Jussi Mononen

--
remove -asdf and asdf- for email address

Re: Net::FTP, GET transfers only a part of a file

am 29.09.2005 10:58:44 von jussi.mononen-asdf

> Why GET reads only a part of the file? After the first
> read data packet, GET returns OK and my script continues,
> and eventually hangs waiting for the response of PWD.

get-function return value seems to be 0 (zero) ?

It should return either 'local' or undef??

br,

Jussi Mononen

--
remove -asdf and asdf- for email address

Re: Net::FTP, GET transfers only a part of a file

am 29.09.2005 14:32:50 von jussi.mononen-asdf

>> Why GET reads only a part of the file? After the first
>> read data packet, GET returns OK and my script continues,
>> and eventually hangs waiting for the response of PWD.
>
> get-function return value seems to be 0 (zero) ?
>
> It should return either 'local' or undef??

Problem solved.

For experimental reasons I had defined FTP Timeout to zero.
What I didn't know was that the same timeout was used in I.pm
read functions select-function call as a timeout also.

When the data sent from the remote had enough delay, select
would timeout and I.pm would call 'carp'.

As it was, I was executing 'get' inside an eval-block and
was able to caught this one. The only problem was that I
had relied on Net::FTP documentation and only checked that
the return value was defined. After calling 'carp' get
returned zero and halted file transfer. As my script proceeded
I sent the 'pwd' command falling into the deadloc I described
earlier.

Now I would like to ask whether the connection timeout should
be used in rea-timeouts also if zero is a valid value?

br,

Jussi Mononen

--
remove -asdf and asdf- for email address