summaryrefslogtreecommitdiff
path: root/ovsdb/trigger.c
diff options
context:
space:
mode:
authorAndy Zhou <azhou@ovn.org>2016-07-29 14:39:29 -0700
committerAndy Zhou <azhou@ovn.org>2016-08-14 23:32:47 -0700
commite51879e99b3ed11c6b7017a63bff1c5da9f21fda (patch)
treee8e32e013d1e0c3d54898ce08b82e2cbb357a2e2 /ovsdb/trigger.c
parent8fd2bca0270f4055bccca103c596949ab7591b4d (diff)
downloadopenvswitch-e51879e99b3ed11c6b7017a63bff1c5da9f21fda.tar.gz
ovsdb: Make OVSDB backup sever read only
When ovsdb-sever is running in the backup state, it would be nice to make sure there is no un-intended changes to the backup database. This patch makes the ovsdb server only accepts 'read' transactions as a backup server. When the server role is changed into an active server, all existing client connections will be reset. After reconnect, all clinet transactions will then be accepted. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb/trigger.c')
-rw-r--r--ovsdb/trigger.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c
index 0fbe94908..a859983f4 100644
--- a/ovsdb/trigger.c
+++ b/ovsdb/trigger.c
@@ -31,7 +31,8 @@ static void ovsdb_trigger_complete(struct ovsdb_trigger *);
void
ovsdb_trigger_init(struct ovsdb_session *session, struct ovsdb *db,
struct ovsdb_trigger *trigger,
- struct json *request, long long int now)
+ struct json *request, long long int now,
+ bool read_only)
{
trigger->session = session;
trigger->db = db;
@@ -40,6 +41,7 @@ ovsdb_trigger_init(struct ovsdb_session *session, struct ovsdb *db,
trigger->result = NULL;
trigger->created = now;
trigger->timeout_msec = LLONG_MAX;
+ trigger->read_only = read_only;
ovsdb_trigger_try(trigger, now);
}
@@ -111,7 +113,8 @@ static bool
ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now)
{
t->result = ovsdb_execute(t->db, t->session,
- t->request, now - t->created, &t->timeout_msec);
+ t->request, t->read_only,
+ now - t->created, &t->timeout_msec);
if (t->result) {
ovsdb_trigger_complete(t);
return true;