diff --git a/include/object.h b/include/object.h index cf97d59c5c8828a5d851d4d2e8361964476c5884..218c934b5c8e0f17b16ca3ee51ea323bc8495a09 100644 --- a/include/object.h +++ b/include/object.h @@ -35,19 +35,12 @@ class Object { /* Nothing */ } -protected: - /* - * Explicitly disable the copy constructor and the assignment operato - */ - Object(const Object&) - { + virtual ~Object() { /* Nothing */ } - Object& operator=(const Object&) - { - return *this; - } + Object(const Object&) = delete; + Object& operator=(const Object&) = delete; }; #endif /* TARANTOOL_OBJECT_H_INCLUDED */ diff --git a/include/scoped_guard.h b/include/scoped_guard.h index a141737acc915f2d5592d9d5f8984aee49cb9af6..4fdf4bfe6105003d67af54a17d6d4fd0d172a62f 100644 --- a/include/scoped_guard.h +++ b/include/scoped_guard.h @@ -33,7 +33,7 @@ #include "object.h" template <typename Functor> -class ScopedGuard: public Object { +class ScopedGuard { public: explicit ScopedGuard(const Functor& fun) : m_fun(fun), m_active(true) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index add443c2addf7cc748f6fc63f5dc25bc5ee1df9b..08c063c854aaddb7fe1508a8ff2df9ec70d08cc3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,7 +74,6 @@ set (common_sources tbuf.c palloc.cc util.c - scoped_guard.cc sio.cc evio.cc coio.cc diff --git a/src/box/bitset_index.cc b/src/box/bitset_index.cc index 82e9ecedcef29932aaf88f1a271d8e95afb046d6..3713520f5a951721a895d61efa707b9debf12145 100644 --- a/src/box/bitset_index.cc +++ b/src/box/bitset_index.cc @@ -297,7 +297,7 @@ BitsetIndex::initIterator(struct iterator *iterator, enum iterator_type type, } bitset_expr_destroy(&expr); - } catch(const Exception& e) { + } catch (const Exception& e) { bitset_expr_destroy(&expr); throw; } diff --git a/src/box/box_lua.cc b/src/box/box_lua.cc index b811f9585afe8545673ed7a6218387edf786cb60..484cca4da3022e4eb55fd779bafa68f6cebed4d2 100644 --- a/src/box/box_lua.cc +++ b/src/box/box_lua.cc @@ -1186,7 +1186,7 @@ port_add_lua_ret(struct port *port, struct lua_State *L, int index) if (tuple->refs == 0) tuple_free(tuple); - } catch(...) { + } catch (...) { if (tuple->refs == 0) tuple_free(tuple); @@ -1284,7 +1284,7 @@ lbox_process(lua_State *L) * use fiber->cleanup and fiber->gc_pool. */ ptruncate(fiber->gc_pool, allocated_size); - } catch(const Exception& e) { + } catch (const Exception& e) { ptruncate(fiber->gc_pool, allocated_size); throw; } diff --git a/src/box/hash_index.cc b/src/box/hash_index.cc index 159e25fd64138fe960ab3ae743e8db337c52ac57..bf5c80a851fe5ba2447b75ad99bae2f7045dceb2 100644 --- a/src/box/hash_index.cc +++ b/src/box/hash_index.cc @@ -661,7 +661,7 @@ Hash64Index::initIterator(struct iterator *ptr, enum iterator_type type, } /* Fall through. */ case ITER_ALL: - it->h_pos = mh_begin(int_hash); + it->h_pos = mh_begin(int64_hash); it->base.next = hash_iterator_i64_ge; break; case ITER_EQ: diff --git a/src/coeio.cc b/src/coeio.cc index 4dac81719cac4617802b0a4ff0188bde4e553657..9421502bbc86557a2f382aa312bd8f82190987e8 100644 --- a/src/coeio.cc +++ b/src/coeio.cc @@ -221,7 +221,6 @@ getaddrinfo_cb(va_list ap) struct addrinfo *hints = va_arg(ap, struct addrinfo *); struct addrinfo **res = va_arg(ap, struct addrinfo **); - say_warn("Host: %s Port: %s, Hints: %p, Res: %p", host, port, hints, res); int rc = getaddrinfo(host, port, hints, res); /* getaddrinfo can return EAI_ADDRFAMILY on attempt * to resolve ::1, if machine has no public ipv6 addresses diff --git a/src/coio.cc b/src/coio.cc index a8b0ae36a74a1c5206446846a34d7de7a9112a48..0b13e03b82c290342a284e471d0ecd1bb1f37e39 100644 --- a/src/coio.cc +++ b/src/coio.cc @@ -37,8 +37,8 @@ #include "scoped_guard.h" static inline void -fiber_schedule_coio(ev_io *watcher, int event) { - say_warn("fiber schedule IO"); +fiber_schedule_coio(ev_io *watcher, int event) +{ return fiber_schedule((ev_watcher *) watcher, event); } @@ -374,7 +374,7 @@ coio_flush(int fd, struct iovec *iov, ssize_t offset, int iovcnt) sio_add_to_iov(iov, -offset); nwr = sio_writev(fd, iov, iovcnt); sio_add_to_iov(iov, offset); - } catch(const Exception& e) { + } catch (const Exception& e) { sio_add_to_iov(iov, offset); throw; } diff --git a/src/exception.cc b/src/exception.cc index 2a92a1c5db16c9f36259c14ac134af99e6e7a1ba..95579cbcf7cb6cf0dd5d116fa3ef7760f864bde6 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -40,7 +40,7 @@ Exception::Exception(const char *file, unsigned line) } Exception::Exception(const Exception& e) - : Object(e), m_file(e.m_file), m_line(e.m_line) + : Object(), m_file(e.m_file), m_line(e.m_line) { memcpy(m_errmsg, e.m_errmsg, sizeof(m_errmsg)); } diff --git a/src/iproto.cc b/src/iproto.cc index 86249b440d13029caa41c523834ba89b9a024da1..9ec06297164f4b2f216f7f0466fd901fd330d3fc 100644 --- a/src/iproto.cc +++ b/src/iproto.cc @@ -680,7 +680,7 @@ iproto_flush(struct iobuf *iobuf, int fd, struct obuf_svp *svp) nwr = sio_writev(fd, iov, iovcnt); sio_add_to_iov(iov, svp->iov_len); - } catch(const Exception&) { + } catch (const Exception&) { sio_add_to_iov(iov, svp->iov_len); throw; } diff --git a/src/log_io.cc b/src/log_io.cc index 27fb967a75590931e131bc929921c31dc29037d6..ba2d662ba2ab3315b5fcb65494206e433096f142 100644 --- a/src/log_io.cc +++ b/src/log_io.cc @@ -219,7 +219,6 @@ format_filename(struct log_dir *dir, i64 lsn, enum log_suffix suffix) /* {{{ struct log_io_cursor */ -/* TODO: wtf? */ #define ROW_EOF (struct tbuf *) 1 static struct tbuf * diff --git a/src/lua/lua_socket.cc b/src/lua/lua_socket.cc index c855eda4c72c5d0b3f21475e5d1f93c0a438c649..710642eb001e7793d3f8e7212053ae3043e74d06 100644 --- a/src/lua/lua_socket.cc +++ b/src/lua/lua_socket.cc @@ -333,9 +333,7 @@ lbox_socket_connect(struct lua_State *L) /* set coio reader socket */ s->io_r.fd = s->io_w.fd; } catch (const SocketError& e) { - say_error("catch(SocketError&)"); freeaddrinfo(ai); - return bio_pushsockerror(L, s, errno); } @@ -746,7 +744,6 @@ lbox_socket_bind(struct lua_State *L) } catch (const SocketError& e) { /* case #2: error */ freeaddrinfo(ai); - say_error("socket SocketError&"); return bio_pusherror(L, s, errno); } @@ -880,7 +877,6 @@ lbox_socket_sendto(struct lua_State *L) if (a) { freeaddrinfo(a); } - say_error("catch(SocketError&)"); return bio_pushsenderror(L, s, 0, errno); } diff --git a/src/memcached.cc b/src/memcached.cc index fb501909f005300df8f0fe5d265567c34d9b52d9..39d66a745a1256471817ad8e2ea5f0e228c9a7e4 100644 --- a/src/memcached.cc +++ b/src/memcached.cc @@ -589,9 +589,10 @@ memcached_expire_loop(va_list ap __attribute__((unused))) memcached_delete_expired_keys(keys_to_delete); fiber_gc(); goto restart; - } catch(const Exception& e) { + } catch (const Exception& e) { memcached_it->free(memcached_it); memcached_it = NULL; + throw; } } diff --git a/src/recovery.cc b/src/recovery.cc index 240e5c6547a76ce5bef37d6c36960681559975c2..3f684ee966a87cd34f6f3d6d05a5b4f5a757e6e7 100644 --- a/src/recovery.cc +++ b/src/recovery.cc @@ -171,7 +171,7 @@ recovery_wait_lsn(struct recovery_state *r, int64_t lsn) try { fiber_yield(); wait_lsn_clear(&r->wait_lsn); - } catch(const Exception& e) { + } catch (const Exception& e) { wait_lsn_clear(&r->wait_lsn); throw; } diff --git a/src/scoped_guard.cc b/src/scoped_guard.cc deleted file mode 100644 index f7414593c8eb629fce8602fd4f3f9088030e76f9..0000000000000000000000000000000000000000 --- a/src/scoped_guard.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "scoped_guard.h"