rtmp2/connection: Handle EOF like error

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1403>
This commit is contained in:
Jan Alexander Steffens (heftig) 2021-12-01 15:53:13 +01:00 committed by GStreamer Marge Bot
parent 031d52672b
commit 297cdaa381

View file

@ -474,6 +474,12 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data)
sc->input_bytes->data + oldsize, READ_SIZE, sc->cancellable, &error);
g_byte_array_set_size (sc->input_bytes, oldsize + (ret > 0 ? ret : 0));
if (ret == 0) {
error = g_error_new (G_IO_ERROR, G_IO_ERROR_CONNECTION_CLOSED,
"connection closed remotely");
ret = -1;
}
if (ret < 0) {
gint code = error->code;
@ -488,13 +494,9 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data)
GST_ERROR_OBJECT (sc, "read error: %s %d %s",
g_quark_to_string (error->domain), code, error->message);
g_error_free (error);
} else if (ret == 0) {
GST_INFO_OBJECT (sc, "read EOF");
}
if (ret <= 0) {
gst_rtmp_connection_emit_error (sc);
g_error_free (error);
return G_SOURCE_REMOVE;
}
@ -577,16 +579,11 @@ out:
static void
gst_rtmp_connection_emit_error (GstRtmpConnection * self)
{
if (self->error) {
return;
if (!self->error) {
self->error = TRUE;
cancel_all_commands (self);
g_signal_emit (self, signals[SIGNAL_ERROR], 0);
}
GST_INFO_OBJECT (self, "connection error");
self->error = TRUE;
cancel_all_commands (self);
g_signal_emit (self, signals[SIGNAL_ERROR], 0);
}
static void