skx has asked for the wisdom of the Perl Monks concerning the following question:
I've written a fork()ing server which I'm using very happily.
However I've run into a problem where I wish to persist some data between clients, as the forked() children cannot modify the variables stored in the parent I've fudged this by using FreezeThaw to persist the data to a temporary file.
This works .. mostly .. but there are issues with synchronization which appear to cause the temporary file to get trashed.
As I see it I can continue down this route and add locking - or I can solve the problem the right way by creating a shared memory segment in the parent, and writing a hash to that from the client.
(Each client can write to %persistence{clientip} - as I know that each client connects only once).
So my questions begin, how can I manage this? Is there some sample somewhere that I can copy?
I've looked around and I honestly see no real examples of using IPC shared memory under perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of shared memory to persist data between child processes
by Corion (Patriarch) on Oct 09, 2003 at 10:25 UTC | |
by skx (Parson) on Oct 09, 2003 at 10:34 UTC | |
by hardburn (Abbot) on Oct 09, 2003 at 13:58 UTC | |
|
Re: Use of shared memory to persist data between child processes
by Abigail-II (Bishop) on Oct 09, 2003 at 10:58 UTC | |
|
Re: Use of shared memory to persist data between child processes
by delirium (Chaplain) on Oct 09, 2003 at 11:23 UTC | |
|
Re: Use of shared memory to persist data between child processes
by perrin (Chancellor) on Oct 09, 2003 at 17:51 UTC | |
|
Re: Use of shared memory to persist data between child processes
by fokat (Deacon) on Oct 12, 2003 at 02:46 UTC |