POE FollowTail sometimes works sometimes doesn't

Emmanuel <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
Hi,

I am facing a bizarre behaviour from Wheel::FollowTail.
Basically, sometimes it detects the log reset, sometimes it doesn't.
Sometimes it gets the record, sometimes it doesn't. From my extensive
tests, it seems to work only in 10% of the cases.
The file watched is overwritten by an application every 10-15 minutes,
contains only 3 lines. Here is an example of its contents:

   namp@tewap4 ~/code> cat /namp_log/log/TRLOGStatus.cfg
   #
   #Sun Sep 14 18:03:05 IRDT 2008
   TRFILE_INDEX_NUMBER=157

The file is on a normal filesystem:

   /namp_log on /dev/md/dsk/d50
read/write/setuid/devices/intr/largefiles/logging/xattr/noatime/onerror=panic/dev=1540032
on Tue Sep  9 00:58:53 2008

Any idea what could cause this?
O/S is Solaris, Perl 5.10 built from source using gcc, latest version of POE.
I'm about to revert to a more 'tradition' approach of watching the
file (e.g. checking its timestamp every minute) but I wouldn't mind
figuring out why FollowTail, which has worked perfectly fine on other
projects, behaves this way on this file.

Here is the simple code I am using.

sub InitWapLog
# Define POE records
{
        $poe_records{_start} = \&begin_watchers;
        $poe_records{index_record} = \&index_got_record;
        $poe_records{index_log_reset} = \&index_log_reset;
        $poe_records{log_error} = \&generic_log_error;
        &Log("Init complete");
}

sub begin_watchers
# Start POE sessions
{
        my $heap = $_[HEAP];
        my $logid;
        my $log_watcher = POE::Wheel::FollowTail->new
        (
                Filename => $LogStatus,
                InputEvent => "index_record",
                ResetEvent => "index_log_reset",
                ErrorEvent => "log_error",
        );
        $heap->{services}->{ $log_watcher->ID } = "index";
        $heap->{watchers}->{ $log_watcher->ID } = $log_watcher;
        &Log("Started watch on file $LogStatus");
}

sub index_got_record
# Handle index file reset
{
        my ($record, $wheel_id, $heap) = @_[ARG0, ARG1, HEAP];
        my $service = $heap->{services}->{$wheel_id};
        &Log("index: read $record");
}

sub index_log_reset
# An index log reset means the current log has been closed
{
        my ($heap, $wheel_id) = @_[HEAP, ARG0];
        my $service = $heap->{services}->{$wheel_id};
        &Log("$service log reset");
}

sub generic_log_error
# Handles log errors
{
        my ($heap, $operation, $errno, $error_string, $wheel_id) = @_[
HEAP, ARG0, ARG1, ARG2, ARG3 ];
        my $service = $heap->{services}->{$wheel_id};
        &Log("$service log $operation error $errno: $error_string\n");
        &Log("Shutting down $service log watcher.\n");
        delete $heap->{services}->{$wheel_id};
        delete $heap->{watchers}->{$wheel_id};
}

# MAIN

my $LogStatus = "/namp_log/log/TRLOGStatus.cfg";
&Log("Starting WAP log watch");
&InitWapLog;
POE::Session->create(inline_states => {%poe_records});
$poe_kernel->run();
&Log("All watchers died, exiting");
exit;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.