Hi Frank!
On Feb 2, 2007, at 15:39 , Frank Hofmann wrote:
On Fri, 2 Feb 2007, Martin Englund wrote:
I'm working on a command line tool that communicates with a
daemon, using libdoor(3LIB), to retrieve events (malloc()ed
structs of variable length) which sit on a ring buffer.
My problem is that once I've picked up an event from the ring
buffer I want to free() it, but I can't do that until I've called
door_return(), but once I've called door_return() I'm no longer
executing in the server process.
I don't want to do a second door_call() just to free() the event,
but I see no other way to solve the problem.
I am thankful for hints of other ways to solve this...
Multithreaded programming.
Create a "garbage collector thread" in the door server, pass the
"to be freed" buffer onto that before you return. I.e. free
asynchronously.
I've been pondering that, but one problem came to mind:
When I've placed the event on the GC queue (and released the mutex
for mucking with the event queues), and called:
door_return((char *) &event, event_sz, NULL, 0);
How do I make sure that the GC thread doesn't beat door_return() and
free the event before door_return() has successfully completed?
cheers,
/Martin
--
Martin Englund, Java Security Engineer, Java SE, Sun Microsystems Inc.
Email: [EMAIL PROTECTED] Time Zone: GMT+2 PGP: 1024D/AA514677
"The question is not if you are paranoid, it is if you are paranoid
enough."
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code