From e404e4c6cbddaca8fcb9a563ce20fb19d6a722a3 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Tue, 1 May 2018 15:36:33 -0400 Subject: [PATCH] Remove last remnants of old trpc thread exit protocol, clear trpc queue * Remove the shutting_down status in the TRPC_INSTANCE * Clear the TRPC message queue after failed connections * Add a few comments --- include/trp_internal.h | 1 - tr/tr_trp.c | 5 +++++ trp/trpc.c | 1 - trp/trps.c | 10 +++++----- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/trp_internal.h b/include/trp_internal.h index a52edb8..8401bfa 100644 --- a/include/trp_internal.h +++ b/include/trp_internal.h @@ -142,7 +142,6 @@ struct trpc_instance { unsigned int port; TRP_CONNECTION *conn; TR_MQ *mq; /* msgs from master to trpc */ - int shutting_down; /* 0 unless the TRPC is in the shutdown process */ }; /* TRP Server Instance Data */ diff --git a/tr/tr_trp.c b/tr/tr_trp.c index 8304300..79a9a27 100644 --- a/tr/tr_trp.c +++ b/tr/tr_trp.c @@ -573,6 +573,10 @@ struct trpc_thread_data { * a TR_MQMSG_ABORT message is received on trpc->mq, the thread sends a * TR_MQMSG_TRPC_DISCONNECTED message to the trps thread, then cleans up and * terminates. + * + * The trps may continue queueing messages for this client even when the + * connection is down. To prevent the queue from growing endlessly, this thread + * should clear its queue after failed connection attempts. */ static void *tr_trpc_thread(void *arg) { @@ -596,6 +600,7 @@ static void *tr_trpc_thread(void *arg) tr_notice("tr_trpc_thread: failed to initiate connection to %s:%d.", trpc_get_server(trpc), trpc_get_port(trpc)); + trpc_mq_clear(trpc); /* clear the queue even though we did not connect */ } else { /* Retrieve the GSS name used by the peer for authentication */ peer_gssname=trp_connection_get_peer(trpc_get_conn(trpc)); diff --git a/trp/trpc.c b/trp/trpc.c index 5985980..aef5f7b 100644 --- a/trp/trpc.c +++ b/trp/trpc.c @@ -59,7 +59,6 @@ TRPC_INSTANCE *trpc_new (TALLOC_CTX *mem_ctx) trpc->server=NULL; trpc->port=0; trpc->conn=NULL; - trpc->shutting_down = 0; trpc->mq=tr_mq_new(trpc); if (trpc->mq==NULL) { talloc_free(trpc); diff --git a/trp/trps.c b/trp/trps.c index 83461d9..b737aba 100644 --- a/trp/trps.c +++ b/trp/trps.c @@ -265,13 +265,13 @@ TRP_RC trps_send_msg(TRPS_INSTANCE *trps, TRP_PEER *peer, const char *msg) /* get the connection for this peer */ trpc=trps_find_trpc(trps, peer); - /* instead, let's let that happen and then clear the queue when an attempt to - * connect fails */ + /* The peer connection (trpc) usually exists even if the connection is down. + * We will queue messages even if the connection is down. To prevent this from + * endlessly increasing the size of the queue, the trpc handler needs to clear + * its queue periodically, even if it is unable to send the messages + */ if (trpc==NULL) { tr_warning("trps_send_msg: skipping message queued for missing TRP client entry."); - } else if (trpc->shutting_down) { - tr_debug("trps_send_msg: skipping message because TRP client is shutting down."); - rc = TRP_SUCCESS; /* it's ok that this didn't get sent, the connection will be gone in a moment */ } else { mq_msg=tr_mq_msg_new(tmp_ctx, TR_MQMSG_TRPC_SEND, TR_MQ_PRIO_NORMAL); msg_dup=talloc_strdup(mq_msg, msg); /* get local copy in mq_msg context */ -- 2.1.4