From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 2/6] xlog: differentiate between closed and never opened cursor Date: Fri, 29 Jun 2018 19:48:29 +0300 Message-Id: <71f63ba2e80ebb668394a5015acd0d538ba465f2.1530287767.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: Currently, a cursor that has never been opened and a cursor that was properly closed share the same state, XLOG_CURSOR_CLOSED. Let's add a new state, XLOG_CURSOR_UNINITIALIZED, so that we can differentiate between those two. This new state will be used by the next patch. --- src/box/xlog.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/box/xlog.h b/src/box/xlog.h index bff3275f..9b5c8555 100644 --- a/src/box/xlog.h +++ b/src/box/xlog.h @@ -545,8 +545,8 @@ xlog_tx_decode(const char *data, const char *data_end, /* {{{ xlog_cursor - read rows from a log file */ enum xlog_cursor_state { - /* Cursor is closed */ - XLOG_CURSOR_CLOSED = 0, + /* The cursor was never opened. */ + XLOG_CURSOR_UNINITIALIZED = 0, /* The cursor is open but no tx is read */ XLOG_CURSOR_ACTIVE = 1, /* The Cursor is open and a tx is read */ @@ -555,6 +555,8 @@ enum xlog_cursor_state { XLOG_CURSOR_EOF = 3, /* The cursor was closed after reaching EOF. */ XLOG_CURSOR_EOF_CLOSED = 4, + /* The cursor was closed before reaching EOF. */ + XLOG_CURSOR_CLOSED = 5, }; /** @@ -586,7 +588,8 @@ struct xlog_cursor static inline bool xlog_cursor_is_open(const struct xlog_cursor *cursor) { - return (cursor->state != XLOG_CURSOR_CLOSED && + return (cursor->state != XLOG_CURSOR_UNINITIALIZED && + cursor->state != XLOG_CURSOR_CLOSED && cursor->state != XLOG_CURSOR_EOF_CLOSED); } -- 2.11.0