Update of /cvsroot/alsa/alsa-kernel/core/seq
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6058

Modified Files:
        seq_fifo.c seq_memory.c 
Log Message:
- fixed the race conditions.





Index: seq_fifo.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/seq/seq_fifo.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- seq_fifo.c  7 Jan 2004 14:34:22 -0000       1.7
+++ seq_fifo.c  11 Feb 2004 19:40:02 -0000      1.8
@@ -171,10 +171,12 @@
 {
        snd_seq_event_cell_t *cell;
        unsigned long flags;
+       wait_queue_t wait;
 
        snd_assert(f != NULL, return -EINVAL);
 
        *cellp = NULL;
+       init_waitqueue_entry(&wait, current);
        spin_lock_irqsave(&f->lock, flags);
        while ((cell = fifo_cell_out(f)) == NULL) {
                if (nonblock) {
@@ -182,17 +184,19 @@
                        spin_unlock_irqrestore(&f->lock, flags);
                        return -EAGAIN;
                }
-               spin_unlock(&f->lock);
-               interruptible_sleep_on(&f->input_sleep);
-               spin_lock(&f->lock);
-
+               set_current_state(TASK_INTERRUPTIBLE);
+               add_wait_queue(&f->input_sleep, &wait);
+               spin_unlock_irq(&f->lock);
+               schedule();
+               spin_lock_irq(&f->lock);
+               remove_wait_queue(&f->input_sleep, &wait);
                if (signal_pending(current)) {
                        spin_unlock_irqrestore(&f->lock, flags);
                        return -ERESTARTSYS;
                }
        }
-       *cellp = cell;
        spin_unlock_irqrestore(&f->lock, flags);
+       *cellp = cell;
 
        return 0;
 }

Index: seq_memory.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/seq/seq_memory.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- seq_memory.c        7 Jan 2004 14:34:22 -0000       1.13
+++ seq_memory.c        11 Feb 2004 19:40:02 -0000      1.14
@@ -220,12 +220,14 @@
        snd_seq_event_cell_t *cell;
        unsigned long flags;
        int err = -EAGAIN;
+       wait_queue_t wait;
 
        if (pool == NULL)
                return -EINVAL;
 
        *cellp = NULL;
 
+       init_waitqueue_entry(&wait, current);
        spin_lock_irqsave(&pool->lock, flags);
        if (pool->ptr == NULL) {        /* not initialized */
                snd_printd("seq: pool is not initialized\n");
@@ -234,9 +236,12 @@
        }
        while (pool->free == NULL && ! nonblock && ! pool->closing) {
 
-               spin_unlock(&pool->lock);
-               interruptible_sleep_on(&pool->output_sleep);
-               spin_lock(&pool->lock);
+               set_current_state(TASK_INTERRUPTIBLE);
+               add_wait_queue(&pool->output_sleep, &wait);
+               spin_unlock_irq(&pool->lock);
+               schedule();
+               spin_lock_irq(&pool->lock);
+               remove_wait_queue(&pool->output_sleep, &wait);
                /* interrupted? */
                if (signal_pending(current)) {
                        err = -ERESTARTSYS;



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to