moonbridge
changeset 218:35ea31e45b43
Send a TCP RST instead of TCP FIN when a socket gets garbage collected (and hasn't been closed)
author | jbe |
---|---|
date | Tue Jun 23 02:07:26 2015 +0200 (2015-06-23) |
parents | 0b6555732047 |
children | e53da349fd8f |
files | moonbridge_io.c reference.txt |
line diff
1.1 --- a/moonbridge_io.c Tue Jun 23 02:05:46 2015 +0200 1.2 +++ b/moonbridge_io.c Tue Jun 23 02:07:26 2015 +0200 1.3 @@ -726,7 +726,7 @@ 1.4 moonbr_io_handle_t *handle; 1.5 handle = luaL_checkudata(L, 1, MOONBR_IO_HANDLE_MT_REGKEY); 1.6 if (handle->fd >= 0) { 1.7 - lua_pushcfunction(L, moonbr_io_close); 1.8 + lua_pushcfunction(L, moonbr_io_reset); 1.9 lua_pushvalue(L, 1); 1.10 lua_pushinteger(L, 0); 1.11 lua_call(L, 2, 0);
2.1 --- a/reference.txt Tue Jun 23 02:05:46 2015 +0200 2.2 +++ b/reference.txt Tue Jun 23 02:07:26 2015 +0200 2.3 @@ -66,6 +66,11 @@ 2.4 (or drained) before calling socket:close(). Use socket:finish() to send a 2.5 TCP FIN packet to the peer before waiting for EOF from the peer. 2.6 2.7 +A socket passed to the "connect" handler will be closed automatically if it was 2.8 +not closed by the "connect" handler and if the "connect" handler returns 2.9 +normally (i.e. without throwing an error). If the "connect" handler throws an 2.10 +error, then the socket will be reset. See socket:reset(). 2.11 + 2.12 2.13 ### socket:drain(maxlen, terminator) 2.14 2.15 @@ -232,8 +237,10 @@ 2.16 2.17 ### socket:reset() 2.18 2.19 -Alias for socket:close(0). Closes the socket connection by sending a TCP RST 2.20 -packet if possible to indicate error condition. 2.21 +Alias for socket:close(). Closes the socket connection by sending a TCP RST 2.22 +packet if possible to indicate error condition. This is the default operation 2.23 +when a socket handle gets garbage collected or the process is terminated 2.24 +abnormally. 2.25 2.26 Returns true on success, or nil (as first return value) plus error message (as 2.27 second return value) in case of an I/O error. Using this method on sockets that