]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add HAVE_PTHREAD_H guard for pthread_sigmask
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 19 Mar 2010 20:09:30 +0000 (21:09 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 23 Mar 2010 01:13:19 +0000 (02:13 +0100)
Correctly disable pthread related code if pthread is not avialable,
in order to get it compile with MinGW on Windows.

src/remote/remote_driver.c
src/util/util.c

index b7e1c0307a0c3cd927ca9a076c55af01d1837cbc..1476f191814591557a6e9ed7b5e158b03e5d0290 100644 (file)
@@ -8507,7 +8507,9 @@ remoteIOEventLoop(virConnectPtr conn,
         struct remote_thread_call *tmp = priv->waitDispatch;
         struct remote_thread_call *prev;
         char ignore;
+#ifdef HAVE_PTHREAD_H
         sigset_t oldmask, blockedsigs;
+#endif
 
         fds[0].events = fds[0].revents = 0;
         fds[1].events = fds[1].revents = 0;
@@ -8534,18 +8536,22 @@ remoteIOEventLoop(virConnectPtr conn,
          * after the call (RHBZ#567931).  Same for SIGCHLD and SIGPIPE
          * at the suggestion of Paolo Bonzini and Daniel Berrange.
          */
+#ifdef HAVE_PTHREAD_H
         sigemptyset (&blockedsigs);
         sigaddset (&blockedsigs, SIGWINCH);
         sigaddset (&blockedsigs, SIGCHLD);
         sigaddset (&blockedsigs, SIGPIPE);
         ignore_value (pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
+#endif
 
     repoll:
         ret = poll(fds, ARRAY_CARDINALITY(fds), -1);
         if (ret < 0 && errno == EAGAIN)
             goto repoll;
 
+#ifdef HAVE_PTHREAD_H
         ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
+#endif
 
         remoteDriverLock(priv);
 
index c312719d19dfca53cc6b7358cb9107f0223f73c6..0d5e0a8a71b60405c94221b4ea441642abcda456 100644 (file)
@@ -316,7 +316,9 @@ static int virClearCapabilities(void)
 
  */
 int virFork(pid_t *pid) {
+#  ifdef HAVE_PTHREAD_H
     sigset_t oldmask, newmask;
+#  endif
     struct sigaction sig_action;
     int saved_errno, ret = -1;
 
@@ -326,6 +328,7 @@ int virFork(pid_t *pid) {
      * Need to block signals now, so that child process can safely
      * kill off caller's signal handlers without a race.
      */
+#  ifdef HAVE_PTHREAD_H
     sigfillset(&newmask);
     if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) {
         saved_errno = errno;
@@ -333,6 +336,7 @@ int virFork(pid_t *pid) {
                              "%s", _("cannot block signals"));
         goto cleanup;
     }
+#  endif
 
     /* Ensure we hold the logging lock, to protect child processes
      * from deadlocking on another thread's inherited mutex state */
@@ -345,9 +349,11 @@ int virFork(pid_t *pid) {
     virLogUnlock();
 
     if (*pid < 0) {
+#  ifdef HAVE_PTHREAD_H
         /* attempt to restore signal mask, but ignore failure, to
            avoid obscuring the fork failure */
         ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
+#  endif
         virReportSystemError(saved_errno,
                              "%s", _("cannot fork child process"));
         goto cleanup;
@@ -357,6 +363,7 @@ int virFork(pid_t *pid) {
 
         /* parent process */
 
+#  ifdef HAVE_PTHREAD_H
         /* Restore our original signal mask now that the child is
            safely running */
         if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) {
@@ -364,6 +371,7 @@ int virFork(pid_t *pid) {
             virReportSystemError(errno, "%s", _("cannot unblock signals"));
             goto cleanup;
         }
+#  endif
         ret = 0;
 
     } else {
@@ -399,6 +407,7 @@ int virFork(pid_t *pid) {
             sigaction(i, &sig_action, NULL);
         }
 
+#  ifdef HAVE_PTHREAD_H
         /* Unmask all signals in child, since we've no idea
            what the caller's done with their signal mask
            and don't want to propagate that to children */
@@ -408,6 +417,7 @@ int virFork(pid_t *pid) {
             virReportSystemError(errno, "%s", _("cannot unblock signals"));
             goto cleanup;
         }
+#  endif
         ret = 0;
     }