Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com
Subject: [PATCH 4/8] box: remove orphan check from box_is_ro()
Date: Wed,  8 Aug 2018 01:03:47 +0300	[thread overview]
Message-ID: <07b102e6b0abd42b550e718fd366927144b0c527.1533679264.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1533679264.git.v.shpilevoy@tarantool.org>
In-Reply-To: <cover.1533679264.git.v.shpilevoy@tarantool.org>

Box_is_ro now checks both for 'read_only' and 'orphan' modes, but
in promotion only 'read_only' is needed. And now there is no a
method to get the current 'read_only' value. After replacing
box_is_ro with box_is_writable it is possible to reimplement
box_is_ro as a getter for 'read_only' option.
---
 src/box/box.cc     | 10 ++++++++--
 src/box/box.h      |  3 +++
 src/box/lua/info.c |  2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index 6eb358442..d8fbc6252 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -216,17 +216,23 @@ box_set_ro(bool ro)
 	fiber_cond_broadcast(&ro_cond);
 }
 
+bool
+box_is_writable(void)
+{
+	return !is_ro && !is_orphan;
+}
+
 bool
 box_is_ro(void)
 {
-	return is_ro || is_orphan;
+	return is_ro;
 }
 
 int
 box_wait_ro(bool ro, double timeout)
 {
 	double deadline = ev_monotonic_now(loop()) + timeout;
-	while (box_is_ro() != ro) {
+	while (!box_is_writable() != ro) {
 		if (fiber_cond_wait_deadline(&ro_cond, deadline) != 0)
 			return -1;
 		if (fiber_is_cancelled()) {
diff --git a/src/box/box.h b/src/box/box.h
index 9e13378d9..29618c9f8 100644
--- a/src/box/box.h
+++ b/src/box/box.h
@@ -86,6 +86,9 @@ box_atfork(void);
 void
 box_set_ro(bool ro);
 
+bool
+box_is_writable(void);
+
 bool
 box_is_ro(void);
 
diff --git a/src/box/lua/info.c b/src/box/lua/info.c
index d6697df9c..42729bea3 100644
--- a/src/box/lua/info.c
+++ b/src/box/lua/info.c
@@ -242,7 +242,7 @@ lbox_info_signature(struct lua_State *L)
 static int
 lbox_info_ro(struct lua_State *L)
 {
-	lua_pushboolean(L, box_is_ro());
+	lua_pushboolean(L, ! box_is_writable());
 	return 1;
 }
 
-- 
2.15.2 (Apple Git-101.1)

  parent reply	other threads:[~2018-08-07 22:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07 22:03 [PATCH 0/8] box.ctl.promote Vladislav Shpilevoy
2018-08-07 22:03 ` [PATCH 1/8] rfc: describe box.ctl.promote protocol Vladislav Shpilevoy
2018-08-07 22:03 ` [PATCH 2/8] box: rename process_rw to process_dml Vladislav Shpilevoy
2018-08-13  8:20   ` Vladimir Davydov
2018-08-07 22:03 ` [PATCH 3/8] Add 'exact_field_count' parameter to options decoder Vladislav Shpilevoy
2018-08-13  8:30   ` Vladimir Davydov
2018-08-07 22:03 ` Vladislav Shpilevoy [this message]
2018-08-13  8:34   ` [PATCH 4/8] box: remove orphan check from box_is_ro() Vladimir Davydov
2018-08-07 22:03 ` [PATCH 5/8] Fix gcov on Mac Vladislav Shpilevoy
2018-08-07 22:03 ` [PATCH 6/8] box: introduce _promotion space Vladislav Shpilevoy
2018-08-07 22:03 ` [PATCH 7/8] box: introduce box.ctl.promote Vladislav Shpilevoy
2018-08-13  8:58   ` Vladimir Davydov
2018-08-07 22:03 ` [PATCH 8/8] box: introduce promotion GC Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07b102e6b0abd42b550e718fd366927144b0c527.1533679264.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH 4/8] box: remove orphan check from box_is_ro()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox