php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19050 ftp_* functions vs. proftpd
Submitted: 2002-08-22 11:37 UTC Modified: 2002-09-21 02:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: darklord at revai dot hu Assigned:
Status: No Feedback Package: FTP related
PHP Version: 4.2.2 OS: Linux Debian Woody (2.4.18)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: darklord at revai dot hu
New email:
PHP Version: OS:

 

 [2002-08-22 11:37 UTC] darklord at revai dot hu
here's a part of the code I planned to use (it's a method of an object):
    function host_get($file) {
                $tmpname=tempnam("/tmp","IWO".uniqid(rand()));
                if (!ftp_get($this->ftp_fd,$tmpname,$file,FTP_BINARY)) {
                        die("Can't download from server");
                }
                $fd=fopen($tmpname,"r");
                $a=array();
                while (!feof($fd)) {
                        $m=fgets($fd,65536);
                        $a[]=$m;
                }
                fclose($fd);
                unlink($tmpname);
                return $a;
        }
But sometimes (when 3 times this function was called ) the PHP interpreter hanged. (I can't reproduce this problem w/o my whole src), but when I changed the line 
  $m=fgets($fd,65000);
to
  $m=fgets($fd,3000);
The script started to work again ...
I use debian woody with the original apache and php packages, postgres and ftp modules in this script.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-23 21:19 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip
 [2002-08-26 02:13 UTC] darklord at revai dot hu
Hi! I've tryed php 4.2.2 (php-cvs don't compile, the error is in the mysql lib).
Ok! The script above now prints the following (I've chaged the ftp timeout to 1 sec):

Warning: ftp_get: in /home_real/darklord/devel/iwo/modules/host_access/ftp/base.php on line 144

I use proftpd and this bug is like #18781, but they say the functions are slow, but in my case the functions are hanging. I use a local server (my computer) so the transfer should be fast.
(Sorry for the prev bug report ... but changing the buffer size solved the problem ... temporaly)
 [2002-08-26 03:28 UTC] darklord at revai dot hu
I think this error is specific to proftpd becouse the script works fine on a wu-ftpd ...
 [2002-08-26 03:33 UTC] darklord at revai dot hu
#13400 is a workaround for this bug, but I think proftp dev team should know about this thing ...
 [2002-08-26 04:02 UTC] darklord at revai dot hu
The -d 3 doesn't solve the problem with ftp_rawlist, but the following code works for it:
$i=0;
  while (($a=ftp_rawlist($this->ftp_fd,$dir)) === false) {
       $i++;
	if ($i > 5) { die("Error"); }
 }
 [2002-08-26 06:29 UTC] wez@php.net
Is this a problem with fgets or is the problem with ftp_get? (there's a big difference!).
Can you put these two lines before your fopen line:

echo "Downloaded file from server\n";
flush();
 [2002-08-26 12:04 UTC] darklord at revai dot hu
It turned out to be ftp_* bug, sorry.
So:
To solve the error with ftp_get i've rewriten the code to use fopen with ftp:// filename. It's a workaround, not a FIX!
To solve the error with ftp_nlist, i've used the code posted bellow (the one which retries the listing)
I've no idea why has the buffer size change worked (65530->3000) but temporary it solved the problem (my first bug report), but then more calls were made to the reader function and the hanging began again.
The proftpd developer team says that it's not their problem, I'll write them something nice ...
And sorry for the misleading ... to all of you.
 [2002-08-26 12:09 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

Some ftp problems were fixed recently. Please give it a shot.

 [2002-09-21 02:04 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC