|
Posted by Johannes Kiehl on 12/30/06 18:33
guys,
I need one more hint on this. I feel I am not tackling this
in a php'ish way.
I've been asking before, in this NG, how to monitor a
(semaphore-like) file for timestamp changes, other than doing
a (sleep + filectime) loop.
The comments I received suggested using external tools, such as
famd, inotify or dazuko (thanks for the pointers).
The problem with those is that, on shared hosting servers, either they
don't run, or php is not allowed to use them.
Now what about having
1) the loop: while (1) { sleep(30); if (filectime(x)!=y) break; }
---obvious disadvantage: the monitoring script may wakeup with a delay of
up to 30 seconds---
---plus---
2) the option to wake up the monitor script, using sysv messaging where it
works, as soon as the file has been changed (by having whoever changed it
send a 'wakeup' message).
So, the sleep(30) loop would be a fallback option for systems where
sysv messaging is not available.
Let me rephrase the idea:
1.) Script A changes a file. It sends a wakeup message with msg_send
2.) Script B waits for the file to change, so it can do something with
it, but looks at the file's timestamp only once in 30 seconds
3.) Script B also listens for messages and, if sysv messaging is available
on that server, may wake up before the 30 seconds interval has passed
Is this smart, or am I only trying to be clever here?
msg_receive can either wait forever, or just go on, but it has no timeout
option. So I don't see how to combine "sleeping" and "listening", other
than using a loop again, that would eat away CPU time for nothing.
Is there a way to have msg_recive run in blocking mode, but time out
after XX seconds?
Again, thanks for any comments.
Johannes
--
Please don't send personal email to the From: address. -->>
ed tod iduej ta oj :siht rof bmud oot era stobmaps epoH <<--
[Back to original message]
|