From 03c721657e34802a4016dcfdfa1e7bbb91b71f79 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Mon, 10 Dec 2018 23:11:23 +0300 Subject: [PATCH] sio: remove exceptions Propagate exceptions up to the caller. Functions sio_read(), sio_write(). Add an assert for sio_write() with zero bytes. In scope of #3234 --- src/box/iproto.cc | 2 ++ src/coio.cc | 4 ++++ src/sio.cc | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/box/iproto.cc b/src/box/iproto.cc index 7c11d05b37..89b8547b4a 100644 --- a/src/box/iproto.cc +++ b/src/box/iproto.cc @@ -859,6 +859,8 @@ iproto_connection_on_input(ev_loop *loop, struct ev_io *watcher, /* Read input. */ int nrd = sio_read(fd, in->wpos, ibuf_unused(in)); if (nrd < 0) { /* Socket is not ready. */ + if (! sio_wouldblock(errno)) + diag_raise(); ev_io_start(loop, &con->input); return; } diff --git a/src/coio.cc b/src/coio.cc index 245376285e..51596e9eaf 100644 --- a/src/coio.cc +++ b/src/coio.cc @@ -316,6 +316,8 @@ coio_read_ahead_timeout(struct ev_io *coio, void *buf, size_t sz, } else if (nrd == 0) { errno = 0; return sz - to_read; + } else if (! sio_wouldblock(errno)) { + diag_raise(); } /* The socket is not ready, yield */ @@ -407,6 +409,8 @@ coio_write_timeout(struct ev_io *coio, const void *buf, size_t sz, return sz; towrite -= nwr; buf = (char *) buf + nwr; + } else if (nwr < 0 && !sio_wouldblock(errno)) { + diag_raise(); } if (! ev_is_active(coio)) { ev_io_set(coio, coio->fd, EV_WRITE); diff --git a/src/sio.cc b/src/sio.cc index e1ad1c1298..e8d2416d50 100644 --- a/src/sio.cc +++ b/src/sio.cc @@ -232,7 +232,7 @@ sio_read(int fd, void *buf, size_t count) errno = 0; n = 0; } else { - tnt_raise(SocketError, sio_socketname(fd), + diag_set(SocketError, sio_socketname(fd), "read(%zd)", count); } } @@ -244,7 +244,7 @@ sio_write(int fd, const void *buf, size_t count) { ssize_t n = write(fd, buf, count); if (n < 0 && !sio_wouldblock(errno)) - tnt_raise(SocketError, sio_socketname(fd), "write(%zd)", count); + diag_set(SocketError, sio_socketname(fd), "write(%zd)", count); return n; } -- GitLab