[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 990
  • Last Modified:

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!
0
jakac
Asked:
jakac
  • 2
1 Solution
 
kanduraCommented:
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.
0
 
kanduraCommented:
http://search.cpan.org/~samtregar/IPC-SharedCache-1.3/SharedCache.pm tells me:

This module provides a shared memory cache accessed as a tied hash. [...] This module handles all shared memory interaction using the IPC::ShareLite module (version 0.06 and higher) and all data serialization using Storable. See IPC::ShareLite and Storable for details.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now