Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] dmxdev_filter_t mutex
The patch below adds a mutex to dmxdev_filter_t. When using the DVB driver we
had problems with multiple processes (setting up a number of different
section/PES filters) reading from the demux. This was due to DmxDevRead
locking the dmxdev mutex so only one read at a time was allowed. This patch
adds a filter specific mutex which allows multiple reads at the same time.
[mdavis@tun cvs]$ diff -ru DVB/ temp/DVB/
diff -ru DVB/driver/dmxdev.c temp/DVB/driver/dmxdev.c
--- DVB/driver/dmxdev.c Thu Aug 1 11:46:11 2002
+++ temp/DVB/driver/dmxdev.c Thu Aug 15 12:49:57 2002
@@ -722,6 +726,7 @@
return -EMFILE;
}
dmxdevfilter=&dmxdev->filter[i];
+ sema_init(&dmxdevfilter->mutex, 1);
file->private_data=dmxdevfilter;
DmxDevBufferInit(&dmxdevfilter->buffer);
@@ -747,6 +752,11 @@
up(&dmxdev->mutex);
return -EINVAL;
}
+
+ if (down_interruptible(&dmxdevfilter->mutex)) {
+ up(&dmxdev->mutex);
+ return -ERESTARTSYS;
+ }
DmxDevFilterStop(dmxdevfilter);
DmxDevFilterReset(dmxdevfilter);
@@ -761,6 +771,7 @@
}
DmxDevFilterStateSet(dmxdevfilter, DMXDEV_STATE_FREE);
wake_up(&dmxdevfilter->buffer.queue);
+ up(&dmxdevfilter->mutex);
up(&dmxdev->mutex);
//printk("free filters = %d\n", DmxDevFilterNum(dmxdev));
return 0;
@@ -907,7 +924,7 @@
dmxdev_filter_t *dmxdevfilter=DmxDevFile2Filter(dmxdev, file);
int ret=0;
- if (down_interruptible(&dmxdev->mutex))
+ if (down_interruptible(&dmxdevfilter->mutex))
return -ERESTARTSYS;
if (dmxdevfilter->type==DMXDEV_TYPE_SEC)
@@ -916,7 +933,7 @@
ret=DmxDevBufferRead(&dmxdevfilter->buffer,
file->f_flags&O_NONBLOCK,
buf, count, ppos);
- up(&dmxdev->mutex);
+ up(&dmxdevfilter->mutex);
return ret;
}
@@ -937,14 +954,26 @@
switch (cmd) {
case DMX_START:
+ if (down_interruptible(&dmxdevfilter->mutex)) {
+ up(&dmxdev->mutex);
+ return -ERESTARTSYS;
+ }
+
if (dmxdevfilter->state<DMXDEV_STATE_SET)
ret=-EINVAL;
else
ret=DmxDevFilterStart(dmxdevfilter);
+
+ up(&dmxdevfilter->mutex);
break;
case DMX_STOP:
+ if (down_interruptible(&dmxdevfilter->mutex)) {
+ up(&dmxdev->mutex);
+ return -ERESTARTSYS;
+ }
ret=DmxDevFilterStop(dmxdevfilter);
+ up(&dmxdevfilter->mutex);
break;
case DMX_SET_FILTER:
@@ -954,8 +983,14 @@
if (copy_from_user(¶ms, parg, sizeof(params)))
ret=-EFAULT;
- else
+ else {
+ if (down_interruptible(&dmxdevfilter->mutex)) {
+ up(&dmxdev->mutex);
+ return -ERESTARTSYS;
+ }
ret=DmxDevFilterSet(dmxdev, dmxdevfilter, ¶ms);
+ up(&dmxdevfilter->mutex);
+ }
break;
}
@@ -965,13 +1000,24 @@
if (copy_from_user(¶ms, parg, sizeof(params)))
ret=-EFAULT;
- else
+ else {
+ if (down_interruptible(&dmxdevfilter->mutex)) {
+ up(&dmxdev->mutex);
+ return -ERESTARTSYS;
+ }
ret=DmxDevPesFilterSet(dmxdev, dmxdevfilter, ¶ms);
+ up(&dmxdevfilter->mutex);
+ }
break;
}
case DMX_SET_BUFFER_SIZE:
+ if (down_interruptible(&dmxdevfilter->mutex)) {
+ up(&dmxdev->mutex);
+ return -ERESTARTSYS;
+ }
ret=DmxDevSetBufferSize(dmxdevfilter, arg);
+ up(&dmxdevfilter->mutex);
break;
case DMX_GET_EVENT:
diff -ru DVB/driver/dmxdev.h temp/DVB/driver/dmxdev.h
--- DVB/driver/dmxdev.h Mon Oct 29 05:51:26 2001
+++ temp/DVB/driver/dmxdev.h Wed Aug 7 15:08:30 2002
@@ -96,6 +96,8 @@
struct dmxdev_s *dev;
dmxdev_buffer_t buffer;
+ struct semaphore mutex;
+
// only for sections
struct timer_list timer;
int todo;
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index