turbo
                                
                                
                                
                                    turbo copied to clipboard
                            
                            
                            
                        Server stuck after error "Errno: 104. Connection reset by peer"
For the second time I noticed that after the error "iostream.lua: 654: Error when reading from socket 77. Errno: 104. Connection reset by peer" the server freezes and stops responding.
From source code:
--- Reads from the socket. Return the data chunk or nil if theres nothing to
-- read, in the case of EWOULDBLOCK or equivalent.
-- @return Chunk of data.
...
        if sz == -1 then
            errno = ffi.errno()
            if errno == EWOULDBLOCK or errno == EAGAIN then
                return
            else
                local fd = self.socket
                self:close()
                error(string.format(
                      "Error when reading from socket %d. Errno: %d. %s",
                      fd,
                      errno,
                      socket.strerror(errno)))
            end
        end
...
In else-block "return" is missing. Could this be the reason for stopping the server?
Thank you for reporting this finding. This surely would be a issue that could lead to undefined behaviour.
A fix has been pushed to master now.
Have you tested this with master?
I have a feeling this is the reason my server was hanging every few weeks to a month. I ended up writing a canary that would restart it if it hang, so I never dug into it still, but I've been meaning to. After this fix if I still see the server hanging for me every once and a while I'll dig into it and see if I can post an issue.
Jeff S
On Wed, Mar 29, 2017 at 6:55 AM, Titannet [email protected] wrote:
For the second time I noticed that after the error "iostream.lua: 654: Error when reading from socket 77. Errno: 104. Connection reset by peer" the server freezes and stops responding.
From source code:
--- Reads from the socket. Return the data chunk or nil if theres nothing to -- read, in the case of EWOULDBLOCK or equivalent. -- @return Chunk of data. ... if sz == -1 then errno = ffi.errno() if errno == EWOULDBLOCK or errno == EAGAIN then return else local fd = self.socket self:close() error(string.format( "Error when reading from socket %d. Errno: %d. %s", fd, errno, socket.strerror(errno))) end end ...
In else-block "return" is missing. Could this be the reason for stopping the server?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kernelsauce/turbo/issues/305, or mute the thread https://github.com/notifications/unsubscribe-auth/AD6kxpvRRv2St2oQj9MSybbESXuYOzV8ks5rqmLTgaJpZM4MtBBo .
Have you tested this with master?
Hello! I haven't test the master branch yet, but my fix was the same, and server works fine after fix. Thank You!
Great. Thanks to you all.
I will leave the issue open some time to see what happens by the way.
Ooops, server was stuck today two times. Stacktrace the same (bugfix is present):
[E 2017/04/04 16:23:44] [ioloop.lua] Error in IOLoop handler. ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ /usr/local/share/lua/5.1/turbo/iostream.lua:654: Error when reading from socket 38. Errno: 104. Connection reset by peer stack traceback: [C]: in function 'error' /usr/local/share/lua/5.1/turbo/iostream.lua:654: in function '_read_from_socket' /usr/local/share/lua/5.1/turbo/iostream.lua:729: in function '_read_to_buffer' /usr/local/share/lua/5.1/turbo/iostream.lua:467: in function '_initial_read' /usr/local/share/lua/5.1/turbo/iostream.lua:200: in function 'read_until' /usr/local/share/lua/5.1/turbo/httpserver.lua:130: in function 'initialize' ...share/lua/5.1/turbo/3rdparty/middleclass/middleclass.lua:90: in function 'HTTPConnection' /usr/local/share/lua/5.1/turbo/httpserver.lua:101: in function 'handle_stream' /usr/local/share/lua/5.1/turbo/tcpserver.lua:213: in function </usr/local/share/lua/5.1/turbo/tcpserver.lua:200> /usr/local/share/lua/5.1/turbo/sockutil.lua:244: in function </usr/local/share/lua/5.1/turbo/sockutil.lua:204> [C]: in function 'xpcall' /usr/local/share/lua/5.1/turbo/ioloop.lua:546: in function '_run_handler' /usr/local/share/lua/5.1/turbo/ioloop.lua:454: in function '_event_poll' /usr/local/share/lua/5.1/turbo/ioloop.lua:443: in function 'start' run_server.lua:197: in main chunk [C]: in function 'dofile' ...bdev/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: at 0x00406670 ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
Do you have any ideas, why it's happends?
I think that issue might be resolved now by #329