thcsoft has asked for the wisdom of the Perl Monks concerning the following question:

hi all, i'm working on a threaded server process. here are the relevant code lines:
use threads; use threads::shared; use Thread::Queue;
snip...
our (%sessions, %nicks, %times) : shared;
snip...
sub _save { my $session = $req->content; lock %times; lock %nicks; lock %sessions; $times{$session->{ID}} = time; $nicks{$session->{ID}} = $session->{PLAYER}->get('nickname') unless + $session->{PLAYER}->anonymus; $sessions{$session->{ID}} = $session; $logs->enqueue("save request: stored session $session->{ID}") if $d +ebug; $res->content({}); }
and from this line: $sessions{$session->{ID}} = $session; i get this warning: Invalid value for shared scalar at sbin/sessiond line 258. anobody got a clue, why?

Replies are listed 'Best First'.
Re: Invalid value for shared scalar
by Forsaken (Friar) on Apr 29, 2005 at 07:42 UTC
    Shared variables may not contain object refs, is that by any chance what's biting you here? $session does look like an object ref from the way you're using it.

    Remember rule one...
      yes, you're right, thx 4 reminding me. :)
Re: Invalid value for shared scalar
by davido (Cardinal) on Apr 29, 2005 at 07:09 UTC
    $nicks{$session->{ID}} = $session->{PLAYER}->get('nickname') unless $session->{PLAYER}->anonymus;

    Does it have anything to do with the fact that "anonymus" is misspelled, and should be spelled "anonymous"?

    Actually, as I look at it, I doubt that's contributing to the specific problem you're reporting, but once you solve the primary problem, you might find that the misspelling also needs to be addressed before everything runs as it should. ;)


    Dave

      @ dave just pretend, there's a roman catholic player named 'anonymus'. unfortunately he'll never be able to login. ;)
      language is a virus from outer space.