* DCE Client/Server Exceptions
@ 1994-04-03 14:43 Paul Homchick
1994-04-04 12:31 ` Jon Mauney
1994-04-04 13:28 ` Rich Salz
0 siblings, 2 replies; 4+ messages in thread
From: Paul Homchick @ 1994-04-03 14:43 UTC (permalink / raw)
I am working on a DCE/RPC application that, strangely enough, has one
client and multiple servers. The servers are multi-threaded with one
section of code that talks to another application using sockets. This
section of code cannot be interrupted, and must complete or dire
things happen. Thus, when this section of code is entered, all other
threads are blocked.
My problem is that when a client dies unexpectedly, the server thread
also seems to die. I don't really understand this, because my reading
of the DCE documentation seems to indicate that the server/rpc code
should execute at least until the server tries to return to the client
under these circumstances. Alas, this does not seem to be the case.
Although the other threads come back to life, the communication with
the external application is left in a wedged state, and things soon
come to an ignominious end.
I imagine that there might be two approaches to this. 1st) (and best)
set the run-time to block client-death signals until I exit the
critical area of code, or 2nd) set some sort of exception handler that
will allow me to catch the notice of client death and clean up before I
allow the server thread to exit.
It seems that DCE/RPC must provide a way to control this, but I have
yet to find it. A bit of advice on approaches to the problem, where
to look in the documentation or, lists of appropriate rpc/dce function
calls would be appreciated.
Thanks!!!
--
Paul Homchick :UUCP {rutgers | uunet} !cbmvax!cgh!paul
Chimitt Gilman Homchick, Inc. :Internet paul@cgh.com
1111 West DeKalb Pike, Suite 101 :MCI PHOMCHICK
Wayne, PA 19087-2179 :GEnie HOMCHICK
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: DCE Client/Server Exceptions
1994-04-03 14:43 DCE Client/Server Exceptions Paul Homchick
@ 1994-04-04 12:31 ` Jon Mauney
1994-04-04 13:28 ` Rich Salz
1 sibling, 0 replies; 4+ messages in thread
From: Jon Mauney @ 1994-04-04 12:31 UTC (permalink / raw)
paul@cgh.cgh.com (Paul Homchick) writes:
>I am working on a DCE/RPC application that, strangely enough, has one
>client and multiple servers. The servers are multi-threaded with one
>section of code that talks to another application using sockets. This
>section of code cannot be interrupted, and must complete or dire
>things happen. Thus, when this section of code is entered, all other
>threads are blocked.
>My problem is that when a client dies unexpectedly, the server thread
>also seems to die.
Let me restate the situation, to make sure I understand the key points:
Your server accepts a client request, and as part of the server
code makes a connection to another application. This socket
operation must complete, even if the client process dies in
the interval.
First, you need to understand the DCE model of multi-threaded RPC:
The thread operating in the server is considered to be an extension
of the thread operating in the client. For example, if the client
passes invalid arguments to an RPC and the server gets a segmentation
violation as a result, the exception is reported back to the client,
and the client core-dumps, not the server.
In this model, it is reasonable to expect that the death of a client
would be reported to the server.
If you want to make sure your non-RPC connection completes,
I would create a separated thread in the server to do this operation,
before entering rpc_server_listen(). Server threads could
send work to this thread and wait for it to finish; if a server thread
dies, the other connection is not affected. Any mutexes required
could be held by the extra thread, so they can be easily cleaned up;
use of a separate thread may reduce the need for mutexes, anyway.
--
Jon Mauney mauney@csc.ncsu.edu
Mauney Computer Consulting (919) 828-8053
"Have TGT, will travel"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: DCE Client/Server Exceptions
1994-04-03 14:43 DCE Client/Server Exceptions Paul Homchick
1994-04-04 12:31 ` Jon Mauney
@ 1994-04-04 13:28 ` Rich Salz
1994-04-04 18:29 ` Seiichi Tatsukawa
1 sibling, 1 reply; 4+ messages in thread
From: Rich Salz @ 1994-04-04 13:28 UTC (permalink / raw)
In <1994Apr3.144347.27715@cgh.cgh.com> paul@cgh.cgh.com (Paul Homchick) writes:
>My problem is that when a client dies unexpectedly, the server thread
>also seems to die.
DCE tries very hard to preserve local function call semantics. So yes,
if a client dies DCE will try to send the same signal over to the appropriate
thread in the server. If you have a critical section in your server that
you need to protect from cancellations, do this:
#include <pthread.h>
int cancelmode;
cancelmode = pthread_setcancel(CANCEL_OFF);
/* ...critical section here... */
if (cancelmode == CANCEL_ON)
(void)pthread_setcancel(CANCEL_ON);
/r$
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: DCE Client/Server Exceptions
1994-04-04 13:28 ` Rich Salz
@ 1994-04-04 18:29 ` Seiichi Tatsukawa
0 siblings, 0 replies; 4+ messages in thread
From: Seiichi Tatsukawa @ 1994-04-04 18:29 UTC (permalink / raw)
In article <2np4mf$7bh@paperboy.osf.org> rsalz@osf.org (Rich Salz) writes:
> #include <pthread.h>
>
> int cancelmode;
>
> cancelmode = pthread_setcancel(CANCEL_OFF);
> /* ...critical section here... */
> if (cancelmode == CANCEL_ON)
> (void)pthread_setcancel(CANCEL_ON);
And be careful about what you do in the critical section. If the
non-cancelable thread gets blocked forever, your server looses
one of the call executor threads...
Also restoring the general cancelability can be done by just
calling:
(void)pthread_setcancel(cancelmode);
I think, in general, the server manager routine should handle the
forwarded cancel by using TRY/CATCH exception handling, e.g.:
TRY
{
/* Do your critical work with the other process. */
}
/*
* If you want to handle the cancel specifically. */
CATCH(pthread_cancel_e)
{
...
}
*/
CATCH_ALL
{
/* Do the necessary cleanup for the connection with the other process. */
}
ENDTRY
--- Seiichi
--
+ Seiichi Tatsukawa (^[$BN)@n@:0l^[(B) tatsu_s@ch.hp.com +
+ Hewlett-Packard/Open Systems Software Division +
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1994-04-04 18:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-04-03 14:43 DCE Client/Server Exceptions Paul Homchick
1994-04-04 12:31 ` Jon Mauney
1994-04-04 13:28 ` Rich Salz
1994-04-04 18:29 ` Seiichi Tatsukawa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox