[tarantool-patches] Re: [PATCH v2 03/11] sio: remove exceptions

Vladimir Davydov vdavydov.dev at gmail.com
Tue Dec 11 11:44:28 MSK 2018


On Mon, Dec 10, 2018 at 06:37:37PM +0300, Vladislav Shpilevoy wrote:
> On 09/12/2018 15:54, Vladimir Davydov wrote:
> > On Wed, Dec 05, 2018 at 12:28:50AM +0300, Vladislav Shpilevoy wrote:
> > > @@ -40,6 +40,14 @@
> > >   #include "trivia/util.h"
> > >   #include "exception.h"
> > > +enum { SIO_ERROR_FATAL = -2 };
> > > +
> > > +bool
> > > +sio_is_error_fatal(int retcode)
> > > +{
> > > +	return retcode == SIO_ERROR_FATAL;
> > > +}
> > > +
> > >   /** Pretty print socket name and peer (for exceptions) */
> > >   const char *
> > >   sio_socketname(int fd)
> > > @@ -224,9 +234,11 @@ sio_accept(int fd, struct sockaddr *addr, socklen_t *addrlen)
> > >   {
> > >   	/* Accept a connection. */
> > >   	int newfd = accept(fd, addr, addrlen);
> > > -	if (newfd < 0 &&
> > > -	    (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR))
> > > -		tnt_raise(SocketError, sio_socketname(fd), "accept");
> > > +	if (newfd < 0 && errno != EAGAIN && errno != EWOULDBLOCK &&
> > > +	    errno != EINTR) {
> > > +		diag_set(SocketError, sio_socketname(fd), "accept");
> > > +		return SIO_ERROR_FATAL;
> > > +	}
> > >   	return newfd;
> > >   }
> > 
> > This looks bad. It's not just my opinion. I consulted with Kostja
> > verbally and he agrees with me.
> > 
> > Let's please set diag on any error in all sio functions and let the
> > caller decide which ones are critical and which are not by checking
> 
> There is a problem - each diag increments error counter visible in
> stat. But I believe you know it, so as you wish.

Well, only ClientErrors are accounted in box.stat(), SocketErrors are
not. However, you're right - setting diag on each EWOULDBLOCK error does
seem to be expensive, because diag_set() implies malloc(). This would be
a pointless overhead.

So we've agreed that we shouldn't set diag on transient errors,
only errno. Kostja reworked and pushed this patch by himself.
For some reason, he also authored it, split it in 5, and did some
minor unnecessary changes (like moving comments).



More information about the Tarantool-patches mailing list