mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
unixfd: Close file descriptors on error
After calling g_unix_fd_list_steal_fds() and before calling gst_fd_allocator_alloc(), we are responsible for closing those fds. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6532>
This commit is contained in:
parent
1f8accbc8d
commit
f0ef33d018
1 changed files with 12 additions and 2 deletions
|
@ -298,6 +298,14 @@ from_monotonic (GstClockTime timestamp, GstClockTime base_time,
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
close_and_free_fds (gint * fds, gint fds_len)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < fds_len; i++)
|
||||||
|
g_close (fds[i], NULL);
|
||||||
|
g_free (fds);
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_unix_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
gst_unix_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
||||||
{
|
{
|
||||||
|
@ -346,14 +354,14 @@ again:
|
||||||
"Received new buffer command with %d file descriptors instead of "
|
"Received new buffer command with %d file descriptors instead of "
|
||||||
"%d", fds_arr_len, new_buffer->n_memory);
|
"%d", fds_arr_len, new_buffer->n_memory);
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
g_free (fds_arr);
|
close_and_free_fds (fds_arr, fds_arr_len);
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_buffer->type >= MEMORY_TYPE_LAST) {
|
if (new_buffer->type >= MEMORY_TYPE_LAST) {
|
||||||
GST_ERROR_OBJECT (self, "Unknown buffer type %d", new_buffer->type);
|
GST_ERROR_OBJECT (self, "Unknown buffer type %d", new_buffer->type);
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
g_free (fds_arr);
|
close_and_free_fds (fds_arr, fds_arr_len);
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
GstAllocator *allocator = self->allocators[new_buffer->type];
|
GstAllocator *allocator = self->allocators[new_buffer->type];
|
||||||
|
@ -384,6 +392,8 @@ again:
|
||||||
if (consumed == 0) {
|
if (consumed == 0) {
|
||||||
GST_ERROR_OBJECT (self, "Malformed meta serialization");
|
GST_ERROR_OBJECT (self, "Malformed meta serialization");
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
|
close_and_free_fds (fds_arr, fds_arr_len);
|
||||||
|
gst_clear_buffer (outbuf);
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
payload_off += consumed;
|
payload_off += consumed;
|
||||||
|
|
Loading…
Reference in a new issue