Skip Menu |

This queue is for tickets about the File-Tail CPAN distribution.

Report information
The Basics
Id: 20263
Status: resolved
Priority: 0/
Queue: File-Tail

People
Owner: Nobody in particular
Requestors: mjd [...] isc.upenn.edu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.98
Fixed in: (no value)



Subject: ->read() returns false instead of blocking
File::Tail::read should never return false. It is documented as blocking when there is no data to deliver. However, as this program demonstrates, it can be made to return false when maxbuf is set to 1. SunOS porpoise.net.isc.upenn.edu 5.9 Generic_118558-21 sun4u sparc SUNW,Sun-Fire-V240 use File::Tail; my $FILE = "/tmp/file-tail-has-a-bug"; my $pid = fork; die "fork: $!" unless defined $pid; END { kill 15 => $pid if $pid } # clean up child on exit make_file() if $pid == 0; # child process writes the file # parent reads it back with File::Tail sleep 2; my $z = File::Tail->new(name => $FILE, maxbuf => 1) or die; while (defined(my $l = $z->read)) { if ($l eq "") { # This should never happen die "File::Tail::read returned the empty string" } } print "OK\n"; exit; sub make_file { open F, ">", $FILE or die "Couldn't write demo file '$FILE': $!"; select F; $| = 1; while (1) { print time, "\n"; } }
Show quoted text
> However, as this program demonstrates, it can be made to return false > when maxbuf is set to 1.
A value of 1 for maxbuf is not reasonable. If I change anything, it will be to return an error when an attempt is made to set maxbuf below 256 (or, come to think of it, maybe 1024)
Subject: Re: [rt.cpan.org #20263] ->read() returns false instead of blocking
Date: Wed, 5 Jul 2006 09:09:22 -0400
To: bug-File-Tail [...] rt.cpan.org
From: Mark Jason Dominus <mjd [...] isc.upenn.edu>
On Jul 4, 2006, at 1:56 AM, Matija_Grabnar via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=20263 > > >
>> However, as this program demonstrates, it can be made to return false >> when maxbuf is set to 1.
> A value of 1 for maxbuf is not reasonable.
A value of 0 is reasonable; it should enable an unbuffered mode. Show quoted text
> If I change anything, it will > be to return an error when an attempt is made to set maxbuf below 256 > (or, come to think of it, maybe 1024)
I think that's the wrong choice, but it's your module.
Subject: Re: [rt.cpan.org #20263] ->read() returns false instead of blocking
Date: Wed, 05 Jul 2006 19:46:32 +0200
To: bug-File-Tail [...] rt.cpan.org
From: Matija Grabnar <matija [...] serverflow.com>
mjd@isc.upenn.edu via RT wrote: Show quoted text
> A value of 0 is reasonable; it should enable an unbuffered mode.
What do the words "unbuffered mode" mean to you in relation to File::Tail? File::Tail will feed you all the complete lines it has, and will block when it has nothing more. That's as "unbuffered" as I can make it. If it's the blocking that bothers you, set "nowait".
Subject: Re: [rt.cpan.org #20263] ->read() returns false instead of blocking
Date: Wed, 5 Jul 2006 14:06:25 -0400
To: bug-File-Tail [...] rt.cpan.org
From: Mark Jason Dominus <mjd [...] isc.upenn.edu>
On Jul 5, 2006, at 1:49 PM, Matija Grabnar via RT wrote: Show quoted text
> What do the words "unbuffered mode" mean to you in relation to > File::Tail? > > File::Tail will feed you all the complete lines it has, and will block > when it has nothing > more. That's as "unbuffered" as I can make it.
Yes, that's what I meant, but it didn't appear to be doing that. I will look into the problem in more detail and see if I can understand it better.
Added a warning if maxbuf is set to below 1024