changeset 10620:a9d7350484cf

6866221 Setting AIO_SIGNALLED needs to be tightened.
author Surya Prakki <Surya.Prakki@Sun.COM>
date Wed, 23 Sep 2009 03:52:25 -0700
parents bb631a61091f
children a6ab13bfdd64
files usr/src/uts/common/os/aio_subr.c
diffstat 1 files changed, 21 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/os/aio_subr.c	Wed Sep 23 14:53:25 2009 +0530
+++ b/usr/src/uts/common/os/aio_subr.c	Wed Sep 23 03:52:25 2009 -0700
@@ -207,6 +207,7 @@
 	void (*func)();
 	int use_port = 0;
 	int reqp_flags = 0;
+	int send_signal = 0;
 
 	p = bp->b_proc;
 	as = p->p_as;
@@ -385,6 +386,17 @@
 		cv_broadcast(&aiop->aio_waitcv);
 	}
 
+	/*
+	 * No need to set this flag for pollq, portq, lio requests.
+	 * Send a SIGIO signal when the process has a handler enabled.
+	 */
+	if (!sigev && !use_port && head == NULL &&
+	    (func = PTOU(p)->u_signal[SIGIO - 1]) != SIG_DFL &&
+	    (func != SIG_IGN)) {
+		send_signal = 1;
+		reqp->aio_req_flags |= AIO_SIGNALLED;
+	}
+
 	mutex_exit(&aiop->aio_mutex);
 	mutex_exit(&aiop->aio_portq_mutex);
 
@@ -402,18 +414,9 @@
 
 	if (sigev)
 		aio_sigev_send(p, sigev);
-	else if (!use_port && head == NULL) {
-		/*
-		 * Send a SIGIO signal when the process has a handler enabled.
-		 */
-		if ((func = PTOU(p)->u_signal[SIGIO - 1]) !=
-		    SIG_DFL && (func != SIG_IGN)) {
-			psignal(p, SIGIO);
-			mutex_enter(&aiop->aio_mutex);
-			reqp->aio_req_flags |= AIO_SIGNALLED;
-			mutex_exit(&aiop->aio_mutex);
-		}
-	}
+	else if (send_signal)
+		psignal(p, SIGIO);
+
 	if (pkevp)
 		port_send_event(pkevp);
 	if (lio_sigev)
@@ -911,8 +914,12 @@
 			aio_req_free(aiop, reqp);
 		else
 			aio_enq(&aiop->aio_doneq, reqp, AIO_DONEQ);
-		if (!exitflg && reqp->aio_req_flags & AIO_SIGNALLED)
-			signalled++;
+		if (!exitflg) {
+			if (reqp->aio_req_flags & AIO_SIGNALLED)
+				signalled++;
+			else
+				reqp->aio_req_flags |= AIO_SIGNALLED;
+		}
 		mutex_exit(&aiop->aio_mutex);
 	} while ((reqp = next) != qhead);
 	return (signalled);