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/2964>
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;
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;
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;