02-15-05 11:02 PM
>> What's your outer problem? If two different users want to run your
John Smith <john.smith@x-formation.com> wrote:[vbcol=seagreen]
>I have a network daemon which hosts a database to clients. The database can
>only be accessed by one daemon at a time.
You should perhaps look into locking on the database (assuming you mean a
database file, rather than an RDBMS connection), rather than a
system-wide restriction. Is it possible that two different underlying
databases might need to be accessed by two distinct daemons?
Alternately, if the daemon listens on a specific network port, you already g
et
locking because you'll fail to bind to it if another process already has
it. If you need to run two, you can, but they need to specify different
ports.
>daemons so only one instance is running. Naturally you can easily hosts mor
e
>daemons+database on each their machine but not on one.
A lot of systems can hosts multiple instances of a database on one machine,
with different connection methods.
>Since root will be able to delete files I assume I must have a mechanism to
>detect if the lock is still valid. E.g. run a thread every now and then and
>make sure we are still locked.
Yes, if this is a problem, you'll want to exit if your lockfile is removed o
r
changed. If you define your uniqueness requirement to be network port or
specific database file, this won't be a problem, as root would have to kill
your process or destroy your database to nullify your lock.
--
Mark Rafn dagon@dagon.net <http://www.dagon.net/>
[ Post a follow-up to this message ]
|