I believe the accept is failing under heavy load.

I was puzzled by the weird shell parsing and wondered if that was part of the problem so I whipped up a lame threaded client that can reliably "crash" the server on my Debian system.

#!/usr/bin/perl use 5.10.0; use strict; use warnings; use Socket; use threads; my $rendezvous = shift || 'catsock'; my $max_clients = 10; $_->join for map { threads->create( \&run_client ) } 1 .. $max_clients +; sub run_client { my $sock; unless ( socket($sock, PF_UNIX, SOCK_STREAM, 0) ) { warn "socket: $!"; return; } unless ( connect($sock, sockaddr_un($rendezvous)) ) { warn "connect: $!"; return; }; while ( defined(my $line = <$sock>) ) { print $line; } }

The next thing I noticed was that an strace of the server seemed to exit normally. Immediately after the for loop I added

print "\n\nWTF?\n\n";

and got

$ perl -T 855342.pl 855342.pl 22345: server started on catsock at Tue Aug 17 11:00:49 2010 855342.pl 22345: connection on catsock at Tue Aug 17 11:00:51 2010 855342.pl 22345: begat 22348 at Tue Aug 17 11:00:51 2010 855342.pl 22345: connection on catsock at Tue Aug 17 11:00:51 2010 855342.pl 22345: begat 22350 at Tue Aug 17 11:00:51 2010 855342.pl 22345: connection on catsock at Tue Aug 17 11:00:51 2010 855342.pl 22345: begat 22352 at Tue Aug 17 11:00:51 2010 855342.pl 22345: connection on catsock at Tue Aug 17 11:00:51 2010 855342.pl 22345: begat 22355 at Tue Aug 17 11:00:51 2010 855342.pl 22345: connection on catsock at Tue Aug 17 11:00:51 2010 855342.pl 22345: begat 22356 at Tue Aug 17 11:00:51 2010 WTF?

That means that the for condition accept(Client,Server) || $waitedpid; is evaluating to false. Just before the exit, the strace shows

accept(3, 0x7fff3015acc0, [4096]) = ? ERESTARTSYS (To be restart +ed)

Therefore, I believe the accept is failing under heavy load and my advice is to always check the return value from accept.


In reply to Re: Unix-Domain TCP Server Crashing by rowdog
in thread Unix-Domain TCP Server Crashing by wokka

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.