Show
Ignore:
Timestamp:
10/15/07 21:02:42 (7 years ago)
Author:
Brian Holcomb <holcomb@omniti.com>
git-committer:
Brian Holcomb <holcomb@omniti.com> 1192482162 +0000
git-parent:

[8657b1c93255fbc6381e85d10b749f1883265203]

git-author:
Brian Holcomb <holcomb@omniti.com> 1192482162 +0000
Message:

fix shmid=0 problem

git-svn-id: https://labs.omniti.com/resmon/trunk@45 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Status.pm

    r8657b1c re901fb6  
    88use Socket; 
    99use Fcntl qw/:flock/; 
    10 use IPC::SysV qw /IPC_CREAT IPC_RMID ftok S_IRWXU S_IRWXG S_IRWXO/; 
     10use IPC::SysV qw /IPC_PRIVATE IPC_CREAT IPC_RMID ftok S_IRWXU S_IRWXG S_IRWXO/; 
    1111use Data::Dumper; 
    1212 
     
    2525  my $blob; 
    2626  my $len; 
    27   return unless($self->{shared_state}); 
     27  return unless(defined($self->{shared_state})); 
    2828  # Lock shared segment 
    2929  # Read in 
     
    4040sub store_shared_state { 
    4141  my $self = shift; 
    42   return unless($self->{shared_state}); 
     42  return unless(defined($self->{shared_state})); 
    4343  my $blob = Dumper($self->{store}); 
    4444 
     
    260260  chmod 0644, "$self->{file}.swap"; 
    261261 
    262   unless($self->{shared_state}) { 
    263     my $id = ftok(__FILE__,$self->{ftok_number}); 
    264     $self->{shared_state} = shmget($id, $SEGSIZE, 
    265                                    IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO) 
    266       || die "$0: $!"; 
     262  unless(defined($self->{shared_state})) { 
     263    $self->{shared_state} = shmget(IPC_PRIVATE, $SEGSIZE, 
     264                                   IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO); 
     265    die "$0: $!" if($self->{shared_state} == -1); 
    267266  } 
    268267  return 1; 
     
    300299    waitpid(-1,WNOHANG); 
    301300  } 
    302   if($self->{shared_state}) { 
     301  if(defined($self->{shared_state})) { 
    303302    shmctl($self->{shared_state}, IPC_RMID, 0); 
    304303  }