[tarantool-patches] [PATCH 02/10] swim: make swim_new_round() void

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Wed May 15 22:36:39 MSK 2019


Firstly, I thought that there is an error - swim_begin_step()
does not reschedules round timer, when new_round() fails. But
then new_round() appeared never failing. This commit makes it
void to eliminate confusion.

Probably it is a legacy since the shuffled members array was
allocated and freed in new_round().

Part of #3234
---
 src/lib/swim/swim.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c
index 725ebf222..a9a0a39b3 100644
--- a/src/lib/swim/swim.c
+++ b/src/lib/swim/swim.c
@@ -844,7 +844,7 @@ swim_shuffle_members(struct swim *swim)
  * Shuffle members, build randomly ordered queue of addressees. In
  * other words, do all round preparation work.
  */
-static int
+static void
 swim_new_round(struct swim *swim)
 {
 	int size = mh_size(swim->members);
@@ -852,7 +852,7 @@ swim_new_round(struct swim *swim)
 		assert(swim->self != NULL);
 		say_verbose("SWIM %d: skip a round - no members",
 			    swim_fd(swim));
-		return 0;
+		return;
 	}
 	/* -1 for self. */
 	say_verbose("SWIM %d: start a new round with %d members", swim_fd(swim),
@@ -866,7 +866,6 @@ swim_new_round(struct swim *swim)
 					in_round_queue);
 		}
 	}
-	return 0;
 }
 
 /**
@@ -1078,12 +1077,10 @@ swim_begin_step(struct ev_loop *loop, struct ev_timer *t, int events)
 	(void) events;
 	(void) loop;
 	struct swim *swim = (struct swim *) t->data;
-	if (! rlist_empty(&swim->round_queue)) {
+	if (! rlist_empty(&swim->round_queue))
 		say_verbose("SWIM %d: continue the round", swim_fd(swim));
-	} else if (swim_new_round(swim) != 0) {
-		diag_log();
-		return;
-	}
+	else
+		swim_new_round(swim);
 	/*
 	 * Possibly empty, if no members but self are specified.
 	 */
@@ -1994,11 +1991,7 @@ swim_quit(struct swim *swim)
 	swim_ev_timer_stop(loop(), &swim->wait_ack_tick);
 	swim_scheduler_stop_input(&swim->scheduler);
 	/* Start the last round - quiting. */
-	if (swim_new_round(swim) != 0) {
-		diag_log();
-		swim_delete(swim);
-		return;
-	}
+	swim_new_round(swim);
 	struct swim_task *task = &swim->round_step_task;
 	swim_task_destroy(task);
 	swim_task_create(task, swim_quit_step_complete, swim_task_delete_cb,
-- 
2.20.1 (Apple Git-117)





More information about the Tarantool-patches mailing list