Re: multi-process singleton DLL
- From: PaulH <paul.heil@xxxxxxxxx>
- Date: Mon, 23 Jul 2007 17:00:47 -0000
Instead of using IPC, wouldn't it be possible to use DuplicateHandle()
such that ProcessA opens the DLL and gets the original resource
handle, then Process B opens the DLL and gets a DuplicateHandle()?
I'm glad you mentioned the second process. I didn't consider what
would happen to Process B if Process A closed the resource. What about
using the DLL to keep a reference count of all the handles created,
then it could wait for the reference to become 0 before it really
releases the resource. Would that work?
Thanks,
Paul
On Jul 23, 10:47 am, "Ben Voigt [C++ MVP]" <r...@xxxxxxxxxxxxx> wrote:
"PaulH" <paul.h...@xxxxxxxxx> wrote in message
news:1185203158.770652.52140@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a DLL that exports a class that allows a program to access a
unique system resource.
At the moment, the DLL is implemented as a singleton such that any
thread in a given process is using the same resource handle.
But, if a second, unrelated process loads the DLL and accesses it,
this process will try to create its own handle to the resource which
fails because it's already in use by the first process.
How do I give the second process access to the handle that's being
used by the first process so that both can query the resource?
Pick an IPC method, any method. Note that to do this cleanly, it is
necessary that a separate process be set up to "own" the true handle,
because if the owning process closes the resource will be released.
Named pipes would probably be a good choice, because the proxy process can
detect abnormal termination of a client.
Thanks,
PaulH
.
- Follow-Ups:
- Re: multi-process singleton DLL
- From: Ben Voigt [C++ MVP]
- Re: multi-process singleton DLL
- From: Alex Blekhman
- Re: multi-process singleton DLL
- References:
- multi-process singleton DLL
- From: PaulH
- Re: multi-process singleton DLL
- From: Ben Voigt [C++ MVP]
- multi-process singleton DLL
- Prev by Date: Re: Exception and GetLastError()
- Next by Date: Re: System Requirements for Express Edition
- Previous by thread: Re: multi-process singleton DLL
- Next by thread: Re: multi-process singleton DLL
- Index(es):
Relevant Pages
|