Skip to content
Permalink
Browse files

Merge pull request #340 from luvit/fix/double_closes

bugfix: check for closing handle
  • Loading branch information...
rphillips committed Sep 5, 2012
2 parents 950c457 + d162751 commit f9ed04bbe10ae85d6c32ab5dc36ebd2d23f7465b
Showing with 4 additions and 2 deletions.
  1. +4 −0 src/luv_handle.c
  2. +0 −1 src/luv_stream.c
  3. +0 −1 src/luv_udp.c
@@ -84,6 +84,10 @@ void luv_on_close(uv_handle_t* handle) {
int luv_close (lua_State* L) {
uv_handle_t* handle = luv_checkudata(L, 1, "handle");
/* printf("close \tlhandle=%p handle=%p\n", handle->data, handle);*/
if (uv_is_closing(handle)) {
fprintf(stderr, "WARNING: Handle already closing \tlhandle=%p handle=%p\n", handle->data, handle);
return;
}
uv_close(handle, luv_on_close);
luv_handle_ref(L, handle->data, 1);
return 0;
@@ -46,7 +46,6 @@ void luv_on_read(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) {
if (err.code == UV_EOF) {
luv_emit_event(L, "end", 0);
} else {
uv_close((uv_handle_t*)handle, luv_on_close);
luv_push_async_error(L, uv_last_error(luv_get_loop(L)), "on_read", NULL);
luv_emit_event(L, "error", 1);
}
@@ -61,7 +61,6 @@ static void luv_on_udp_recv(uv_udp_t* handle,
}

if (nread < 0) {
uv_close((uv_handle_t *)handle, luv_on_close);
luv_push_async_error(L, uv_last_error(luv_get_loop(L)), "on_recv", NULL);
luv_emit_event(L, "error", 1);
return;

0 comments on commit f9ed04b

Please sign in to comment.
You can’t perform that action at this time.