diff options
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -155,7 +155,17 @@ int stream_readk(lua_State * L, int status, lua_KContext ctx) int remaining_bytes; do { - remaining_bytes = buffer_prepare_at_least(L, s->fd, &s->in, (int) pattern_length, ctx); + remaining_bytes = buffer_prepare_at_least(s->fd, &s->in, (int) pattern_length); + if (-1 == remaining_bytes) + { + if (EWOULDBLOCK == errno || EAGAIN == errno) + return lua_yieldk(L, 0, ctx, stream_readk); + else + { + lua_pushstring(L, strerror(errno)); + return lua_error(L); + } + } offset = buffer_until(&s->in, pattern, (int) pattern_length); } while (-1 == offset && 0 < remaining_bytes); |