Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Looking at the code near the line on which the error was reported, we find this set method in 5.6.1:

# IPC/Msg.pm lines 61-79 sub set { my $self = shift; my $ds; if(@_ == 1) { $ds = shift; } else { croak 'Bad arg count' if @_ % 2; my %arg = @_; my $ds = $self->stat or return undef; my($key,$val); $ds->$key($val) while(($key,$val) = each %arg); } msgctl($$self,IPC_SET,$ds->pack); }

There is a bug in this code: on line 11 (which is line 71 of the original file), my $ds creates a new $ds variable which goes out of scope at the end of the else block. That is why the final line has an undefined value for $ds when it tries to invoke $ds->pack.

Removing the redundant "my" will fix that problem by ensuring that (as intended) the outer $ds variable is the one used, and indeed in later perls you'll find that exactly this change has been made: replacing

my $ds = $self->stat
with
$ds = $self->stat
at line 71.

If you don't have permission to make this fix to the code directly, and you can't convince the system administrator to apply the fix for you, there are a couple of ways you can get around it. One way is subclassing to replace the buggy routine:

{ package IPC::Msg::Bugfix; our @ISA = qw/ IPC::Msg /; sub set { # corrected version of set here ... } } # in your code my $msg = new IPC::Msg::Bugfix('24h', IPC_CREAT); # and continue as before

An alternative is to recode to avoid the path with the bug in it:

# avoiding buggy multiple-arg set() # $msg->set('qbytes' => 32768); my $ds = $msg->stat or die "stat: $!"; $ds->qbytes(32768); $msg->set($ds);

(Please note, I haven't tested any of this code.)

Hugo


In reply to Re^3: Resizing IPC::Msg queue size by hv
in thread Resizing IPC::Msg queue size by Jeppe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found