mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
tcpserversink: Don't assume g_socket_get_remote_address succeeds
When the client disconnects immediately after connecting, the remote address is no longer available. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/908>
This commit is contained in:
parent
69b5cb8a10
commit
c4cdb6590e
1 changed files with 12 additions and 6 deletions
|
@ -172,14 +172,20 @@ gst_tcp_server_sink_handle_server_read (GstTCPServerSink * sink)
|
||||||
GInetSocketAddress *addr =
|
GInetSocketAddress *addr =
|
||||||
G_INET_SOCKET_ADDRESS (g_socket_get_remote_address (client_socket,
|
G_INET_SOCKET_ADDRESS (g_socket_get_remote_address (client_socket,
|
||||||
NULL));
|
NULL));
|
||||||
gchar *ip =
|
if (addr) {
|
||||||
g_inet_address_to_string (g_inet_socket_address_get_address (addr));
|
gchar *ip =
|
||||||
|
g_inet_address_to_string (g_inet_socket_address_get_address (addr));
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "added new client ip %s:%u with socket %p",
|
GST_DEBUG_OBJECT (sink, "added new client ip %s:%u with socket %p",
|
||||||
ip, g_inet_socket_address_get_port (addr), client_socket);
|
ip, g_inet_socket_address_get_port (addr), client_socket);
|
||||||
|
|
||||||
g_free (ip);
|
g_free (ip);
|
||||||
g_object_unref (addr);
|
g_object_unref (addr);
|
||||||
|
} else {
|
||||||
|
/* This can happen when the client immediately closes the connection */
|
||||||
|
GST_DEBUG_OBJECT (sink, "added new client (no address) with socket %p",
|
||||||
|
client_socket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue