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

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



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

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


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