shmsink: Print errors if fchmod fails

This commit is contained in:
Olivier Crête 2010-06-03 14:22:36 -04:00
parent b9decbb056
commit f26d799676
3 changed files with 17 additions and 6 deletions

View File

@ -195,6 +195,7 @@ gst_shm_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstShmSink *self = GST_SHM_SINK (object); GstShmSink *self = GST_SHM_SINK (object);
int ret = 0;
switch (prop_id) { switch (prop_id) {
case PROP_SOCKET_PATH: case PROP_SOCKET_PATH:
@ -206,8 +207,12 @@ gst_shm_sink_set_property (GObject * object, guint prop_id,
case PROP_PERMS: case PROP_PERMS:
GST_OBJECT_LOCK (object); GST_OBJECT_LOCK (object);
self->perms = g_value_get_uint (value); self->perms = g_value_get_uint (value);
sp_writer_setperms_shm (self->pipe, self->perms); if (self->pipe)
ret = sp_writer_setperms_shm (self->pipe, self->perms);
GST_OBJECT_UNLOCK (object); GST_OBJECT_UNLOCK (object);
if (ret < 0)
GST_WARNING_OBJECT (object, "Could not set permissions on pipe: %s",
strerror (ret));
break; break;
case PROP_SHM_SIZE: case PROP_SHM_SIZE:
GST_OBJECT_LOCK (object); GST_OBJECT_LOCK (object);
@ -245,8 +250,14 @@ gst_shm_sink_get_property (GObject * object, guint prop_id,
break; break;
case PROP_PERMS: case PROP_PERMS:
self->perms = g_value_get_uint (value); self->perms = g_value_get_uint (value);
if (self->pipe) if (self->pipe) {
sp_writer_setperms_shm (self->pipe, self->perms); int ret;
ret = sp_writer_setperms_shm (self->pipe, self->perms);
if (ret < 0)
GST_WARNING_OBJECT (object, "Could not set permissions on pipe: %s",
strerror (ret));
}
break; break;
case PROP_SHM_SIZE: case PROP_SHM_SIZE:
g_value_set_uint (value, self->size); g_value_set_uint (value, self->size);

View File

@ -371,11 +371,11 @@ sp_close (ShmPipe * self)
spalloc_free (ShmPipe, self); spalloc_free (ShmPipe, self);
} }
void int
sp_writer_setperms_shm (ShmPipe * self, mode_t perms) sp_writer_setperms_shm (ShmPipe * self, mode_t perms)
{ {
self->perms = perms; self->perms = perms;
fchmod (self->shm_area->shm_fd, perms); return fchmod (self->shm_area->shm_fd, perms);
} }
static int static int

View File

@ -50,7 +50,7 @@ ShmPipe *sp_writer_create (const char *path, size_t size, mode_t perms);
const char *sp_writer_get_path (ShmPipe *pipe); const char *sp_writer_get_path (ShmPipe *pipe);
void sp_close (ShmPipe * self); void sp_close (ShmPipe * self);
void sp_writer_setperms_shm (ShmPipe * self, mode_t perms); int sp_writer_setperms_shm (ShmPipe * self, mode_t perms);
int sp_writer_resize (ShmPipe * self, size_t size); int sp_writer_resize (ShmPipe * self, size_t size);
int sp_get_fd (ShmPipe * self); int sp_get_fd (ShmPipe * self);