mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 10:42:22 +00:00
rtsp: make read uncancelable when reading a message
When we start to read a message, we need to continue reading until the end of the message or else we lose track and cause parse errors. Use a variable may_cancel to avoid cancelation after we read the first byte until we have the complete message. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=703088
This commit is contained in:
parent
97e68b36c7
commit
32a1deb404
1 changed files with 8 additions and 2 deletions
|
@ -121,6 +121,7 @@ struct _GstRTSPConnection
|
||||||
GSocket *write_socket;
|
GSocket *write_socket;
|
||||||
GSocket *socket0, *socket1;
|
GSocket *socket0, *socket1;
|
||||||
gboolean manual_http;
|
gboolean manual_http;
|
||||||
|
gboolean may_cancel;
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
|
|
||||||
gchar tunnelid[TUNNELID_LEN];
|
gchar tunnelid[TUNNELID_LEN];
|
||||||
|
@ -217,6 +218,7 @@ gst_rtsp_connection_create (const GstRTSPUrl * url, GstRTSPConnection ** conn)
|
||||||
|
|
||||||
newconn = g_new0 (GstRTSPConnection, 1);
|
newconn = g_new0 (GstRTSPConnection, 1);
|
||||||
|
|
||||||
|
newconn->may_cancel = TRUE;
|
||||||
newconn->cancellable = g_cancellable_new ();
|
newconn->cancellable = g_cancellable_new ();
|
||||||
newconn->client = g_socket_client_new ();
|
newconn->client = g_socket_client_new ();
|
||||||
|
|
||||||
|
@ -925,11 +927,11 @@ fill_raw_bytes (GstRTSPConnection * conn, guint8 * buffer, guint size,
|
||||||
gsize count = size - out;
|
gsize count = size - out;
|
||||||
if (block)
|
if (block)
|
||||||
r = g_input_stream_read (conn->input_stream, (gchar *) & buffer[out],
|
r = g_input_stream_read (conn->input_stream, (gchar *) & buffer[out],
|
||||||
count, conn->cancellable, err);
|
count, conn->may_cancel ? conn->cancellable : NULL, err);
|
||||||
else
|
else
|
||||||
r = g_pollable_input_stream_read_nonblocking (G_POLLABLE_INPUT_STREAM
|
r = g_pollable_input_stream_read_nonblocking (G_POLLABLE_INPUT_STREAM
|
||||||
(conn->input_stream), (gchar *) & buffer[out], count,
|
(conn->input_stream), (gchar *) & buffer[out], count,
|
||||||
conn->cancellable, err);
|
conn->may_cancel ? conn->cancellable : NULL, err);
|
||||||
|
|
||||||
if (G_UNLIKELY (r < 0)) {
|
if (G_UNLIKELY (r < 0)) {
|
||||||
if (out == 0) {
|
if (out == 0) {
|
||||||
|
@ -1663,12 +1665,14 @@ build_next (GstRTSPBuilder * builder, GstRTSPMessage * message,
|
||||||
if (c == '$') {
|
if (c == '$') {
|
||||||
/* data message, prepare for the header */
|
/* data message, prepare for the header */
|
||||||
builder->state = STATE_DATA_HEADER;
|
builder->state = STATE_DATA_HEADER;
|
||||||
|
conn->may_cancel = FALSE;
|
||||||
} else if (c == '\n' || c == '\r') {
|
} else if (c == '\n' || c == '\r') {
|
||||||
/* skip \n and \r */
|
/* skip \n and \r */
|
||||||
builder->offset = 0;
|
builder->offset = 0;
|
||||||
} else {
|
} else {
|
||||||
builder->line = 0;
|
builder->line = 0;
|
||||||
builder->state = STATE_READ_LINES;
|
builder->state = STATE_READ_LINES;
|
||||||
|
conn->may_cancel = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1770,6 +1774,8 @@ build_next (GstRTSPBuilder * builder, GstRTSPMessage * message,
|
||||||
gchar *session_cookie;
|
gchar *session_cookie;
|
||||||
gchar *session_id;
|
gchar *session_id;
|
||||||
|
|
||||||
|
conn->may_cancel = TRUE;
|
||||||
|
|
||||||
if (message->type == GST_RTSP_MESSAGE_DATA) {
|
if (message->type == GST_RTSP_MESSAGE_DATA) {
|
||||||
/* data messages don't have headers */
|
/* data messages don't have headers */
|
||||||
res = GST_RTSP_OK;
|
res = GST_RTSP_OK;
|
||||||
|
|
Loading…
Reference in a new issue