To the best of my knowledge, IO::Socket::INET and all it's dependencies are thread-safe. I've written and tested several dozen threaded scripts using them and never encountered a problem that I haven't tracked down to elsewhere.

However, looking at the extract you posted which I've never had occasion to look at before, I'm not particularly impressed, and I do see a possible source of conflict/error.

If Symbol is loaded, as it normally will be, before the threads are spawned, then the package global $genseq will be cloned into each thread that is created. That means that each thread will have it's own sequence counter and will therefore be generating duplicate fully-qualified names for the globs it creates. That shouldn't be a problem as best I can tell as each sequence would live in a separate interpreter and should never come into conflict. But still it tweaks my radar.

It seems to me that it would be better to forgo the naming of the globs completely and just return the address of an anonymous glob created by localising a single well-known name:

sub gensym { return \do{ local *GLOB; *GLOB }; }

You could try temporarily substituting that for the code you posted and see if it makes any difference, but I seriously doubt it will. You've rather glossed over where I think the problem really lies. Ie.

the caching process simply doesn't receive any data at all - which i tried to bypass by locally undef'ing $/ and $\, and although i rather consider this as magic it apparently works - apart from that, sometimes the data get merged in ways that are plainly impossible. for instance chunks of data from one entity seem to appear somewhere else, where they don't belong to.

In particular, the caching process cannot be the reason for these mistakes,... smacks greatly of "famous last words".

I think if you posted (preferably cut down) working code that demonstrates how your caching process works, and resolved the problems described in the above paragraph, then you'd probably fix the overall problem also. I always, always suspect "magic" code :)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: yet another thread question: is Symbol::gensym threadsafe? by BrowserUk
in thread yet another thread question: is Symbol::gensym threadsafe? by TOD

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.