Module Name:    src
Committed By:   nat
Date:           Tue May  2 06:25:05 UTC 2017

Modified Files:
        src/sys/dev: audio.c

Log Message:
Explicitly set ioflag in audio_[read/write] IO_NDELAY if O_NONBLOCK is set
in f_flags.  This makes nonblocking reads and writes behave normally.

Addresses PR kern/52196.


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/sys/dev/audio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.329 src/sys/dev/audio.c:1.330
--- src/sys/dev/audio.c:1.329	Fri Apr 28 06:59:49 2017
+++ src/sys/dev/audio.c	Tue May  2 06:25:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.329 2017/04/28 06:59:49 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.330 2017/05/02 06:25:05 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <nathanialsl...@yahoo.com.au>
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.329 2017/04/28 06:59:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.330 2017/05/02 06:25:05 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -1661,6 +1661,9 @@ audioread(struct file *fp, off_t *offp, 
 	if ((error = audio_enter(dev, RW_READER, &sc)) != 0)
 		return error;
 
+	if (fp->f_flag & O_NONBLOCK)
+		ioflag |= IO_NDELAY;
+
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:
 	case AUDIO_DEVICE:
@@ -1697,6 +1700,9 @@ audiowrite(struct file *fp, off_t *offp,
 	if ((error = audio_enter(dev, RW_READER, &sc)) != 0)
 		return error;
 
+	if (fp->f_flag & O_NONBLOCK)
+		ioflag |= IO_NDELAY;
+
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:
 	case AUDIO_DEVICE:

Reply via email to