Re: Multiple processes and tie'd files
- From: Alexander Clouter <alex@xxxxxxxxxxxxx>
- Date: Sun, 31 Aug 2008 13:58:37 +0100
xhoster@xxxxxxxxx wrote:
Tuc <tuctboh@xxxxxxxxx> wrote:The documentation for DB_File has *nothing* to say on this that is useful,
Hi,
I'm running into an issue when using a file I've tied, and there
are multiple long term running processes. I first ran into it with
Squid as a redirection program (Never resolved it), and now with
MimeDefang.
When I tie to a DB_File, if one of the processes or even an
external process updates the file, the persistent processes aren't
seeing the update. I have to stop them and restart them for that to
happen.
Have you read the documentation for DB_File?
this is just general unix'y know how that you never really get to pick up
easily.
When I wrote a squid based url filtering blacklisting mcwhatsit I used
DB_File. The important thing is to have *one* writer and many readers,
this means you can forget about locking altogether.
UNIX has this rather nice feature where when a file is open that FD's 'view'
of the file does not change even if you delete the file or edit it. To see
the changes you have to close the FD and reopen the DB_File. On long
running processes this is easy, I would recommend you just '(stat($file))[9]'
and see if the modification timestamp has changed at regular intervals.
If they have then untie and retie the file and you will see your updates.
The regular interval I would use alarm() and have a function that does this,
should keep things clean without messing up the logic of your core code.
No no no, MySQL is horrible! Putting any network based database into theShort of going to mysql (Which is like trying to swat a fly with
the supercollider) is there another option?
Mysql is not a super-collider, it is a very light-weight fly swatter. What
you are trying to doing with DB_File is like trying to swat a fly with a
pencil sharpener.
critical loop of a realtime interactive is a bad bad idea. You might get
away with using sqlite but probably would still feel dirty from the
experience, DB_File's are great for this kind of task.
Cheers
Alex
.
- References:
- Multiple processes and tie'd files
- From: Tuc
- Multiple processes and tie'd files
- Prev by Date: Re: subprocesses lifecycle
- Next by Date: FAQ 6.14 How do I process each word on each line?
- Previous by thread: Re: Multiple processes and tie'd files
- Next by thread: FAQ 8.19 Why doesn't my sockets program work under System V (Solaris)? What does the error message "Protocol not supported" mean?
- Index(es):