in reply to Shared variables between threads

From a quick look at the Net::Pcap source, the return value of open_live() isn't a 'object', at least not in the Perlish sense of a blessed reference. It is the value returned from a direct call to the pcap c-library function:

pcap_t * pcap_open_live(device, snaplen, promisc, to_ms, err) ... RETVAL = pcap_open_live(device, snaplen, promisc, to_ms, errbuf);

That looks like a c struct address to me. If that is the case, and that is what is ending up back in your Perl program, it ought to look like an unsigned integer to Perl. And if that were true, it is hard to see why Perl wouldn't let you assign it to a shared scalar.

Would you try assigning it to a non-shared variable, printing it and post the output here?


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."

Replies are listed 'Best First'.
Re^2: Shared variables between threads
by Saladino (Beadle) on Nov 05, 2007 at 09:40 UTC
    This is the value of $capobj just after the assignation.
    pcap_tPtr=SCALAR(0x8a97fd4)

      From that it seems that you are receiving a bless scalar reference. Older versions of threads shared did not allow you to assign bless references (objects) to shared variables for technical reasons.

      A recent change by jdhedden alleviated this restriction, but (unless you've already done so) you will need to download the latest versions from CPAN to be able to do this:

      print $threads::VERSION, $threads::shared::VERSION;; 1.67 1.14

      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.
        I have updated my threads and threads::shared packages but no way.
        threads version -> 1.67 threads::shared version -> 1.14 Invalid value for shared scalar at RTP_media.pl line 23.
        lines 22-23
        my $capobj:shared; $capobj = Net::Pcap::open_live($dev,1024,0,0,\$err);