(I think I've allready posted a reply, but I can't see it, so here's my second try).
The line in the Reader's loop:
next if ($NoClient < 2)
directly corresponds to my wish (and purpose) not to echo the input back to the Client: If only 1 Client is connected, there is nothing to send, so don't push anything into @chat.
But you can delete this line without any side effect - I think. If this line is deleted the input is pushed into @chat. Then the Writer tries to sent those lines but won't because he is not allowed to do
print $socket .. if ($1 ne $ID ..);
after that he is eliminating them from @chat. Just to prevent the Writer to do this for nothing I added the a.m. line.
Writer-Zombie
When the socket broke the Reader pushes his kill-code into @chat no matter how many Clients are left and on this the Writer is asked to work (cond_wait) and will find his 'personal' kill-code and he'll die.
As soon as I moved the 'kill-code-detection' from the wile (1) loop
-- formally I had: while ( "@chat" !~ ($ID\s$kill/){..
this place is
after cond_wait and
after the elimination of sent lines --
rigth after the cond_wait, I have had no more zombies. I pretty much convinced that this was the cause for this problem.
The memory access error I had went away as soon as I removed my bug splitting the empty $Elm. It could be that this is a mistake either of Perl or thread (thread:shared) or even Linux. It would be ok if the program crashes, but not in that way - I think.
I wish you and your relatives nice christmas days
here in Vienna we might get snow the next days, you too,
Carl
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.