From: Tom Yu Date: Mon, 12 Dec 2011 20:44:30 +0000 (+0000) Subject: Make ccapiserver exit if its receiveloop thread terminates for any reason X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5afb7bcbb9a5bd76132be60b58c01f6a3e5e3f7c;p=krb5.git Make ccapiserver exit if its receiveloop thread terminates for any reason This happens, for example, when the rpc endpoint is already registered by another ccapiserver process. There's no reason to leave a zombie process running that can't receive messages. ticket: 7050 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25540 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/ccapi/common/win/win-utils.h b/src/ccapi/common/win/win-utils.h index 6469a61e8..41cab24dc 100644 --- a/src/ccapi/common/win/win-utils.h +++ b/src/ccapi/common/win/win-utils.h @@ -42,7 +42,8 @@ static enum ccapiMsgType { CCMSG_REQUEST_REPLY, CCMSG_DISCONNECT, CCMSG_LISTEN, - CCMSG_PING + CCMSG_PING, + CCMSG_QUIT }; char* clientEndpoint(const char* UUID); diff --git a/src/ccapi/server/win/ccs_os_server.cpp b/src/ccapi/server/win/ccs_os_server.cpp index 811090ba5..9a45e72c0 100644 --- a/src/ccapi/server/win/ccs_os_server.cpp +++ b/src/ccapi/server/win/ccs_os_server.cpp @@ -199,6 +199,7 @@ cc_int32 ccs_os_server_listen_loop (int argc, const char *argv[]) { ParseOpts::Opts opts = { 0 }; ParseOpts PO; + BOOL bQuit = FALSE; opts.cMinCalls = 1; opts.cMaxCalls = 20; @@ -230,7 +231,7 @@ cc_int32 ccs_os_server_listen_loop (int argc, const char *argv[]) { threadStatus = _beginthread(receiveLoop, 0, (void*)&rpcargs); /* We handle the queue entries here. Work loop: */ - while (TRUE) { + while (!bQuit) { worklist_wait(); while (!worklist_isEmpty()) { k5_ipc_stream buf = NULL; @@ -243,6 +244,10 @@ cc_int32 ccs_os_server_listen_loop (int argc, const char *argv[]) { ccs_pipe_t pipe2 = NULL; if (worklist_remove(&rpcmsg, &pipe, &buf, &serverStartTime)) { + if (rpcmsg == CCMSG_QUIT) { + bQuit = TRUE; + break; + } uuid = ccs_win_pipe_getUuid(pipe); #if 0 cci_debug_printf("%s: processing WorkItem msg:%ld pipeUUID:<%s> pipeHandle:0x%X SST:%ld", @@ -462,6 +467,8 @@ void receiveLoop(void* rpcargs) { free_alloc_p(&endpoint); } + // tell main thread to shutdown since it won't receive any more messages + worklist_add(CCMSG_QUIT, NULL, NULL, 0); _endthread(); } // End receiveLoop