Gnulib finally learned how to do pthread_sigmask on mingw.
* .gnulib: Update to latest, for pthread_sigmask.
* bootstrap.conf (gnulib_modules): Add pthread_sigmask.
* configure.ac (AC_CHECK_FUNCS): Drop redundant check.
* src/rpc/virnetclient.c (virNetClientSetTLSSession)
(virNetClientIOEventLoop): Make code unconditional.
* src/util/command.c (virFork): Likewise.
* tools/virsh.c (doMigrate, cmdMigrate): Likewise.
-Subproject commit c3153d2c0cf5f675ae13ae2bd1dee0f463b9c86a
+Subproject commit 56005a21e8f9f434212a19dcb628c6d3b179fd08
poll
posix-shell
pthread
+pthread_sigmask
recv
random_r
sched
dnl LIB_PTHREAD was set during gl_INIT by gnulib.
old_LIBS=$LIBS
LIBS="$LIBS $LIB_PTHREAD"
-AC_CHECK_FUNCS([pthread_sigmask pthread_mutexattr_init])
+AC_CHECK_FUNCS([pthread_mutexattr_init])
LIBS=$old_libs
dnl Availability of various common headers (non-fatal if missing).
char buf[1];
int len;
struct pollfd fds[1];
-#ifdef HAVE_PTHREAD_SIGMASK
sigset_t oldmask, blockedsigs;
sigemptyset (&blockedsigs);
+#ifdef SIGWINCH
sigaddset (&blockedsigs, SIGWINCH);
+#endif
+#ifdef SIGCHLD
sigaddset (&blockedsigs, SIGCHLD);
- sigaddset (&blockedsigs, SIGPIPE);
#endif
+ sigaddset (&blockedsigs, SIGPIPE);
virNetClientLock(client);
* after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE
* at the suggestion of Paolo Bonzini and Daniel Berrange.
*/
-#ifdef HAVE_PTHREAD_SIGMASK
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_SIGMASK
ignore_value(pthread_sigmask(SIG_BLOCK, &oldmask, NULL));
-#endif
}
ret = virNetTLSContextCheckCertificate(tls, client->tls);
fds[0].revents = 0;
fds[0].events = POLLIN;
-#ifdef HAVE_PTHREAD_SIGMASK
/* Block SIGWINCH from interrupting poll in curses programs */
ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
-#endif
repoll2:
ret = poll(fds, ARRAY_CARDINALITY(fds), -1);
if (ret < 0 && errno == EAGAIN)
goto repoll2;
-#ifdef HAVE_PTHREAD_SIGMASK
ignore_value(pthread_sigmask(SIG_BLOCK, &oldmask, NULL));
-#endif
len = virNetTLSSessionRead(client->tls, buf, 1);
if (len < 0) {
virNetClientCallPtr tmp = client->waitDispatch;
virNetClientCallPtr prev;
char ignore;
-#ifdef HAVE_PTHREAD_SIGMASK
sigset_t oldmask, blockedsigs;
-#endif
int timeout = -1;
/* If we have existing SASL decoded data we
* after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE
* at the suggestion of Paolo Bonzini and Daniel Berrange.
*/
-#ifdef HAVE_PTHREAD_SIGMASK
sigemptyset (&blockedsigs);
+#ifdef SIGWINCH
sigaddset (&blockedsigs, SIGWINCH);
+#endif
+#ifdef SIGCHLD
sigaddset (&blockedsigs, SIGCHLD);
+#endif
sigaddset (&blockedsigs, SIGPIPE);
ignore_value(pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
-#endif
repoll:
ret = poll(fds, ARRAY_CARDINALITY(fds), timeout);
if (ret < 0 && errno == EAGAIN)
goto repoll;
-#ifdef HAVE_PTHREAD_SIGMASK
ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
-#endif
virNetClientLock(client);
*/
int virFork(pid_t *pid) {
-# ifdef HAVE_PTHREAD_SIGMASK
sigset_t oldmask, newmask;
-# endif
struct sigaction sig_action;
int saved_errno, ret = -1;
* Need to block signals now, so that child process can safely
* kill off caller's signal handlers without a race.
*/
-# ifdef HAVE_PTHREAD_SIGMASK
sigfillset(&newmask);
if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) {
saved_errno = errno;
"%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 */
virLogUnlock();
if (*pid < 0) {
-# ifdef HAVE_PTHREAD_SIGMASK
/* 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;
/* parent process */
-# ifdef HAVE_PTHREAD_SIGMASK
/* Restore our original signal mask now that the child is
safely running */
if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) {
virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup;
}
-# endif
ret = 0;
} else {
sigaction(i, &sig_action, NULL);
}
-# ifdef HAVE_PTHREAD_SIGMASK
/* 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 */
virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup;
}
-# endif
ret = 0;
}
const vshCmd *cmd = data->cmd;
const char *xmlfile = NULL;
char *xml = NULL;
-#if HAVE_PTHREAD_SIGMASK
sigset_t sigmask, oldsigmask;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGINT);
if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
goto out_sig;
-#endif
if (!vshConnectionUsability (ctl, ctl->conn))
goto out;
}
out:
-#if HAVE_PTHREAD_SIGMASK
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
-#endif
if (dom) virDomainFree (dom);
VIR_FREE(xml);
ignore_value(safewrite(data->writefd, &ret, sizeof(ret)));
struct timeval start, curr;
bool live_flag = false;
vshCtrlData data;
-#if HAVE_PTHREAD_SIGMASK
sigset_t sigmask, oldsigmask;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGINT);
-#endif
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
}
if (verbose) {
-#if HAVE_PTHREAD_SIGMASK
pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask);
-#endif
ret = virDomainGetJobInfo(dom, &jobinfo);
-#if HAVE_PTHREAD_SIGMASK
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
-#endif
if (ret == 0)
print_job_progress(jobinfo.dataRemaining, jobinfo.dataTotal);
}