On 24/06/18 19:32, Bruno Haible wrote: > This fixes the error message reported by Assaf Gordon on non-seekable > input. > > Four approaches come to mind for fixing this: > 1) Change the afalg_stream signature, adding an argument where the function > can store read but not yet processed input. > 2) Change the afalg_stream signature, passing it the fallback computation > function as argument. So that afalg_stream can invoke this function on > read input that it could not process itself. > 3) Try the first send() with 1 byte only, because upon failure it can be > pushed back onto the stream. > 4) Try the first send() with the number of bytes returned by freadptr, > instead of fread(). > > The first two approaches would be a major code change, for just a little > particular case. I prefer the third approach.
For reference a quick search suggests this bug may have been: https://patchwork.kernel.org/patch/8124631/ and was noticed by Assaf on a 3.10 kernel. 3) Seems like the best approach. I'd have a slight reservation on perf impact of I/O aligned 1 byte over natural boundaries. Then implementation looks sound. thanks, Pádraig