[PATCH v2 2/6] xlog: differentiate between closed and never opened cursor

Vladimir Davydov vdavydov.dev at gmail.com
Fri Jun 29 19:48:29 MSK 2018


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




More information about the Tarantool-patches mailing list