moonbridge
changeset 129:df08e63dc44b
Bugfix in close method of moonbridge_io (do not mark as closed before flushing)
author | jbe |
---|---|
date | Tue Apr 14 22:25:32 2015 +0200 (2015-04-14) |
parents | ebaac38b7224 |
children | ee98e12427a9 |
files | moonbridge_io.c |
line diff
1.1 --- a/moonbridge_io.c Tue Apr 14 19:32:46 2015 +0200 1.2 +++ b/moonbridge_io.c Tue Apr 14 22:25:32 2015 +0200 1.3 @@ -433,23 +433,28 @@ 1.4 moonbr_io_handle_t *handle; 1.5 handle = luaL_checkudata(L, 1, MOONBR_IO_HANDLE_MT_REGKEY); 1.6 if (handle->closed) luaL_error(L, "Attempt to close a closed I/O handle"); 1.7 - handle->closed = 1; 1.8 if (!reset) { 1.9 if (handle->writeleft) { 1.10 lua_pushcfunction(L, moonbr_io_flush); 1.11 lua_pushvalue(L, 1); 1.12 if (lua_pcall(L, 1, 2, 0)) { 1.13 + handle->closed = 1; 1.14 close(handle->fd); 1.15 handle->fd = -1; 1.16 lua_error(L); 1.17 } 1.18 + handle->closed = 1; 1.19 if (!lua_toboolean(L, -2)) { 1.20 close(handle->fd); 1.21 handle->fd = -1; 1.22 return 2; 1.23 } 1.24 + } else { 1.25 + handle->closed = 1; 1.26 + moonbr_io_handle_set_linger(L, handle, -1); 1.27 } 1.28 - moonbr_io_handle_set_linger(L, handle, -1); 1.29 + } else { 1.30 + handle->closed = 1; 1.31 } 1.32 if (handle->fd >= 0) { 1.33 if (close(handle->fd)) {