On Fri Feb 27 12:12:12 2009, CLEACH wrote:
Show quoted text> I believe that sysread() is supposed to return undef in that case, not
zero.
From perldoc -f sysread:
"Returns the number of bytes actually read, 0 at end of file, or undef
if there was an error (in the latter case $! is also set)."
Both 0 and undef are error cases, albeit different ones. In the
premature EOF case, $! will either not be set or will correspond to some
earlier error, so it's misleading to print it out if you just see EOF.
Show quoted text> But since I can't reproduce what you are seeing, and I have no
> sample code with a trace or server to exploit it, please try out the
> following code change to see if it resolves your issue. If it does,
> I'll make it part of v0.08 if it works for you & doesn't hurt other
> servers I test against.
This should work with the above caveat about $!.
From the start, I probably should have mentioned that this bug was
actually encountered in the wild, and given you the patch I ended up
applying--basically your change except that the error cases are
distinguished.
Debug logging was on when this occurred and a PBSZ command had just been
issued. Not that it really matters...an FTP server could misbehave and
shutdown prematurely in response to any command, and the client should
report this error immediately.
To add a little bit more concrete evidence to the busy loop claim, I
decided to strace the process after noticing it was at 100% cpu usage.
Here's what I saw:
$ strace -p 32082
...
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
read(3, ""..., 5) = 0
...
$ cd /proc/32082/fd/
$ ls -l
total 0
lr-x------ 1 user user 64 Feb 26 11:37 0 -> pipe:[45840078]
l-wx------ 1 user user 64 Feb 26 11:37 1 -> pipe:[11266942]
l-wx------ 1 user user 64 Feb 26 11:37 2 -> pipe:[11266942]
lrwx------ 1 user user 64 Feb 26 11:37 3 -> socket:[45840086]