[26776] in Perl-Users-Digest
Perl-Users Digest, Issue: 8843 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 9 14:05:17 2006
Date: Mon, 9 Jan 2006 11:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 9 Jan 2006 Volume: 10 Number: 8843
Today's topics:
Re: IO::Pipe and loss of data xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 09 Jan 2006 17:55:51 GMT
From: xhoster@gmail.com
Subject: Re: IO::Pipe and loss of data
Message-Id: <20060109125551.943$NM@newsreader.com>
"Ina Scherf" <ina.scherf@sap.com> wrote:
> >
> >> sub logProcessing{
> >> my $line = '';
> >> my ($msg, $server);
> >> eval {
> >> local $SIG{ALRM} = sub { die "lesedauer" };
> >> alarm(1);
> >> $line = <$pipe_log>;
> >> alarm(0);
> >> };
> >
> > I don't understand the point of this time out. If the timeout occurs,
> > you never complain about it or even detect it. You merely start
> > another call of the same thing that just timed out. If all you do upon
> > a timeout is restart the same thing, why bother timing out?
> This seems to be obsolete because I cut away code. Normally the father
> process shall do three things parallel in its routine. One of them has to
> do with user input to another script and sending data. So I wanted to
> reduce wating time at this point (although I believe this pipe is _never_
> empty for over one second).
If it is never empty for more than a second, then it should be safe to
remove the timeout :) At least for debugging purposes.
Or at least do a
die "$@: $line:" if $@;
(or a warn, or a logging command)
after the end of the eval block.
>
> > Anyway, if the alarm goes off after the next line is read from
> > $pipe_log, but before the "alarm(0)" gets executed, then you die out of
> > the eval{} and
> > the line you just read from $pipe_log gets ignored. That could account
> > for
> > your missing data!
> But should not be at least half a line in $line then?
Maybe, maybe not. I think that $line = <$pipe_log>; is executed first as a
read from pipe_log into some anonymous storage, then as an assignment from
that storage into $line. If the interuption happens after (or during)
the read but before the assingment, then $line will show no hint of the
missing data, (other than being empty, which event is silently ignored in
the code as you originally posted it.)
> I changed my log to
> have the old line and the new line. No half lines so far. Either there is
> the whole line or nothing in it. And it is very easy to check if the line
> is not complete as the last thing to be transfered is a dumped object and
> this gives an error on every missing character at the end.
>
> >> return if ($line !~ /::/);
> > Wouldn't it be better to die upon malformed data?
> Yes - you're completely right :)
Have you seen the error after making this change? (This is where you
silently ignore empty lines, which, in conjuction with your alarm time-out,
might be the cause of the missing data).
....
>
> I give out either the last line that was send sucessfully and the new
> line after the missing one. Both seem to be just normal - nothing is
> missing.
This definitely makes me thinkg the problem is with the time-out, and not
with the pipe itself.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8843
***************************************