render / rpms / libvirt

Forked from rpms/libvirt 8 months ago
Clone
4fec1b
From fc487718995019c158cbf8305b6473f0dfb61ef7 Mon Sep 17 00:00:00 2001
4fec1b
Message-Id: <fc487718995019c158cbf8305b6473f0dfb61ef7@dist-git>
4fec1b
From: Michal Privoznik <mprivozn@redhat.com>
4fec1b
Date: Tue, 24 Jun 2014 15:44:35 +0200
4fec1b
Subject: [PATCH] virNetClientSetTLSSession: Restore original signal mask
4fec1b
4fec1b
https://bugzilla.redhat.com/show_bug.cgi?id=1112689
4fec1b
4fec1b
Currently, we use pthread_sigmask(SIG_BLOCK, ...) prior to calling
4fec1b
poll(). This is okay, as we don't want poll() to be interrupted.
4fec1b
However, then - immediately as we fall out from the poll() - we try to
4fec1b
restore the original sigmask - again using SIG_BLOCK. But as the man
4fec1b
page says, SIG_BLOCK adds signals to the signal mask:
4fec1b
4fec1b
SIG_BLOCK
4fec1b
      The set of blocked signals is the union of the current set and the set argument.
4fec1b
4fec1b
Therefore, when restoring the original mask, we need to completely
4fec1b
overwrite the one we set earlier and hence we should be using:
4fec1b
4fec1b
SIG_SETMASK
4fec1b
      The set of blocked signals is set to the argument set.
4fec1b
4fec1b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4fec1b
(cherry picked from commit 3d4b4f5ac634c123af1981084add29d3a2ca6ab0)
4fec1b
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4fec1b
---
4fec1b
 src/rpc/virnetclient.c | 4 ++--
4fec1b
 1 file changed, 2 insertions(+), 2 deletions(-)
4fec1b
4fec1b
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
4fec1b
index 9deec9e..9cb77cd 100644
4fec1b
--- a/src/rpc/virnetclient.c
4fec1b
+++ b/src/rpc/virnetclient.c
4fec1b
@@ -789,7 +789,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
4fec1b
         if (ret < 0 && (errno == EAGAIN || errno == EINTR))
4fec1b
             goto repoll;
4fec1b
 
4fec1b
-        ignore_value(pthread_sigmask(SIG_BLOCK, &oldmask, NULL));
4fec1b
+        ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
4fec1b
     }
4fec1b
 
4fec1b
     ret = virNetTLSContextCheckCertificate(tls, client->tls);
4fec1b
@@ -813,7 +813,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
4fec1b
     if (ret < 0 && (errno == EAGAIN || errno == EINTR))
4fec1b
         goto repoll2;
4fec1b
 
4fec1b
-    ignore_value(pthread_sigmask(SIG_BLOCK, &oldmask, NULL));
4fec1b
+    ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
4fec1b
 
4fec1b
     len = virNetTLSSessionRead(client->tls, buf, 1);
4fec1b
     if (len < 0 && errno != ENOMSG) {
4fec1b
-- 
4fec1b
2.0.0
4fec1b