From bd94be0109f55d70eb0c49ff55338422e5e48571 Mon Sep 17 00:00:00 2001 From: Klaus Wenninger Date: Thu, 9 Dec 2021 11:25:22 +0100 Subject: [PATCH] use libqb async API for connect --- lib/common/ipc_client.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/common/ipc_client.c b/lib/common/ipc_client.c index 5106fb28444..baa764965c2 100644 --- a/lib/common/ipc_client.c +++ b/lib/common/ipc_client.c @@ -1407,13 +1407,30 @@ pcmk__ipc_is_authentic_process_active(const char *name, uid_t refuid, int32_t qb_rc; pid_t found_pid = 0; uid_t found_uid = 0; gid_t found_gid = 0; qb_ipcc_connection_t *c; + struct pollfd pollfd = { 0, }; + int poll_rc; - c = qb_ipcc_connect(name, 0); + // c = qb_ipcc_connect(name, 0); + c = qb_ipcc_connect_async(name, 0, + &(pollfd.fd)); if (c == NULL) { crm_info("Could not connect to %s IPC: %s", name, strerror(errno)); rc = pcmk_rc_ipc_unresponsive; goto bail; } + pollfd.events = POLLIN; + do { + poll_rc = poll(&pollfd, 1, 2000); + } while ((poll_rc == -1) && (errno == EINTR)); + if ((poll_rc <= 0) || (qb_ipcc_connect_continue(c) != 0)) { + crm_info("Could not connect to %s IPC: %s", name, + (poll_rc == 0)?"timeout":strerror(errno)); + rc = pcmk_rc_ipc_unresponsive; + if (poll_rc > 0) { + c = NULL; // qb_ipcc_connect_continue cleaned up for us + } + goto bail; + } qb_rc = qb_ipcc_fd_get(c, &fd); if (qb_rc != 0) {