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_BUFSI Z() * 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_p erl/5.8.3/ IPC/Sharea ble.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!
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_BUFSI
);
tie %Data, 'IPC::Shareable', "data", { %options };
Now I get following error:
IPC::Shareable::SharedMem:
at /usr/local/ActivePerl-5.8/
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.