diff mbox

[ovs-dev,monitor_cond,V5,15/18] ovsdb: Add EQ_COND mode to ovsdb_monitor_table_condition

Message ID 1457078953-22280-16-git-send-email-lirans@il.ibm.com
State Deferred
Headers show

Commit Message

Liran Schour March 4, 2016, 8:09 a.m. UTC
This mode indicates that this session has a table with only "=="/"includes"
conditions clauses (might have also a FALSE clause). And we clauses changes
tracking should be enabled.

Signed-off-by: Liran Schour <lirans@il.ibm.com>
---
 ovsdb/monitor.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox

Patch

diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index dfd282a..2975674 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -54,6 +54,8 @@  struct ovsdb_monitor_session_condition {
 enum monitor_table_condition_mode {
     MTC_MODE_TRUE,    /* monitor all rows in table */
     MTC_MODE_FALSE,   /* nothing to monitor */
+    /* conditional monitoring */
+    MTC_MODE_EQ_COND, /* false and "==" clauses only */
     MTC_MODE_FULL,    /* full conditional monitoring */
 };
 
@@ -649,9 +651,17 @@  ovsdb_monitor_condition_bind(struct ovsdb_monitor *dbmon,
         struct ovsdb_monitor_table *mt =
             shash_find_data(&dbmon->tables, mtc->table->schema->name);
 
+        ovs_assert(mtc);
         mtc->mt = mt;
         ovsdb_monitor_condition_add_columns(dbmon, mtc->table,
                                             &mtc->new_condition);
+        if (mtc->cond_mode == MTC_MODE_EQ_COND) {
+            /* Track columns on this table */
+            mt->clauses_tracking = true;
+            ovsdb_monitor_condition_update_tracking(mtc->mt,
+                                                    &mtc->old_condition,
+                                                    NULL);
+        }
     }
 }
 
@@ -918,11 +928,19 @@  ovsdb_monitor_table_condition_set(
     shash_add(&condition->tables, table->schema->name, mtc);
     /* On session startup old == new condition */
     ovsdb_condition_clone(&mtc->new_condition, &mtc->old_condition);
+
+    enum ovsdb_function max_function =
+        ovsdb_condition_max_function(&mtc->old_condition);
+
     if (ovsdb_condition_is_true(&mtc->old_condition)) {
         condition->n_true_cnd++;
         ovsdb_monitor_session_condition_set_mode(condition);
     } else if (ovsdb_condition_is_false(&mtc->old_condition)) {
         mtc->cond_mode = MTC_MODE_FALSE;
+    } else if (max_function <= OVSDB_F_INCLUDES) {
+        mtc->cond_mode = MTC_MODE_EQ_COND;
+        /* We will update tracking of condition's columns only on condition
+         * bind. (After ovsdb_monitor_add) */
     } else {
         mtc->cond_mode = MTC_MODE_FULL;
     }
@@ -997,6 +1015,9 @@  ovsdb_monitor_table_condition_updated(struct ovsdb_monitor_table *mt,
         /* If conditional monitoring - set old condition to new condition */
         if (ovsdb_condition_cmp_3way(&mtc->old_condition,
                                      &mtc->new_condition)) {
+            enum ovsdb_function max_function =
+                ovsdb_condition_max_function(&mtc->old_condition);
+
             if (ovsdb_condition_is_true(&mtc->new_condition)) {
                 mtc->cond_mode = MTC_MODE_TRUE;
                 if (!old_true) {
@@ -1007,6 +1028,16 @@  ovsdb_monitor_table_condition_updated(struct ovsdb_monitor_table *mt,
                 if (old_true) {
                     condition->n_true_cnd--;
                 }
+            } else if (max_function <= OVSDB_F_INCLUDES) {
+                mtc->cond_mode = MTC_MODE_EQ_COND;
+                /* Track columns on this table */
+                mt->clauses_tracking = true;
+                ovsdb_monitor_condition_update_tracking(mtc->mt,
+                                                        &mtc->old_condition,
+                                                        &mtc->new_condition);
+                if (old_true) {
+                    condition->n_true_cnd--;
+                }
             } else {
                 mtc->cond_mode = MTC_MODE_FULL;
                 if (old_true) {