Permalink
Browse files

unix: check UV_CLOSING flag in uv__write()

uv__write() runs after the read callbacks have fired. Said callbacks may have
closed the handle, handle that graciously.
  • Loading branch information...
1 parent 34e95d1 commit 0db3274f8af73b9d8a7757f7fdc699e7f7f92349 @bnoordhuis bnoordhuis committed Dec 5, 2011
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/unix/stream.c
View
@@ -341,6 +341,13 @@ static void uv__write(uv_stream_t* stream) {
int iovcnt;
ssize_t n;
+ if (stream->flags & UV_CLOSING) {
+ /* Handle was closed this tick. We've received a stale
+ * 'is writable' callback from the event loop, ignore.
+ */
+ return;
+ }
+
start:
assert(stream->fd >= 0);

0 comments on commit 0db3274

Please sign in to comment.