From 4fbfe6dec6e7c8c03116a7349693ecde6a09fd33 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Mon, 12 Dec 2011 20:46:00 +0000 Subject: [PATCH] kfw fixes: ccapiserver only quits after all clients detach Not sure if this is really a good idea or not... Signed-off-by: Kevin Wasserman ticket: 7050 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25563 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ccapi/server/ccs_server.c | 7 +++++++ src/ccapi/server/ccs_server.h | 2 ++ src/ccapi/server/win/ccs_os_server.cpp | 11 +++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ccapi/server/ccs_server.c b/src/ccapi/server/ccs_server.c index aeff7235a..1fc8d2c5e 100644 --- a/src/ccapi/server/ccs_server.c +++ b/src/ccapi/server/ccs_server.c @@ -399,3 +399,10 @@ cc_int32 ccs_server_send_reply (ccs_pipe_t in_reply_pipe, return cci_check_error (err); } + +/* ------------------------------------------------------------------------ */ + +cc_uint64 ccs_server_client_count () +{ + return ccs_client_array_count (g_client_array); +} diff --git a/src/ccapi/server/ccs_server.h b/src/ccapi/server/ccs_server.h index 4d17099d0..e920ad939 100644 --- a/src/ccapi/server/ccs_server.h +++ b/src/ccapi/server/ccs_server.h @@ -48,4 +48,6 @@ cc_int32 ccs_server_send_reply (ccs_pipe_t in_reply_pipe, cc_int32 in_reply_err, k5_ipc_stream in_reply_data); +cc_uint64 ccs_server_client_count (); + #endif /* CCS_SERVER_H */ diff --git a/src/ccapi/server/win/ccs_os_server.cpp b/src/ccapi/server/win/ccs_os_server.cpp index 9a45e72c0..f84239491 100644 --- a/src/ccapi/server/win/ccs_os_server.cpp +++ b/src/ccapi/server/win/ccs_os_server.cpp @@ -199,7 +199,7 @@ cc_int32 ccs_os_server_listen_loop (int argc, const char *argv[]) { ParseOpts::Opts opts = { 0 }; ParseOpts PO; - BOOL bQuit = FALSE; + BOOL bQuitIfNoClients = FALSE; opts.cMinCalls = 1; opts.cMaxCalls = 20; @@ -231,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 (!bQuit) { + while (ccs_server_client_count() > 0 || !bQuitIfNoClients) { worklist_wait(); while (!worklist_isEmpty()) { k5_ipc_stream buf = NULL; @@ -244,10 +244,6 @@ 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", @@ -290,6 +286,9 @@ cc_int32 ccs_os_server_listen_loop (int argc, const char *argv[]) { err = krb5int_ipc_stream_write(stream, "This is a test of the emergency broadcasting system", 52); err = ccs_os_server_send_reply(pipe, stream); break; + case CCMSG_QUIT: + bQuitIfNoClients = TRUE; + break; default: cci_debug_printf("Huh? Received invalid message type %ld from UUID:<%s>", rpcmsg, uuid); -- 2.26.2