The read method of nixio's file and socket objects both return an empty string
when they reach EOF, not nil, causing the consumer to loop endlessly as
source.file() never terminates.
As there is no other situation in which an empty chunk is read, just change it
to nil to terminate the consumer's loop.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
if handle then
return function()
local chunk = handle:read(BLOCKSIZE)
+ if chunk and chunk:len() == 0 then chunk = nil end
if not chunk then handle:close() end
return chunk
end