Lo, perl 5.8.3. I have a server with only ever one client. The client talks to the server via named pipe. On the live machine the client is logging a write to the pipe, but the server isn't logging a read. This happens every so often, ie the majority of the time it works. Below are two scripts, I can't get these to fail. The server and client code are similar and are shown after. I think the problem may be related to server load, but I have no idea tbh. I have put in a SIG PIPE handler, but it never gets called and output stdout and stderr, but nothing is sent to them. The posix pipe buffer is 512bytes but the message is nowhere near this length. I'm sure I'm doing something fundamentally wrong, but don't know what. Any clue greatly appreciated. Here's the server. The sleep simulates the server doing something.
#! /usr/bin/perl -w use strict; use diagnostics; while (1) { print "HERE\n"; open FH, "<pipe"; my $data = <FH>; close FH; print "D: $data\n"; for ( split /ROSE/, $data ? $data : '' ) { if ( /^RELOAD/ ) { } else { sleep 3; } } } # while 1
And here's the test client
#! /usr/bin/perl -w use strict; use diagnostics; my $f = shift; for my $dir (1..20) { open (PIPE, ">pipe"); $dir = $f.'_'.$dir; $| = 1; select(PIPE); print STDOUT "$dir\n"; print PIPE "C,$dir,1ROSE"; close PIPE; sleep 1; }
Here's the live server code snippet:
open FH, "<$config->{'pipe'}"; my $data = <FH>; close FH; Log( { logfile => $log_file, text => 'trace: START: '. ( $data || +'$data no val' ) }) if TRACE;
and the live client code snippet:
if ( $has_files ) { my @now = gettimeofday; open FH, ">> /tmp/tmd_logs/DNOTIFY.LOG"; print FH format_time( $now[0] ).'.'.$now[1], " PREOPEN $dir\n"; close FH; open (PIPE, ">$pipe"); @now = gettimeofday; open FH, ">> /tmp/tmd_logs/DNOTIFY.LOG"; print FH format_time( $now[0] ).'.'.$now[1], " POSTOPEN $dir\n"; close FH; $| = 1; select(PIPE); eval { print PIPE "C,$dir,1ROSE"; }; $dirs{$dir}-- if $@; close PIPE; @now = gettimeofday; open FH, ">> /tmp/tmd_logs/DNOTIFY.LOG"; print FH format_time( $now[0] ).'.'.$now[1], " POSTCLOS $dir\n"; close FH; }
The logs show that the client "sent" a message at 08:40:20 and the server didn't get it ie it got one at 08:40:17 and another at 08:40:22 (the server log is GMT, client log BST) Here's a sample from the client log:
08:40:20.96244 PREOPEN /other/hosting/LIVE/127/out/3_304_127_21 08:40:20.96460 POSTOPEN /other/hosting/LIVE/127/out/3_304_127_21 08:40:20.96570 POSTCLOS /other/hosting/LIVE/127/out/3_304_127_21 08:40:20.96690 S: 14:35:51 H: 1 A: 08:31:06 M: 08:40:19 C: 08:40:19 SI +G: 0 /other/hosting/LIVE/127/out/3_304_127_21 08:53:38.319388 PREOPEN /other/hosting/LIVE/127/out/3_304_127_21 08:53:38.319599 POSTOPEN /other/hosting/LIVE/127/out/3_304_127_21 08:53:38.319712 POSTCLOS /other/hosting/LIVE/127/out/3_304_127_21 08:53:38.319834 S: 08:40:19 H: 1 A: 08:53:32 M: 08:53:36 C: 08:53:36 S +IG: 0 /other/hosting/LIVE/127/out/3_304_127_21 08:53:40.359719 S: 08:53:36 H: 0 A: 08:53:38 M: 08:53:38 C: 08:53:38 S +IG: 0 /other/hosting/LIVE/127/out/3_304_127_21
and here's the time snippet from the server log.
080411 07:40:17.514797 [8625] trace: START: C,/other/hosting/toxml/LIV +E/273/out/1_128_1,1ROSE 080411 07:40:22.248450 [8625] trace: START: C,/other/hosting/LIVE/251/ +out/3_128_251_3,1ROSE

In reply to IPC via named pipes, losing some messages by ftumsh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.