aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-03-27 10:16:52 -0700
committerBen Pfaff <blp@nicira.com>2012-04-12 08:19:01 -0700
commit854a94d9d20ee57b00ed8d8503e0fd945eb52301 (patch)
tree7d4522137939e8b091757e44e4d16f2fce40b50f /tests
parent6da258aa4c4552a905af36340be15dcbd42b4ab6 (diff)
ovsdb-idl: Simplify transaction retry.
Originally the IDL transaction state machine had a return value TXN_TRY_AGAIN to signal the client to wait for a change in the database and then retry its transaction. However, this logic was incomplete, because it was possible for the database to change before the reply to the transaction RPC was received, in which case the client would wait for a further change. Commit 4fdfe5ccf84c (ovsdb-idl: Prevent occasional hang when multiple database clients race.) fixed the problem by breaking TXN_TRY_AGAIN into two status codes, TXN_AGAIN_WAIT that meant to wait for a further change and TXN_AGAIN_NOW that meant that a change had already occurred so try again immediately. This is correct enough, but it is more complicated than necessary. It is simpler and just as correct to use a single "try again" status that requires the client to wait for a change relative to the database contents *before* the transaction was committed. This commit makes that change. It also changes ovsdb_idl_run()'s return type from bool to void because its return type is hardly useful anymore. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-ovsdb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 65d6e5f7..cc01bbe3 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1893,7 +1893,11 @@ do_idl(int argc, char *argv[])
arg++;
} else {
/* Wait for update. */
- while (ovsdb_idl_get_seqno(idl) == seqno && !ovsdb_idl_run(idl)) {
+ for (;;) {
+ ovsdb_idl_run(idl);
+ if (ovsdb_idl_get_seqno(idl) != seqno) {
+ break;
+ }
jsonrpc_run(rpc);
ovsdb_idl_wait(idl);
@@ -1933,7 +1937,11 @@ do_idl(int argc, char *argv[])
if (rpc) {
jsonrpc_close(rpc);
}
- while (ovsdb_idl_get_seqno(idl) == seqno && !ovsdb_idl_run(idl)) {
+ for (;;) {
+ ovsdb_idl_run(idl);
+ if (ovsdb_idl_get_seqno(idl) != seqno) {
+ break;
+ }
ovsdb_idl_wait(idl);
poll_block();
}