rawmidi/ctl/timer read() blocks too long
PATCH 1/1 rawmidi/ctl/timer read() blocks too long
When read() can return some data, is mustn't sleep.
The behaviour of snd_ctl_hw_read() doesn't change as it reads only one event at a time anyway.
The behaviour of snd_rawmidi_read() does change, but now it's compatible to OSS rawmidi devices.
I added set_current_state(TASK_RUNNING) to snd_timer_user_read() because other sleep loops have this, too.
Furthermore, if there is an error when some data has already been read successfully, snd_timer_user_read() should return this data instead of the error.
core/control.c +1 -1
@@ -660,7 +660,7 @@snd_kctl_event_t *kev;while (list_empty (&ctl->events)) {wait_queue_t wait; -if (file->f_flags &O_NONBLOCK ) { +if (file->f_flags &O_NONBLOCK || result >0 ) { err = -EAGAIN ; goto __end; }
core/rawmidi.c +1 -1
@@ -943,7 +943,7 @@spin_lock_irq (&runtime->lock);while (!snd_rawmidi_ready (substream)) {wait_queue_t wait; -if (file->f_flags &O_NONBLOCK ) { +if (file->f_flags &O_NONBLOCK || result >0 ) {spin_unlock_irq (&runtime->lock);return result >0 ? result : -EAGAIN ; }
core/timer.c +3 -2
@@ -1270,7 +1270,7 @@while (!tu->qused) {wait_queue_t wait; -if (file->f_flags &O_NONBLOCK ) { +if (file->f_flags &O_NONBLOCK || result >0 ) {spin_unlock_irq (&tu->qlock); err = -EAGAIN ;break ;
@@ -1285,6 +1285,7 @@spin_lock_irq (&tu->qlock);remove_wait_queue (&tu->qchange_sleep, &wait); +set_current_state (TASK_RUNNING );if (signal_pending (current)) { err = -ERESTARTSYS ;
@@ -1307,7 +1308,7 @@ result +=sizeof (snd_timer_read_t); buffer +=sizeof (snd_timer_read_t); } -return err? err: result; +return result >0 ? result : err; }static unsigned int snd_timer_user_poll (struct file *file,poll_table * wait)
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf