Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2015 13:09:54 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r277697 - in stable/10/sys: fs/fifofs kern sys
Message-ID:  <201501251309.t0PD9sV2059920@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Jan 25 13:09:53 2015
New Revision: 277697
URL: https://svnweb.freebsd.org/changeset/base/277697

Log:
  MFC r277321:
  Make SIGSTOP working for sleeps done while waiting for fifo readers or
  writers in open(2), when the fifo is located on an NFS mount.

Modified:
  stable/10/sys/fs/fifofs/fifo_vnops.c
  stable/10/sys/kern/kern_sig.c
  stable/10/sys/sys/signalvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/fifofs/fifo_vnops.c
==============================================================================
--- stable/10/sys/fs/fifofs/fifo_vnops.c	Sun Jan 25 12:50:26 2015	(r277696)
+++ stable/10/sys/fs/fifofs/fifo_vnops.c	Sun Jan 25 13:09:53 2015	(r277697)
@@ -137,7 +137,7 @@ fifo_open(ap)
 	struct thread *td;
 	struct fifoinfo *fip;
 	struct pipe *fpipe;
-	int error;
+	int error, stops_deferred;
 
 	vp = ap->a_vp;
 	fp = ap->a_fp;
@@ -188,8 +188,11 @@ fifo_open(ap)
 	if ((ap->a_mode & O_NONBLOCK) == 0) {
 		if ((ap->a_mode & FREAD) && fip->fi_writers == 0) {
 			VOP_UNLOCK(vp, 0);
+			stops_deferred = sigallowstop();
 			error = msleep(&fip->fi_readers, PIPE_MTX(fpipe),
 			    PDROP | PCATCH | PSOCK, "fifoor", 0);
+			if (stops_deferred)
+				sigdeferstop();
 			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 			if (error) {
 				fip->fi_readers--;
@@ -212,8 +215,11 @@ fifo_open(ap)
 		}
 		if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) {
 			VOP_UNLOCK(vp, 0);
+			stops_deferred = sigallowstop();
 			error = msleep(&fip->fi_writers, PIPE_MTX(fpipe),
 			    PDROP | PCATCH | PSOCK, "fifoow", 0);
+			if (stops_deferred)
+				sigdeferstop();
 			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 			if (error) {
 				fip->fi_writers--;

Modified: stable/10/sys/kern/kern_sig.c
==============================================================================
--- stable/10/sys/kern/kern_sig.c	Sun Jan 25 12:50:26 2015	(r277696)
+++ stable/10/sys/kern/kern_sig.c	Sun Jan 25 13:09:53 2015	(r277697)
@@ -2596,15 +2596,18 @@ sigdeferstop(void)
  * not immediately suspend if a stop was posted.  Instead, the thread
  * will suspend either via ast() or a subsequent interruptible sleep.
  */
-void
-sigallowstop()
+int
+sigallowstop(void)
 {
 	struct thread *td;
+	int prev;
 
 	td = curthread;
 	thread_lock(td);
+	prev = (td->td_flags & TDF_SBDRY) != 0;
 	td->td_flags &= ~TDF_SBDRY;
 	thread_unlock(td);
+	return (prev);
 }
 
 /*

Modified: stable/10/sys/sys/signalvar.h
==============================================================================
--- stable/10/sys/sys/signalvar.h	Sun Jan 25 12:50:26 2015	(r277696)
+++ stable/10/sys/sys/signalvar.h	Sun Jan 25 13:09:53 2015	(r277697)
@@ -325,7 +325,7 @@ extern struct mtx	sigio_lock;
 
 int	cursig(struct thread *td);
 int	sigdeferstop(void);
-void	sigallowstop(void);
+int	sigallowstop(void);
 void	execsigs(struct proc *p);
 void	gsignal(int pgid, int sig, ksiginfo_t *ksi);
 void	killproc(struct proc *p, char *why);



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