Skip to content

Commit

Permalink
io: interrupt streams on close
Browse files Browse the repository at this point in the history
  • Loading branch information
esmil committed Jan 7, 2016
1 parent 0e339a5 commit c5dffb8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lem/io/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,16 @@ stream_close(lua_State *T)
s = lua_touserdata(T, 1);
if (!s->open)
return io_closed(T);
if (s->r.data != NULL || s->w.data != NULL)
return io_busy(T);
if (s->r.data != NULL) {
ev_io_stop(LEM_ &s->r);
lem_queue(s->r.data, io_closed(s->r.data));
s->r.data = NULL;
}
if (s->w.data != NULL) {
ev_io_stop(LEM_ &s->w);
lem_queue(s->w.data, io_closed(s->w.data));
s->w.data = NULL;
}

s->open = 0;
if (close(s->r.fd))
Expand Down

0 comments on commit c5dffb8

Please sign in to comment.