Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
pacemaker.3577
bug-986644_pacemaker-libcrmcommon-errors-waitin...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bug-986644_pacemaker-libcrmcommon-errors-waiting-for-data.patch of Package pacemaker.3577
commit 4e2be138afeae6a94a685fcfea9d1b50ba817fec Author: Ken Gaillot <kgaillot@redhat.com> Date: Thu Sep 15 10:16:22 2016 -0500 Fix: libcrmcommon: report errors consistently when waiting for data on connection For some errors, crm_ipc_ready() and crm_remote_ready() would return -errno, while for other errors, they would return -1 and set errno, making it impossible for callers to reliably interpret the value. Now, they consistently return -errno on error. diff --git a/lib/common/ipc.c b/lib/common/ipc.c index 6d6d3cd..f060fcd 100644 --- a/lib/common/ipc.c +++ b/lib/common/ipc.c @@ -910,9 +910,18 @@ crm_ipc_connected(crm_ipc_t * client) return rc; } +/*! + * \brief Check whether an IPC connection is ready to be read + * + * \param[in] client Connection to check + * + * \return Positive value if ready to be read, 0 if not ready, -errno on error + */ int -crm_ipc_ready(crm_ipc_t * client) +crm_ipc_ready(crm_ipc_t *client) { + int rc; + CRM_ASSERT(client != NULL); if (crm_ipc_connected(client) == FALSE) { @@ -920,7 +929,8 @@ crm_ipc_ready(crm_ipc_t * client) } client->pfd.revents = 0; - return poll(&(client->pfd), 1, 0); + rc = poll(&(client->pfd), 1, 0); + return (rc < 0)? -errno : rc; } static int diff --git a/lib/common/remote.c b/lib/common/remote.c index fd6a9c2..2042f78 100644 --- a/lib/common/remote.c +++ b/lib/common/remote.c @@ -440,14 +440,15 @@ crm_remote_parse_buffer(crm_remote_t * remote) /*! * \internal - * \brief Determine if a remote session has data to read + * \brief Wait for a remote session to have data to read * - * \retval 0, timeout occured. - * \retval positive, data is ready to be read - * \retval negative, session has ended + * \param[in] remote Connection to check + * \param[in] total_timeout Maximum time (in ms) to wait + * + * \return Positive value if ready to be read, 0 on timeout, -errno on error */ int -crm_remote_ready(crm_remote_t * remote, int total_timeout /* ms */ ) +crm_remote_ready(crm_remote_t *remote, int total_timeout) { struct pollfd fds = { 0, }; int sock = 0; @@ -493,7 +494,7 @@ crm_remote_ready(crm_remote_t * remote, int total_timeout /* ms */ ) rc = poll(&fds, 1, timeout); } while (rc < 0 && errno == EINTR); - return rc; + return (rc < 0)? -errno : rc; } @@ -631,12 +632,8 @@ crm_remote_recv(crm_remote_t * remote, int total_timeout /*ms */ , int *disconne crm_err("poll timed out (%d ms) while waiting to receive msg", remaining_timeout); return FALSE; - } else if (rc == -EAGAIN) { - crm_trace("waiting for remote connection data (up to %dms)", - remaining_timeout); - } else if(rc < 0) { - crm_debug("poll() failed: %s (%d)", pcmk_strerror(rc), rc); + crm_debug("could not poll: %s (%d)", pcmk_strerror(rc), rc); } else { rc = crm_remote_recv_once(remote);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor