* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Report
failures on pipe used for wakeup.
Reported by Chris Lalancette.
---
I think this is what you had in mind for additional error
checking. However, in practice, will one-byte reads and
writes on fd's created by pipe() ever encounter any errors?
src/remote/remote_driver.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 57cf8a2..e4a4b73 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8505,8 +8505,12 @@ remoteIOEventLoop(virConnectPtr conn,
if (fds[1].revents) {
DEBUG0("Woken up from poll by other thread");
- ignore_value (saferead(priv->wakeupReadFD, &ignore,
- sizeof(ignore)));
+ if (saferead(priv->wakeupReadFD, &ignore, sizeof(ignore))
+ != sizeof(ignore)) {
+ virReportSystemError(errno ? errno : 0,
+ "%s", _("read on wakeup fd
failed"));
+ goto error;
+ }
}
if (ret < 0) {
@@ -8642,6 +8646,7 @@ remoteIO(virConnectPtr conn,
/* Stick ourselves on the end of the wait queue */
struct remote_thread_call *tmp = priv->waitDispatch;
char ignore = 1;
+ ssize_t s;
while (tmp && tmp->next)
tmp = tmp->next;
if (tmp)
@@ -8649,8 +8654,22 @@ remoteIO(virConnectPtr conn,
else
priv->waitDispatch = thiscall;
- /* Force other thread to wakup from poll */
- ignore_value (safewrite(priv->wakeupSendFD, &ignore, sizeof(ignore)));
+ /* Force other thread to wakeup from poll */
+ s = safewrite(priv->wakeupSendFD, &ignore, sizeof(ignore));
+ if (s < 0) {
+ errorf(flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
+ VIR_ERR_INTERNAL_ERROR,
+ _("failed to wake up polling thread: %s"),
+ strerror(errno));
+ VIR_FREE(thiscall);
+ return -1;
+ } else if (s != sizeof(ignore)) {
+ errorf(flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
+ VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to wake up polling thread"));
+ VIR_FREE(thiscall);
+ return -1;
+ }
DEBUG("Going to sleep %d %p %p", thiscall->proc_nr,
priv->waitDispatch, thiscall);
/* Go to sleep while other thread is working... */
--
1.6.6.1