Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Aug 2012 00:11:30 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r239930 - projects/fuse/sys/fs/fuse
Message-ID:  <201208310011.q7V0BUvq035849@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Fri Aug 31 00:11:30 2012
New Revision: 239930
URL: http://svn.freebsd.org/changeset/base/239930

Log:
  Mimic Linux behaviour and disable signals delivery for fuse libs user
  while waiting for deamon notifications.
  Otherwise the fuse libs user gets interrupted by spourious signals
  sent by the deamon.
  
  In collaboration with:	pho
  Tested by:	Gustau Perez i Querol

Modified:
  projects/fuse/sys/fs/fuse/fuse_ipc.c

Modified: projects/fuse/sys/fs/fuse/fuse_ipc.c
==============================================================================
--- projects/fuse/sys/fs/fuse/fuse_ipc.c	Thu Aug 30 23:54:49 2012	(r239929)
+++ projects/fuse/sys/fs/fuse/fuse_ipc.c	Fri Aug 31 00:11:30 2012	(r239930)
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/proc.h>
 #include <sys/mount.h>
 #include <sys/vnode.h>
+#include <sys/signalvar.h>
+#include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
 #include <vm/uma.h>
 
@@ -124,6 +126,27 @@ SYSCTL_INT(_vfs_fuse, OID_AUTO, iov_cred
 MALLOC_DEFINE(M_FUSEMSG, "fuse_msgbuf", "fuse message buffer");
 static uma_zone_t ticket_zone;
 
+static void
+fuse_block_sigs(sigset_t *oldset)
+{
+	sigset_t newset;
+
+	SIGFILLSET(newset);
+	SIGDELSET(newset, SIGKILL);
+	if (kern_sigprocmask(curthread, SIG_BLOCK, &newset, oldset, 0))
+		panic("%s: Invalid operation for kern_sigprocmask()",
+		    __func__);
+}
+
+static void
+fuse_restore_sigs(sigset_t *oldset)
+{
+
+	if (kern_sigprocmask(curthread, SIG_SETMASK, oldset, NULL, 0))
+		panic("%s: Invalid operation for kern_sigprocmask()",
+		    __func__);
+}
+
 void
 fiov_init(struct fuse_iov *fiov, size_t size)
 {
@@ -289,6 +312,7 @@ fticket_refresh(struct fuse_ticket *ftic
 static int
 fticket_wait_answer(struct fuse_ticket *ftick)
 {
+	sigset_t tset;
 	int err = 0;
 	struct fuse_data *data;
 
@@ -305,8 +329,10 @@ fticket_wait_answer(struct fuse_ticket *
 		fticket_set_answered(ftick);
 		goto out;
 	}
+	fuse_block_sigs(&tset);
 	err = msleep(ftick, &ftick->tk_aw_mtx, PCATCH, "fu_ans",
 	    data->daemon_timeout * hz);
+	fuse_restore_sigs(&tset);
 	if (err == EAGAIN) {		/* same as EWOULDBLOCK */
 #ifdef XXXIP				/* die conditionally */
 		if (!fdata_get_dead(data)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208310011.q7V0BUvq035849>