mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-05 05:52:37 +00:00
srt: Clean up poll/sock lifecycle
Make sure `srtobject->poll_id` is never invalid as long as `srtobject` exists. Only remove our caller socket from it when the socket becomes invalid. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3329>
This commit is contained in:
parent
debb19868f
commit
68cd5e1de1
1 changed files with 9 additions and 20 deletions
|
@ -363,11 +363,12 @@ gst_srt_object_destroy (GstSRTObject * srtobject)
|
||||||
{
|
{
|
||||||
g_return_if_fail (srtobject != NULL);
|
g_return_if_fail (srtobject != NULL);
|
||||||
|
|
||||||
if (srtobject->poll_id != SRT_ERROR) {
|
if (srtobject->sock != SRT_INVALID_SOCK) {
|
||||||
srt_epoll_release (srtobject->poll_id);
|
srt_close (srtobject->sock);
|
||||||
srtobject->poll_id = SRT_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srt_epoll_release (srtobject->poll_id);
|
||||||
|
|
||||||
g_cond_clear (&srtobject->sock_cond);
|
g_cond_clear (&srtobject->sock_cond);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (srtobject->element, "Destroying srtobject");
|
GST_DEBUG_OBJECT (srtobject->element, "Destroying srtobject");
|
||||||
|
@ -1170,7 +1171,7 @@ gst_srt_object_connect (GstSRTObject * srtobject, GCancellable * cancellable,
|
||||||
if (sock == SRT_INVALID_SOCK) {
|
if (sock == SRT_INVALID_SOCK) {
|
||||||
g_set_error (error, GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_INIT, "%s",
|
g_set_error (error, GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_INIT, "%s",
|
||||||
srt_getlasterror_str ());
|
srt_getlasterror_str ());
|
||||||
goto failed;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_srt_object_set_common_params (sock, srtobject, error)) {
|
if (!gst_srt_object_set_common_params (sock, srtobject, error)) {
|
||||||
|
@ -1254,6 +1255,7 @@ gst_srt_object_connect (GstSRTObject * srtobject, GCancellable * cancellable,
|
||||||
if (srt_connect (sock, sa, sa_len) == SRT_ERROR) {
|
if (srt_connect (sock, sa, sa_len) == SRT_ERROR) {
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, "%s",
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, "%s",
|
||||||
srt_getlasterror_str ());
|
srt_getlasterror_str ());
|
||||||
|
srt_epoll_remove_usock (srtobject->poll_id, sock);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,18 +1264,7 @@ gst_srt_object_connect (GstSRTObject * srtobject, GCancellable * cancellable,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
|
srt_close (sock);
|
||||||
if (srtobject->poll_id != SRT_ERROR) {
|
|
||||||
srt_epoll_release (srtobject->poll_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sock != SRT_INVALID_SOCK) {
|
|
||||||
srt_close (sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
srtobject->poll_id = SRT_ERROR;
|
|
||||||
srtobject->sock = SRT_INVALID_SOCK;
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1381,9 +1372,7 @@ gst_srt_object_close (GstSRTObject * srtobject)
|
||||||
g_mutex_lock (&srtobject->sock_lock);
|
g_mutex_lock (&srtobject->sock_lock);
|
||||||
|
|
||||||
if (srtobject->sock != SRT_INVALID_SOCK) {
|
if (srtobject->sock != SRT_INVALID_SOCK) {
|
||||||
if (srtobject->poll_id != SRT_ERROR) {
|
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
|
||||||
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (srtobject->element, "Closing SRT socket (0x%x)",
|
GST_DEBUG_OBJECT (srtobject->element, "Closing SRT socket (0x%x)",
|
||||||
srtobject->sock);
|
srtobject->sock);
|
||||||
|
@ -1584,7 +1573,7 @@ gst_srt_object_wakeup (GstSRTObject * srtobject, GCancellable * cancellable)
|
||||||
|
|
||||||
/* Removing all socket descriptors from the monitoring list
|
/* Removing all socket descriptors from the monitoring list
|
||||||
* wakes up SRT's threads. We only have one to remove. */
|
* wakes up SRT's threads. We only have one to remove. */
|
||||||
if (srtobject->sock != SRT_INVALID_SOCK && srtobject->poll_id != SRT_ERROR) {
|
if (srtobject->sock != SRT_INVALID_SOCK) {
|
||||||
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
|
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue