aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libdvbv5
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-08-06 19:12:13 (GMT)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-08-06 19:13:45 (GMT)
commita95865a40c39e5a9d39119ffe72724b7624077d0 (patch)
tree86bedc9d9f0c358deb6d39800ce7c406d159eb56 /lib/libdvbv5
parent49010212a7f0e0643083d5f1f9b185c8cb1ea156 (diff)
libdvbv5: Fix remote read()
There were several small bugs making read() unreliable when used over a remote connection. Address them. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'lib/libdvbv5')
-rw-r--r--lib/libdvbv5/dvb-dev-local.c4
-rw-r--r--lib/libdvbv5/dvb-dev-remote.c27
2 files changed, 14 insertions, 17 deletions
diff --git a/lib/libdvbv5/dvb-dev-local.c b/lib/libdvbv5/dvb-dev-local.c
index 796571d..4632991 100644
--- a/lib/libdvbv5/dvb-dev-local.c
+++ b/lib/libdvbv5/dvb-dev-local.c
@@ -16,6 +16,10 @@
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+
#include <libudev.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libdvbv5/dvb-dev-remote.c b/lib/libdvbv5/dvb-dev-remote.c
index 1353b85..640e2bd 100644
--- a/lib/libdvbv5/dvb-dev-remote.c
+++ b/lib/libdvbv5/dvb-dev-remote.c
@@ -16,6 +16,10 @@
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+
#include <libudev.h>
#include <stdio.h>
#include <stdlib.h>
@@ -234,7 +238,8 @@ static struct queued_msg *send_fmt(struct dvb_device_priv *dvb, int fd,
p += ret;
- ret = write(fd, buf, p - buf);
+ pthread_mutex_lock(&msg->lock);
+ ret = send(fd, buf, p - buf, MSG_CONFIRM);
if (ret < 0 || (ret < p - buf)) {
pthread_mutex_destroy(&msg->lock);
pthread_cond_destroy(&msg->cond);
@@ -525,7 +530,6 @@ static int dvb_remote_get_version(struct dvb_device_priv *dvb)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -567,7 +571,6 @@ static int dvb_remote_find(struct dvb_device_priv *dvb, int enable_monitor)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -600,7 +603,6 @@ static int dvb_remote_stop_monitor(struct dvb_device_priv *dvb)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -638,7 +640,6 @@ struct dvb_dev_list *dvb_remote_seek_by_sysname(struct dvb_device_priv *dvb,
if (!msg)
return NULL;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -709,7 +710,6 @@ static struct dvb_open_descriptor *dvb_remote_open(struct dvb_device_priv *dvb,
if (!msg)
return NULL;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -760,7 +760,6 @@ static int dvb_remote_close(struct dvb_open_descriptor *open_dev)
if (!msg)
goto error;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -812,7 +811,6 @@ static int dvb_remote_dmx_stop(struct dvb_open_descriptor *open_dev)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -848,7 +846,6 @@ static int dvb_remote_set_bufsize(struct dvb_open_descriptor *open_dev,
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -886,7 +883,6 @@ static ssize_t dvb_remote_read(struct dvb_open_descriptor *open_dev,
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -918,6 +914,10 @@ error:
pthread_mutex_unlock(&msg->lock);
free_msg(dvb, msg);
+
+ if (ret < 0)
+ errno = -ret;
+
return ret;
}
@@ -936,7 +936,6 @@ static int dvb_remote_dmx_set_pesfilter(struct dvb_open_descriptor *open_dev,
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -977,7 +976,6 @@ static int dvb_remote_dmx_set_section_filter(struct dvb_open_descriptor *open_de
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -1012,7 +1010,6 @@ static int dvb_remote_dmx_get_pmt_pid(struct dvb_open_descriptor *open_dev, int
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -1046,7 +1043,6 @@ int dvb_remote_fe_set_sys(struct dvb_v5_fe_parms *p, fe_delivery_system_t sys)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -1083,7 +1079,6 @@ int dvb_remote_fe_get_parms(struct dvb_v5_fe_parms *par)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -1227,7 +1222,6 @@ int dvb_remote_fe_set_parms(struct dvb_v5_fe_parms *par)
if (!msg)
goto error;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);
@@ -1269,7 +1263,6 @@ int dvb_remote_fe_get_stats(struct dvb_v5_fe_parms *par)
if (!msg)
return -1;
- pthread_mutex_lock(&msg->lock);
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
dvb_logerr("error waiting for %s response", msg->cmd);

Privacy Policy