mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
cudaipcsink: Fix deadlock on stop
Manually close connection if client does not hold any shared memory on stop. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5747>
This commit is contained in:
parent
ed5987efd4
commit
012222bcb3
4 changed files with 30 additions and 2 deletions
|
@ -630,14 +630,28 @@ gst_cuda_ipc_server_on_idle (GstCudaIpcServer * server)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (server, "Have %" G_GSIZE_FORMAT " alive connections",
|
GST_DEBUG_OBJECT (server, "Have %" G_GSIZE_FORMAT " alive connections",
|
||||||
priv->conn_map.size());
|
priv->conn_map.size());
|
||||||
|
|
||||||
|
size_t num_closed = 0;
|
||||||
for (auto it : priv->conn_map) {
|
for (auto it : priv->conn_map) {
|
||||||
auto conn = it.second;
|
auto conn = it.second;
|
||||||
GST_DEBUG_OBJECT (server, "conn-id %u"
|
GST_DEBUG_OBJECT (server, "conn-id %u"
|
||||||
" peer handle size %" G_GSIZE_FORMAT, conn->id,
|
" peer handle size %" G_GSIZE_FORMAT, conn->id,
|
||||||
conn->peer_handles.size ());
|
conn->peer_handles.size ());
|
||||||
|
|
||||||
|
/* Cannot erase conn since it's still referenced.
|
||||||
|
* Manually close connection */
|
||||||
|
if (conn->peer_handles.empty ()) {
|
||||||
|
conn->CloseConn ();
|
||||||
|
num_closed++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
if (priv->conn_map.size () == num_closed) {
|
||||||
|
GST_DEBUG_OBJECT (server, "All connections were closed");
|
||||||
|
klass->terminate (server);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,8 @@ struct GstCudaIpcServerConn : public OVERLAPPED
|
||||||
gst_clear_caps (&caps);
|
gst_clear_caps (&caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void CloseConn () = 0;
|
||||||
|
|
||||||
GstCudaIpcServer *server;
|
GstCudaIpcServer *server;
|
||||||
|
|
||||||
GstCudaContext *context = nullptr;
|
GstCudaContext *context = nullptr;
|
||||||
|
|
|
@ -47,8 +47,14 @@ struct GstCudaIpcServerConnUnix : public GstCudaIpcServerConn
|
||||||
g_clear_object (&socket_conn);
|
g_clear_object (&socket_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CloseConn ()
|
||||||
|
{
|
||||||
|
if (socket_conn)
|
||||||
|
g_io_stream_close (G_IO_STREAM (socket_conn), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Holds ref */
|
/* Holds ref */
|
||||||
GSocketConnection *socket_conn;
|
GSocketConnection *socket_conn = nullptr;
|
||||||
|
|
||||||
/* Owned by socket_conn */
|
/* Owned by socket_conn */
|
||||||
GInputStream *istream;
|
GInputStream *istream;
|
||||||
|
|
|
@ -41,15 +41,21 @@ struct GstCudaIpcServerConnWin32 : public GstCudaIpcServerConn
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~GstCudaIpcServerConnWin32 ()
|
virtual ~GstCudaIpcServerConnWin32 ()
|
||||||
|
{
|
||||||
|
CloseConn ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseConn ()
|
||||||
{
|
{
|
||||||
if (pipe != INVALID_HANDLE_VALUE) {
|
if (pipe != INVALID_HANDLE_VALUE) {
|
||||||
CancelIo (pipe);
|
CancelIo (pipe);
|
||||||
DisconnectNamedPipe (pipe);
|
DisconnectNamedPipe (pipe);
|
||||||
CloseHandle (pipe);
|
CloseHandle (pipe);
|
||||||
|
pipe = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE pipe;
|
HANDLE pipe = INVALID_HANDLE_VALUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GstCudaIpcServerWin32Private
|
struct GstCudaIpcServerWin32Private
|
||||||
|
|
Loading…
Reference in a new issue