1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

improved logging (all FTP protocol data, both ways) to possibly help us realize

why sometimes the control connection dies after a RETR has been sent
This commit is contained in:
Daniel Stenberg 2005-05-04 21:49:30 +00:00
parent 0cc8b57d4f
commit 9e95dd4821

View File

@ -140,7 +140,7 @@ unlink($pidfile);
startsf(); startsf();
logmsg sprintf("FTP server started on port IPv%d/$port\n", $ipv6?6:4); logmsg sprintf("FTP server listens on port IPv%d/$port\n", $ipv6?6:4);
open(PID, ">$pidfile"); open(PID, ">$pidfile");
print PID $$."\n"; print PID $$."\n";
close(PID); close(PID);
@ -173,7 +173,11 @@ sub sendcontrol {
select(undef, undef, undef, 0.01); select(undef, undef, undef, 0.01);
} }
} }
my $log;
foreach $log (@_) {
$log =~ s/[\r\n]//g;
logmsg "> \"$log\"\n";
}
} }
# Send data to the client on the data stream # Send data to the client on the data stream
@ -263,7 +267,7 @@ sub close_dataconn {
my ($closed)=@_; # non-zero if already disconnected my ($closed)=@_; # non-zero if already disconnected
if(!$closed) { if(!$closed) {
logmsg "time to kill the data connection\n"; logmsg "* disconnect data connection\n";
print DWRITE "DISC\n"; print DWRITE "DISC\n";
my $i; my $i;
sysread DREAD, $i, 5; sysread DREAD, $i, 5;
@ -271,14 +275,12 @@ sub close_dataconn {
else { else {
logmsg "data connection already disconnected\n"; logmsg "data connection already disconnected\n";
} }
logmsg "time to quit sockfilt for data\n";
print DWRITE "QUIT\n";
logmsg "told data slave to die (pid $slavepid)\n";
waitpid $slavepid, 0;
$slavepid=0;
logmsg "=====> Closed data connection\n"; logmsg "=====> Closed data connection\n";
logmsg "* quit sockfilt for data (pid $slavepid)\n";
print DWRITE "QUIT\n";
waitpid $slavepid, 0;
$slavepid=0;
} }
my $rest=0; my $rest=0;
@ -308,7 +310,6 @@ my @ftpdir=("total 20\r\n",
senddata $_; senddata $_;
} }
close_dataconn(0); close_dataconn(0);
logmsg "done passing data\n";
sendcontrol "226 ASCII transfer complete\r\n"; sendcontrol "226 ASCII transfer complete\r\n";
return 0; return 0;
} }
@ -555,7 +556,7 @@ sub PASV_command {
return 0; return 0;
} }
logmsg "sockfilt for data on pid $slavepid\n"; logmsg "Run sockfilt for data on pid $slavepid\n";
# Find out what port we listen on # Find out what port we listen on
my $i; my $i;
@ -582,17 +583,14 @@ sub PASV_command {
if($cmd ne "EPSV") { if($cmd ne "EPSV") {
# PASV reply # PASV reply
logmsg "replying to a $cmd command, waiting on port $pasvport\n";
sendcontrol sprintf("227 Entering Passive Mode (127,0,0,1,%d,%d)\n", sendcontrol sprintf("227 Entering Passive Mode (127,0,0,1,%d,%d)\n",
($pasvport/256), ($pasvport%256)); ($pasvport/256), ($pasvport%256));
} }
else { else {
# EPSV reply # EPSV reply
logmsg "replying to a $cmd command, waiting on port $pasvport\n";
sendcontrol sprintf("229 Entering Passive Mode (|||%d|)\n", $pasvport); sendcontrol sprintf("229 Entering Passive Mode (|||%d|)\n", $pasvport);
} }
eval { eval {
local $SIG{ALRM} = sub { die "alarm\n" }; local $SIG{ALRM} = sub { die "alarm\n" };
@ -831,7 +829,7 @@ while(1) {
my $FTPARG=$2; my $FTPARG=$2;
my $full=$_; my $full=$_;
logmsg "Received \"$full\"\n"; logmsg "< \"$full\"\n";
if($verbose) { if($verbose) {
print STDERR "IN: $full\n"; print STDERR "IN: $full\n";
@ -872,7 +870,6 @@ while(1) {
# used enough number of times, now blank the customreply # used enough number of times, now blank the customreply
$customreply{$FTPCMD}=""; $customreply{$FTPCMD}="";
} }
logmsg "$FTPCMD made to send '$text'\n";
} }
if($text) { if($text) {
sendcontrol "$text\r\n"; sendcontrol "$text\r\n";