Re: [PATCH 2/3] Ensure errno is valid when returning from lxcContainerWaitForContinue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/01/2011 08:31 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@xxxxxxxxxx>

Only some of the return paths of lxcContainerWaitForContinue will
have set errno. In other paths we need to set it manually to avoid
the caller getting a random stale errno value

* src/lxc/lxc_container.c: Set errno in lxcContainerWaitForContinue
---
  src/lxc/lxc_container.c |    9 +++++++--
  1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 06ccf7e..7a3589b 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -224,8 +224,13 @@ int lxcContainerWaitForContinue(int control)
      int readLen;

      readLen = saferead(control,&msg, sizeof(msg));
-    if (readLen != sizeof(msg) ||
-        msg != LXC_CONTINUE_MSG) {
+    if (readLen != sizeof(msg)) {
+        if (readLen>= 0)
+            errno = EIO;
+        return -1;
+    }
+    if (msg != LXC_CONTINUE_MSG) {
msg being a single char -- ok so that works.
+        errno = EINVAL;
          return -1;
      }

ACK

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]