+ }
+ free(changed);
+
+ return json;
+}
+
+/* Returns JSON for a <table-updates> object (as described in RFC 7047)
+ * for all the outstanding changes within 'monitor' that starts from
+ * '*unflushed' transaction id.
+ *
+ * The caller should specify 'initial' as true if the returned JSON is going to
+ * be used as part of the initial reply to a "monitor" request, false if it is
+ * going to be used as part of an "update" notification. */
+struct json *
+ovsdb_monitor_get_update(struct ovsdb_monitor *dbmon,
+ bool initial, uint64_t *unflushed)
+{
+ struct ovsdb_monitor_json_cache_node *cache_node;
+ struct shash_node *node;
+ struct json *json;
+ uint64_t prev_txn = *unflushed;
+ uint64_t next_txn = dbmon->n_transactions + 1;
+
+ /* Return a clone of cached json if one exists. Otherwise,
+ * generate a new one and add it to the cache. */
+ cache_node = ovsdb_monitor_json_cache_search(dbmon, prev_txn);
+ if (cache_node) {
+ json = cache_node->json ? json_clone(cache_node->json) : NULL;
+ } else {
+ json = ovsdb_monitor_compose_update(dbmon, initial, prev_txn);
+ ovsdb_monitor_json_cache_insert(dbmon, prev_txn, json);
+ }
+
+ /* Maintain transaction id of 'changes'. */
+ SHASH_FOR_EACH (node, &dbmon->tables) {
+ struct ovsdb_monitor_table *mt = node->data;