File pacemaker-libcrmcommon-next-flush-delay.patch of Package pacemaker.14737
commit f1f9bf7ceb3737ed4d731669c2e5744a9e234a04
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Mon May 1 17:06:03 2017 -0500
Low: libcrmcommon: don't delay next flush by more than 5 seconds
If an IPC client falls behind on processing incoming events, we set a
progressive delay between queue flushes. However, at the maximum backlog
of 500 events, this would be 51 seconds. Cap this delay at 5 seconds.
diff --git a/lib/common/ipc.c b/lib/common/ipc.c
index 2949837e3..c9e3da2bb 100644
--- a/lib/common/ipc.c
+++ b/lib/common/ipc.c
@@ -463,12 +463,28 @@ crm_ipcs_flush_events_cb(gpointer data)
return FALSE;
}
+/*!
+ * \internal
+ * \brief Add progressive delay before next event queue flush
+ *
+ * \param[in,out] c Client connection to add delay to
+ * \param[in] queue_len Current event queue length
+ */
+static inline void
+delay_next_flush(crm_client_t *c, unsigned int queue_len)
+{
+ /* Delay a maximum of 5 seconds */
+ guint delay = (queue_len < 40)? (1000 + 100 * queue_len) : 5000;
+
+ c->event_timer = g_timeout_add(delay, crm_ipcs_flush_events_cb, c);
+}
+
ssize_t
crm_ipcs_flush_events(crm_client_t * c)
{
- int sent = 0;
ssize_t rc = 0;
- int queue_len = 0;
+ unsigned int sent = 0;
+ unsigned int queue_len = 0;
if (c == NULL) {
return pcmk_ok;
@@ -523,8 +539,8 @@ crm_ipcs_flush_events(crm_client_t * c)
qb_ipcs_disconnect(c->ipcs);
return rc;
}
+ delay_next_flush(c, queue_len);
- c->event_timer = g_timeout_add(1000 + 100 * queue_len, crm_ipcs_flush_events_cb, c);
}
return rc;