Apache-SharedMem

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.07 Mon August 27, 2001 18:36:52
    - Implement a more efficient IPC key generation for the root segment, using
      the system ftok() function provied by IPC::SysV module
    - Pod documentation
    - Default IPC mode is now 0600
    - We now keep ipc_mode and ipc_segment_size in the root map for calling IPC::ShareLite
      with same values.
    - Add "readonly" parameter to constructor
    - Feature enhancement, add "dump" and "dump_map" methods
    - Data::Dumper is now autoused
    - Feature enhancement, release method now release root map when it go empty
    - Feature enhancement, add a "destroy" method, that call "release" method on all root-map's
      namespaces. Usefull for cleaning shared memory on Apache shutdown.
    - Adding tools to package for debuging purpose
    - Bugfix in delete method, for problem on root map cleanup
    - Better support of mod_perl
    - Minor bugfix in _init_namespace method
    - Misc bugfixes

0.06 Mon August 20, 2001 15:55:50

Makefile.PL  view on Meta::CPAN


WriteMakefile
(
    'NAME'		=> 'Apache::SharedMem',
    'VERSION_FROM'	=> 'lib/Apache/SharedMem.pm', # finds $VERSION
    'PREREQ_PM'		=> 
    {
        IPC::ShareLite  => '0.06',
        IPC::SysV       => '1.03',
        Storable        => '1.006',
        Data::Dumper    => '2.101',
    },
    EXE_FILES           => [grep(-f $_ && -x _, glob('./bin/*'))],
    ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM => 'lib/Apache/SharedMem.pm',
       AUTHOR     => 'Olivier Poitrey <rs@rhapsodyk.net>') : ()),
);

README  view on Meta::CPAN

   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

  IPC::ShareLite
  IPC::SysV
  Storable
  Data::Dumper

CHANGES

0.09 Thu Oct  4, 2001 13:54:53
    - Major bugfix that made the module unusable under mod_perl !

0.08 Tue Oct  2, 2001 16:19:08
    - status() now return bitmask values.
    - get() method can know return undef() when value in undefined instead of void string.
    - Bugfix in test scripts: don't failed if PWD environment variable isn't set.

0.07 Mon August 27, 2001 18:36:52
    - Implement a more efficient IPC key generation for the root segment, using
      the system ftok() function provied by IPC::SysV module
    - Pod documentation
    - Default IPC mode is now 0600
    - We now keep ipc_mode and ipc_segment_size in the root map for calling IPC::ShareLite
      with same values.
    - Add "readonly" parameter to constructor
    - Feature enhancement, add "dump" and "dump_map" methods
    - Data::Dumper is now autoused
    - Feature enhancement, release method now release root map when it go empty
    - Feature enhancement, add a "destroy" method, that call "release" method on all root-map's
      namespaces. Usefull for cleaning shared memory on Apache shutdown.
    - Adding tools to package for debuging purpose
    - Bugfix in delete method, for problem on root map cleanup
    - Better support of mod_perl
    - Minor bugfix in _init_namespace method
    - Misc bugfixes

0.06 Mon August 20, 2001 15:55:50

lib/Apache/SharedMem.pm  view on Meta::CPAN

    my $record  = $self->_get_root;
    return(keys %{$record->{'map'}});
}

sub dump_map
{
    my $self    = shift;

    _init_dumper();
    my $root_record = $self->_get_root || return undef;
    return Data::Dumper::Dumper($root_record);
}

sub dump
{
    my $self        = shift;
    my $namespace   = defined $_[0] ? shift : croak('too few arguments');

    _init_dumper();
    if(my $ns_obj = $self->_get_namespace_ipcobj($self->_get_root, $namespace))
    {
        return Data::Dumper::Dumper($self->_get_record($ns_obj));
    }
    else
    {
        carp("can't read namespace $namespace: ", $self->error);
        return undef;
    }
}

=pod

lib/Apache/SharedMem.pm  view on Meta::CPAN


    if(defined $root)
    {
        # we have found an existing root
        $self->{root} = $root;
        $self->_root_lock(LOCK_SH);
        $record = $self->_get_root;
        $self->_root_unlock;
        unless(ref $record && ref($record) eq 'HASH' && exists $record->{'map'})
        {
            $self->_debug("map dump: ", $record, Data::Dumper::Dumper($record)) if($options->{debug});
            confess("Apache::SharedMem object initialization: wrong root map type")
        }

        # checking map version
        unless(exists $record->{'version'} && $record->{'version'} >= 2)
        {
            # old map style, we ne upgrade it
            $self->_root_lock(LOCK_EX);
            foreach my $namespace (keys %{$record->{'map'}})
            {

lib/Apache/SharedMem.pm  view on Meta::CPAN

        eval { $record = thaw($serialized) };
        confess("Apache::SharedMem: Invalid share block recieved from shared memory. Storable error: $@") if $@;
        confess("Apache::SharedMem: Invalid share block recieved from shared memory.") unless(ref($record) eq 'HASH');
    }
    else
    {
        # record not initialized
        $record = {};
    }

    $self->_debug(4, 'dump: ', Data::Dumper::Dumper($record)) if($self->{options}->{debug});

    return($record);
}

sub _store_namespace { $_[0]->_debug; $_[0]->_store_record($_[1], $_[0]->{namespace}) }
sub _store_root      { $_[0]->_debug; $_[0]->_store_record($_[1], $_[0]->{root}) }

sub _store_record
{
    my $self    = shift;
    my $share   = defined($_[0]) ? (ref($_[0]) eq 'HASH' ? shift() : croak('Apache::SharedMem: unexpected error, wrong data type')) : croak('Apache::SharedMem; unexpected error, missing argument');
    my $ipc_obj = defined $_[0] ? shift : return undef;

    if($self->{options}->{readonly})
    {
        $self->_set_error('can\'t store any data in readonly mode');
        $self->_set_status(FAILURE);
        return undef;
    }

    $self->_debug(4, 'dump: ', Data::Dumper::Dumper($share)) if($self->{options}->{debug});

    my $serialized;

    # freeze the shared block
    eval { $serialized = freeze($share) };
    confess("Apache::SharedMem: Problem while the serialization of shared data. Storable error: $@") if $@;
    confess("Apache::SahredMem: Problem while the serialization of shared data.") unless(defined $serialized && $serialized ne '');

    $self->_debug(4, 'storable src: ', $serialized);

lib/Apache/SharedMem.pm  view on Meta::CPAN


sub _set_status
{
    my $self = shift;
    $self->{__status__} = defined($_[0]) ? $_[0] : '';
    $self->_debug("setting status to $_[0]");
}

sub _init_dumper
{
    require Data::Dumper;
    $Data::Dumper::Indent    = 2;
    $Data::Dumper::Terse     = 1;
    $Data::Dumper::Quotekeys = 0;
}

sub _cleanup
{
    if(defined $Apache::SharedMem::ROOTKEY)
    {
        my $share = new Apache::SharedMem;
        $share->destroy if(defined $share)
    }
}

lib/Apache/SharedMem.pm  view on Meta::CPAN

meny documentation updates

Revision 1.46  2001/08/28 16:42:14  rs
adding better support of mod_perl with a cleanup method handled to Apache's
registry_cleanup.

Revision 1.45  2001/08/28 10:17:00  rs
little documentation fix

Revision 1.44  2001/08/28 08:45:12  rs
stop using autouse for Data::Dumper, mod_perl don't like it
add auto unlock on DESTROY, seem to work under mod_perl with Apache::Registry
TODO test with mod_perl handlers

Revision 1.43  2001/08/27 15:42:02  rs
bugfix in release method, on root map cleanup, ipc_mode must be defined
bugfix in _init_namespace method, if object was create without any "set" called,
the empty namespace won't be allocated.

Revision 1.42  2001/08/24 16:11:25  rs
    - Implement a more efficient IPC key generation for the root segment, using
      the system ftok() function provied by IPC::SysV module
    - Pod documentation
    - Default IPC mode is now 0600
    - We now keep ipc_mode and ipc_segment_size in the root map for calling IPC::ShareLite
      with same values.
    - Add "readonly" parameter to constructor
    - Feature enhancement, add "dump" and "dump_map" methods
    - Data::Dumper is now autoused
    - Feature enhancement, release method now release root map when it go empty
    - Feature enhancement, add a "destroy" method, that call "release" method on all root-map's
      namespaces. Usefull for cleaning shared memory on Apache shutdown.
    - Misc bugfixes

Revision 1.41  2001/08/23 08:37:03  rs
major bug, _get_rootkey was call mod_perl method on a wrong object

Revision 1.40  2001/08/23 08:08:18  rs
little documentation update



( run in 0.270 second using v1.01-cache-2.11-cpan-4d50c553e7e )