Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bugfix: check for closing handle
  • Loading branch information
Ryan Phillips committed Sep 5, 2012
1 parent 950c457 commit d162751
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/luv_handle.c
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/luv_stream.c
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/luv_udp.c
Expand Up @@ -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;
Expand Down

0 comments on commit d162751

Please sign in to comment.