Link to home
Start Free TrialLog in
Avatar of jakac
jakac

asked on

IPC::Shareable size of hash in shared memory or different approach to shared memory

Hello!

I used IPC::Shareable module for my simple webserver solution for three years now. I find it very useful but the module hasn't been updated a while (version 0.6 is more than 3 years old). Anyway I use this module so that server (parent) stores some data into hash and then ties it into the shared memory to which all childs have access. But the default size of shared memory with this module is  65536 bytes and my hash just got bigger so when I try to build this hash I get following error:

Could not create semaphore set: No space left on device
 at lib/Server.pm line 170

And when I tried to change the size in options:

my %options = (
create    => 1,
exclusive => 0,
mode      => 0644,
DESTROY   => 1,
size      =>  (IPC::Shareable::SHM_BUFSIZ() * 2)
);

tie %Data, 'IPC::Shareable', "data", { %options };

Now I get following error:

IPC::Shareable::SharedMem: shmget: Invalid argument
 at /usr/local/ActivePerl-5.8/lib/site_perl/5.8.3/IPC/Shareable.pm line 566
Could not create shared memory segment:
 at lib/Server.pm line 165

I tried to contact author of this module but his address on CPAN doesn't exist anymore. So does anyone here have an idea how I can fix this problem or is there perhaps any better (newer) solution for tying hashes in shared memory out there?

Thanx!
Avatar of kandura
kandura

http://search.cpan.org/~maurice/IPC-ShareLite-0.09/ShareLite.pm tells me:

IPC::ShareLite provides a simple interface to shared memory, allowing data to be efficiently communicated between processes. Your operating system must support SysV IPC (shared memory and semaphores) in order to use this module.

IPC::ShareLite provides an abstraction of the shared memory and semaphore facilities of SysV IPC, allowing the storage of arbitrarily large data; the module automatically acquires and removes shared memory segments as needed. Storage and retrieval of data is atomic, and locking functions are provided for higher-level synchronization.

In many respects, this module is similar to IPC::Shareable. However, IPC::ShareLite does not provide a tied interface, does not (automatically) allow the storage of variables, and is written in C for additional speed.
ASKER CERTIFIED SOLUTION
Avatar of kandura
kandura

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial