[tarantool-patches] Re: [PATCH v2 2/3] console: do not use netbox for console text connections

Konstantin Osipov kostja at tarantool.org
Thu Mar 29 16:03:56 MSK 2018


* Vladislav Shpilevoy <v.shpilevoy at tarantool.org> [18/03/28 16:50]:

You mentioned you were going to get rid of the read() to detect
sigpipe, and investigate sigpipe problem more thoroughly.

Please do.

> +        write = function(self, text)
> +            -- It is the hack to protect from SIGPIPE, which is
> +            -- not ignored under debugger (gdb, lldb) on send in
> +            -- a socket, that is actually closed. If a socket is
> +            -- readable and read() returns nothing then the socket
> +            -- is closed, and writing into it will raise SIGPIPE.
> +            if self._socket:readable(0) then
> +                local rc = self._socket:read({chunk = 1})
> +                if not rc or rc == '' then
> +                    return nil
> +                else
> +                    assert(#rc == 1)
> +                    -- Make the char be unread.
> +                    self._socket.rbuf.wpos = self._socket.rbuf.wpos - 1
> +                end
> +            end
> +            return self._socket:write(text)

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov




More information about the Tarantool-patches mailing list