mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
gstpluginloader: Don't hang on short reads/writes
If read_one or write_one was called but the stream closed before it could read/write a whole packet, read_one/write_one would hang indefinitely, consuming 100% CPU. This commit fixes that by treating a short read/write as an error. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2994>
This commit is contained in:
parent
1ba67eab9e
commit
674bb309d8
1 changed files with 9 additions and 0 deletions
|
@ -810,6 +810,9 @@ write_one (GstPluginLoader * l)
|
|||
continue;
|
||||
/* Failed to write -> child died */
|
||||
goto fail_and_cleanup;
|
||||
} else if (G_UNLIKELY (res == 0)) {
|
||||
/* FD closed -> child died */
|
||||
goto fail_and_cleanup;
|
||||
}
|
||||
to_write -= res;
|
||||
out += res;
|
||||
|
@ -1074,6 +1077,9 @@ read_one (GstPluginLoader * l)
|
|||
continue;
|
||||
GST_LOG ("Failed reading packet header");
|
||||
return FALSE;
|
||||
} else if (G_UNLIKELY (res == 0)) {
|
||||
GST_LOG ("Failed reading packet header: Unexpected EOF");
|
||||
return FALSE;
|
||||
}
|
||||
to_read -= res;
|
||||
in += res;
|
||||
|
@ -1111,6 +1117,9 @@ read_one (GstPluginLoader * l)
|
|||
continue;
|
||||
GST_ERROR ("Packet payload read failed");
|
||||
return FALSE;
|
||||
} else if (G_UNLIKELY (res == 0)) {
|
||||
GST_ERROR ("Packet payload read failed: Unexpected EOF");
|
||||
return FALSE;
|
||||
}
|
||||
to_read -= res;
|
||||
in += res;
|
||||
|
|
Loading…
Reference in a new issue