]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virNetClientSetTLSSession: Restore original signal mask
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 19 Mar 2014 17:10:34 +0000 (18:10 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 19 Mar 2014 17:54:51 +0000 (18:54 +0100)
Currently, we use pthread_sigmask(SIG_BLOCK, ...) prior to calling
poll(). This is okay, as we don't want poll() to be interrupted.
However, then - immediately as we fall out from the poll() - we try to
restore the original sigmask - again using SIG_BLOCK. But as the man
page says, SIG_BLOCK adds signals to the signal mask:

SIG_BLOCK
      The set of blocked signals is the union of the current set and the set argument.

Therefore, when restoring the original mask, we need to completely
overwrite the one we set earlier and hence we should be using:

SIG_SETMASK
      The set of blocked signals is set to the argument set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/rpc/virnetclient.c

index b288b74e4648ca9a97c2b443fe48e98c1a97699c..255997b61139e1dc784f41714f63f19f29bac18c 100644 (file)
@@ -792,7 +792,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
         if (ret < 0 && (errno == EAGAIN || errno == EINTR))
             goto repoll;
 
-        ignore_value(pthread_sigmask(SIG_BLOCK, &oldmask, NULL));
+        ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
     }
 
     ret = virNetTLSContextCheckCertificate(tls, client->tls);
@@ -816,7 +816,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
     if (ret < 0 && (errno == EAGAIN || errno == EINTR))
         goto repoll2;
 
-    ignore_value(pthread_sigmask(SIG_BLOCK, &oldmask, NULL));
+    ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
 
     len = virNetTLSSessionRead(client->tls, buf, 1);
     if (len < 0 && errno != ENOMSG) {