ip = g_inet_address_to_string (g_inet_socket_address_get_address
(G_INET_SOCKET_ADDRESS (addr)));
port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
+ g_object_unref (addr);
ret =
gst_rtsp_connection_create_from_socket (client_sock, ip, port, NULL,
conn);
+ g_object_unref (client_sock);
g_free (ip);
return ret;
if (!g_socket_connect (socket, saddr, cancellable, &err)) {
if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_PENDING))
goto sys_error;
+ g_clear_error (&err);
} else {
goto done;
}
}
g_socket_set_timeout (socket, 0);
- if (g_socket_check_connect_result (socket, &err))
+ if (!g_socket_check_connect_result (socket, &err))
goto sys_error;
done:
g_object_unref (saddr);
+ *socket_out = socket;
+
return GST_RTSP_OK;
/* ERRORS */
{
g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
+ /* last unref closes the connection we don't want to explicitly close here
+ * because these sockets might have been provided at construction */
+ if (conn->socket0) {
+ g_object_unref (conn->socket0);
+ conn->socket0 = NULL;
+ }
+ if (conn->socket1) {
+ g_object_unref (conn->socket1);
+ conn->socket1 = NULL;
+ }
+
g_free (conn->ip);
conn->ip = NULL;
g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
res = gst_rtsp_connection_close (conn);
- if (conn->socket0)
- g_object_unref (conn->socket0);
- if (conn->socket1)
- g_object_unref (conn->socket1);
if (conn->cancellable)
g_object_unref (conn->cancellable);
g_mutex_lock (watch->mutex);
/* try to send the message synchronously first */
- if (watch->messages->length == 0) {
+ if (watch->messages->length == 0 && watch->write_data == NULL) {
res =
write_bytes (watch->conn->write_socket, data, &off, size,
watch->conn->cancellable);