2 * Copyright (c) 2015 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include "dynamic-string.h"
26 #include "ovsdb-error.h"
27 #include "ovsdb-parser.h"
35 #include "transaction.h"
36 #include "jsonrpc-server.h"
38 #include "openvswitch/vlog.h"
41 static const struct ovsdb_replica_class ovsdb_jsonrpc_replica_class;
42 static struct hmap ovsdb_monitors = HMAP_INITIALIZER(&ovsdb_monitors);
46 * ovsdb_monitor keep track of the ovsdb changes.
49 /* A collection of tables being monitored. */
50 struct ovsdb_monitor {
51 struct ovsdb_replica replica;
52 struct shash tables; /* Holds "struct ovsdb_monitor_table"s. */
53 struct ovs_list jsonrpc_monitors; /* Contains "jsonrpc_monitor_node"s. */
55 uint64_t n_transactions; /* Count number of committed transactions. */
56 struct hmap_node hmap_node; /* Elements within ovsdb_monitors. */
59 struct jsonrpc_monitor_node {
60 struct ovsdb_jsonrpc_monitor *jsonrpc_monitor;
64 /* A particular column being monitored. */
65 struct ovsdb_monitor_column {
66 const struct ovsdb_column *column;
67 enum ovsdb_monitor_selection select;
70 /* A row that has changed in a monitored table. */
71 struct ovsdb_monitor_row {
72 struct hmap_node hmap_node; /* In ovsdb_jsonrpc_monitor_table.changes. */
73 struct uuid uuid; /* UUID of row that changed. */
74 struct ovsdb_datum *old; /* Old data, NULL for an inserted row. */
75 struct ovsdb_datum *new; /* New data, NULL for a deleted row. */
78 /* Contains 'struct ovsdb_monitor_row's for rows that have been
79 * updated but not yet flushed to all the jsonrpc connection.
81 * 'n_refs' represent the number of jsonrpc connections that have
82 * not received updates. Generate the update for the last jsonprc
83 * connection will also destroy the whole "struct ovsdb_monitor_changes"
86 * 'transaction' stores the first update's transaction id.
88 struct ovsdb_monitor_changes {
89 struct ovsdb_monitor_table *mt;
93 struct hmap_node hmap_node; /* Element in ovsdb_monitor_tables' changes
97 /* A particular table being monitored. */
98 struct ovsdb_monitor_table {
99 const struct ovsdb_table *table;
101 /* This is the union (bitwise-OR) of the 'select' values in all of the
102 * members of 'columns' below. */
103 enum ovsdb_monitor_selection select;
105 /* Columns being monitored. */
106 struct ovsdb_monitor_column *columns;
109 /* Contains 'ovsdb_monitor_changes' indexed by 'transaction'. */
113 static void ovsdb_monitor_destroy(struct ovsdb_monitor *dbmon);
114 static struct ovsdb_monitor_changes * ovsdb_monitor_table_add_changes(
115 struct ovsdb_monitor_table *mt, uint64_t next_txn);
116 static struct ovsdb_monitor_changes *ovsdb_monitor_table_find_changes(
117 struct ovsdb_monitor_table *mt, uint64_t unflushed);
118 static void ovsdb_monitor_changes_destroy(
119 struct ovsdb_monitor_changes *changes);
120 static void ovsdb_monitor_table_track_changes(struct ovsdb_monitor_table *mt,
124 compare_ovsdb_monitor_column(const void *a_, const void *b_)
126 const struct ovsdb_monitor_column *a = a_;
127 const struct ovsdb_monitor_column *b = b_;
129 return a->column < b->column ? -1 : a->column > b->column;
132 static struct ovsdb_monitor *
133 ovsdb_monitor_cast(struct ovsdb_replica *replica)
135 ovs_assert(replica->class == &ovsdb_jsonrpc_replica_class);
136 return CONTAINER_OF(replica, struct ovsdb_monitor, replica);
139 /* Finds and returns the ovsdb_monitor_row in 'mt->changes->rows' for the
140 * given 'uuid', or NULL if there is no such row. */
141 static struct ovsdb_monitor_row *
142 ovsdb_monitor_changes_row_find(const struct ovsdb_monitor_changes *changes,
143 const struct uuid *uuid)
145 struct ovsdb_monitor_row *row;
147 HMAP_FOR_EACH_WITH_HASH (row, hmap_node, uuid_hash(uuid),
149 if (uuid_equals(uuid, &row->uuid)) {
156 /* Allocates an array of 'mt->n_columns' ovsdb_datums and initializes them as
157 * copies of the data in 'row' drawn from the columns represented by
158 * mt->columns[]. Returns the array.
160 * If 'row' is NULL, returns NULL. */
161 static struct ovsdb_datum *
162 clone_monitor_row_data(const struct ovsdb_monitor_table *mt,
163 const struct ovsdb_row *row)
165 struct ovsdb_datum *data;
172 data = xmalloc(mt->n_columns * sizeof *data);
173 for (i = 0; i < mt->n_columns; i++) {
174 const struct ovsdb_column *c = mt->columns[i].column;
175 const struct ovsdb_datum *src = &row->fields[c->index];
176 struct ovsdb_datum *dst = &data[i];
177 const struct ovsdb_type *type = &c->type;
179 ovsdb_datum_clone(dst, src, type);
184 /* Replaces the mt->n_columns ovsdb_datums in row[] by copies of the data from
185 * in 'row' drawn from the columns represented by mt->columns[]. */
187 update_monitor_row_data(const struct ovsdb_monitor_table *mt,
188 const struct ovsdb_row *row,
189 struct ovsdb_datum *data)
193 for (i = 0; i < mt->n_columns; i++) {
194 const struct ovsdb_column *c = mt->columns[i].column;
195 const struct ovsdb_datum *src = &row->fields[c->index];
196 struct ovsdb_datum *dst = &data[i];
197 const struct ovsdb_type *type = &c->type;
199 if (!ovsdb_datum_equals(src, dst, type)) {
200 ovsdb_datum_destroy(dst, type);
201 ovsdb_datum_clone(dst, src, type);
206 /* Frees all of the mt->n_columns ovsdb_datums in data[], using the types taken
207 * from mt->columns[], plus 'data' itself. */
209 free_monitor_row_data(const struct ovsdb_monitor_table *mt,
210 struct ovsdb_datum *data)
215 for (i = 0; i < mt->n_columns; i++) {
216 const struct ovsdb_column *c = mt->columns[i].column;
218 ovsdb_datum_destroy(&data[i], &c->type);
224 /* Frees 'row', which must have been created from 'mt'. */
226 ovsdb_monitor_row_destroy(const struct ovsdb_monitor_table *mt,
227 struct ovsdb_monitor_row *row)
230 free_monitor_row_data(mt, row->old);
231 free_monitor_row_data(mt, row->new);
237 ovsdb_monitor_add_jsonrpc_monitor(struct ovsdb_monitor *dbmon,
238 struct ovsdb_jsonrpc_monitor *jsonrpc_monitor)
240 struct jsonrpc_monitor_node *jm;
242 jm = xzalloc(sizeof *jm);
243 jm->jsonrpc_monitor = jsonrpc_monitor;
244 list_push_back(&dbmon->jsonrpc_monitors, &jm->node);
247 struct ovsdb_monitor *
248 ovsdb_monitor_create(struct ovsdb *db,
249 struct ovsdb_jsonrpc_monitor *jsonrpc_monitor)
251 struct ovsdb_monitor *dbmon;
253 dbmon = xzalloc(sizeof *dbmon);
255 ovsdb_replica_init(&dbmon->replica, &ovsdb_jsonrpc_replica_class);
256 ovsdb_add_replica(db, &dbmon->replica);
257 list_init(&dbmon->jsonrpc_monitors);
259 dbmon->n_transactions = 0;
260 shash_init(&dbmon->tables);
261 hmap_node_nullify(&dbmon->hmap_node);
263 ovsdb_monitor_add_jsonrpc_monitor(dbmon, jsonrpc_monitor);
268 ovsdb_monitor_add_table(struct ovsdb_monitor *m,
269 const struct ovsdb_table *table)
271 struct ovsdb_monitor_table *mt;
273 mt = xzalloc(sizeof *mt);
275 shash_add(&m->tables, table->schema->name, mt);
276 hmap_init(&mt->changes);
280 ovsdb_monitor_add_column(struct ovsdb_monitor *dbmon,
281 const struct ovsdb_table *table,
282 const struct ovsdb_column *column,
283 enum ovsdb_monitor_selection select,
284 size_t *allocated_columns)
286 struct ovsdb_monitor_table *mt;
287 struct ovsdb_monitor_column *c;
289 mt = shash_find_data(&dbmon->tables, table->schema->name);
291 if (mt->n_columns >= *allocated_columns) {
292 mt->columns = x2nrealloc(mt->columns, allocated_columns,
293 sizeof *mt->columns);
296 mt->select |= select;
297 c = &mt->columns[mt->n_columns++];
302 /* Check for duplicated column names. Return the first
303 * duplicated column's name if found. Otherwise return
305 const char * OVS_WARN_UNUSED_RESULT
306 ovsdb_monitor_table_check_duplicates(struct ovsdb_monitor *m,
307 const struct ovsdb_table *table)
309 struct ovsdb_monitor_table *mt;
312 mt = shash_find_data(&m->tables, table->schema->name);
315 /* Check for duplicate columns. */
316 qsort(mt->columns, mt->n_columns, sizeof *mt->columns,
317 compare_ovsdb_monitor_column);
318 for (i = 1; i < mt->n_columns; i++) {
319 if (mt->columns[i].column == mt->columns[i - 1].column) {
320 return mt->columns[i].column->name;
328 static struct ovsdb_monitor_changes *
329 ovsdb_monitor_table_add_changes(struct ovsdb_monitor_table *mt,
332 struct ovsdb_monitor_changes *changes;
334 changes = xzalloc(sizeof *changes);
336 changes->transaction = next_txn;
339 hmap_init(&changes->rows);
340 hmap_insert(&mt->changes, &changes->hmap_node, hash_uint64(next_txn));
345 static struct ovsdb_monitor_changes *
346 ovsdb_monitor_table_find_changes(struct ovsdb_monitor_table *mt,
347 uint64_t transaction)
349 struct ovsdb_monitor_changes *changes;
350 size_t hash = hash_uint64(transaction);
352 HMAP_FOR_EACH_WITH_HASH(changes, hmap_node, hash, &mt->changes) {
353 if (changes->transaction == transaction) {
361 /* Stop currently tracking changes to table 'mt' since 'transaction'.
363 * Return 'true' if the 'transaction' is being tracked. 'false' otherwise. */
365 ovsdb_monitor_table_untrack_changes(struct ovsdb_monitor_table *mt,
366 uint64_t transaction)
368 struct ovsdb_monitor_changes *changes =
369 ovsdb_monitor_table_find_changes(mt, transaction);
371 if (--changes->n_refs == 0) {
372 hmap_remove(&mt->changes, &changes->hmap_node);
373 ovsdb_monitor_changes_destroy(changes);
378 /* Start tracking changes to table 'mt' begins from 'transaction' inclusive.
381 ovsdb_monitor_table_track_changes(struct ovsdb_monitor_table *mt,
382 uint64_t transaction)
384 struct ovsdb_monitor_changes *changes;
386 changes = ovsdb_monitor_table_find_changes(mt, transaction);
390 ovsdb_monitor_table_add_changes(mt, transaction);
395 ovsdb_monitor_changes_destroy(struct ovsdb_monitor_changes *changes)
397 struct ovsdb_monitor_row *row, *next;
399 HMAP_FOR_EACH_SAFE (row, next, hmap_node, &changes->rows) {
400 hmap_remove(&changes->rows, &row->hmap_node);
401 ovsdb_monitor_row_destroy(changes->mt, row);
403 hmap_destroy(&changes->rows);
407 /* Returns JSON for a <row-update> (as described in RFC 7047) for 'row' within
408 * 'mt', or NULL if no row update should be sent.
410 * The caller should specify 'initial' as true if the returned JSON is going to
411 * be used as part of the initial reply to a "monitor" request, false if it is
412 * going to be used as part of an "update" notification.
414 * 'changed' must be a scratch buffer for internal use that is at least
415 * bitmap_n_bytes(mt->n_columns) bytes long. */
417 ovsdb_monitor_compose_row_update(
418 const struct ovsdb_monitor_table *mt,
419 const struct ovsdb_monitor_row *row,
420 bool initial, unsigned long int *changed)
422 enum ovsdb_monitor_selection type;
423 struct json *old_json, *new_json;
424 struct json *row_json;
427 type = (initial ? OJMS_INITIAL
428 : !row->old ? OJMS_INSERT
429 : !row->new ? OJMS_DELETE
431 if (!(mt->select & type)) {
435 if (type == OJMS_MODIFY) {
439 memset(changed, 0, bitmap_n_bytes(mt->n_columns));
440 for (i = 0; i < mt->n_columns; i++) {
441 const struct ovsdb_column *c = mt->columns[i].column;
442 if (!ovsdb_datum_equals(&row->old[i], &row->new[i], &c->type)) {
443 bitmap_set1(changed, i);
448 /* No actual changes: presumably a row changed and then
449 * changed back later. */
454 row_json = json_object_create();
455 old_json = new_json = NULL;
456 if (type & (OJMS_DELETE | OJMS_MODIFY)) {
457 old_json = json_object_create();
458 json_object_put(row_json, "old", old_json);
460 if (type & (OJMS_INITIAL | OJMS_INSERT | OJMS_MODIFY)) {
461 new_json = json_object_create();
462 json_object_put(row_json, "new", new_json);
464 for (i = 0; i < mt->n_columns; i++) {
465 const struct ovsdb_monitor_column *c = &mt->columns[i];
467 if (!(type & c->select)) {
468 /* We don't care about this type of change for this
469 * particular column (but we will care about it for some
474 if ((type == OJMS_MODIFY && bitmap_is_set(changed, i))
475 || type == OJMS_DELETE) {
476 json_object_put(old_json, c->column->name,
477 ovsdb_datum_to_json(&row->old[i],
480 if (type & (OJMS_INITIAL | OJMS_INSERT | OJMS_MODIFY)) {
481 json_object_put(new_json, c->column->name,
482 ovsdb_datum_to_json(&row->new[i],
490 /* Constructs and returns JSON for a <table-updates> object (as described in
491 * RFC 7047) for all the outstanding changes within 'monitor', and deletes all
492 * the outstanding changes from 'monitor'. Returns NULL if no update needs to
495 * The caller should specify 'initial' as true if the returned JSON is going to
496 * be used as part of the initial reply to a "monitor" request, false if it is
497 * going to be used as part of an "update" notification.
499 * 'unflushed' should point to value that is the transaction ID that did
500 * was not updated. The update contains changes between
501 * ['unflushed, ovsdb->n_transcations]. Before the function returns, this
502 * value will be updated to ovsdb->n_transactions + 1, ready for the next
505 ovsdb_monitor_compose_update(const struct ovsdb_monitor *dbmon,
506 bool initial, uint64_t *unflushed)
508 struct shash_node *node;
509 unsigned long int *changed;
512 uint64_t prev_txn = *unflushed;
513 uint64_t next_txn = dbmon->n_transactions + 1;
516 SHASH_FOR_EACH (node, &dbmon->tables) {
517 struct ovsdb_monitor_table *mt = node->data;
519 max_columns = MAX(max_columns, mt->n_columns);
521 changed = xmalloc(bitmap_n_bytes(max_columns));
524 SHASH_FOR_EACH (node, &dbmon->tables) {
525 struct ovsdb_monitor_table *mt = node->data;
526 struct ovsdb_monitor_row *row, *next;
527 struct ovsdb_monitor_changes *changes;
528 struct json *table_json = NULL;
530 changes = ovsdb_monitor_table_find_changes(mt, prev_txn);
532 ovsdb_monitor_table_track_changes(mt, next_txn);
536 HMAP_FOR_EACH_SAFE (row, next, hmap_node, &changes->rows) {
537 struct json *row_json;
539 row_json = ovsdb_monitor_compose_row_update(
540 mt, row, initial, changed);
542 char uuid[UUID_LEN + 1];
544 /* Create JSON object for transaction overall. */
546 json = json_object_create();
549 /* Create JSON object for transaction on this table. */
551 table_json = json_object_create();
552 json_object_put(json, mt->table->schema->name, table_json);
555 /* Add JSON row to JSON table. */
556 snprintf(uuid, sizeof uuid, UUID_FMT, UUID_ARGS(&row->uuid));
557 json_object_put(table_json, uuid, row_json);
561 ovsdb_monitor_table_untrack_changes(mt, prev_txn);
562 ovsdb_monitor_table_track_changes(mt, next_txn);
565 *unflushed = next_txn;
571 ovsdb_monitor_needs_flush(struct ovsdb_monitor *dbmon,
572 uint64_t next_transaction)
574 ovs_assert(next_transaction <= dbmon->n_transactions + 1);
575 return (next_transaction <= dbmon->n_transactions);
579 ovsdb_monitor_table_add_select(struct ovsdb_monitor *dbmon,
580 const struct ovsdb_table *table,
581 enum ovsdb_monitor_selection select)
583 struct ovsdb_monitor_table * mt;
585 mt = shash_find_data(&dbmon->tables, table->schema->name);
586 mt->select |= select;
589 struct ovsdb_monitor_aux {
590 const struct ovsdb_monitor *monitor;
591 struct ovsdb_monitor_table *mt;
595 ovsdb_monitor_init_aux(struct ovsdb_monitor_aux *aux,
596 const struct ovsdb_monitor *m)
603 ovsdb_monitor_changes_update(const struct ovsdb_row *old,
604 const struct ovsdb_row *new,
605 const struct ovsdb_monitor_table *mt,
606 struct ovsdb_monitor_changes *changes)
608 const struct uuid *uuid = ovsdb_row_get_uuid(new ? new : old);
609 struct ovsdb_monitor_row *change;
611 change = ovsdb_monitor_changes_row_find(changes, uuid);
613 change = xzalloc(sizeof *change);
614 hmap_insert(&changes->rows, &change->hmap_node, uuid_hash(uuid));
615 change->uuid = *uuid;
616 change->old = clone_monitor_row_data(mt, old);
617 change->new = clone_monitor_row_data(mt, new);
620 update_monitor_row_data(mt, new, change->new);
622 free_monitor_row_data(mt, change->new);
626 /* This row was added then deleted. Forget about it. */
627 hmap_remove(&changes->rows, &change->hmap_node);
635 ovsdb_monitor_change_cb(const struct ovsdb_row *old,
636 const struct ovsdb_row *new,
637 const unsigned long int *changed OVS_UNUSED,
640 struct ovsdb_monitor_aux *aux = aux_;
641 const struct ovsdb_monitor *m = aux->monitor;
642 struct ovsdb_table *table = new ? new->table : old->table;
643 struct ovsdb_monitor_table *mt;
644 struct ovsdb_monitor_changes *changes;
646 if (!aux->mt || table != aux->mt->table) {
647 aux->mt = shash_find_data(&m->tables, table->schema->name);
649 /* We don't care about rows in this table at all. Tell the caller
656 HMAP_FOR_EACH(changes, hmap_node, &mt->changes) {
657 ovsdb_monitor_changes_update(old, new, mt, changes);
663 ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon)
665 struct ovsdb_monitor_aux aux;
666 struct shash_node *node;
668 ovsdb_monitor_init_aux(&aux, dbmon);
669 SHASH_FOR_EACH (node, &dbmon->tables) {
670 struct ovsdb_monitor_table *mt = node->data;
672 if (mt->select & OJMS_INITIAL) {
673 struct ovsdb_row *row;
674 struct ovsdb_monitor_changes *changes;
676 changes = ovsdb_monitor_table_find_changes(mt, 0);
678 changes = ovsdb_monitor_table_add_changes(mt, 0);
679 HMAP_FOR_EACH (row, hmap_node, &mt->table->rows) {
680 ovsdb_monitor_changes_update(NULL, row, mt, changes);
690 ovsdb_monitor_remove_jsonrpc_monitor(struct ovsdb_monitor *dbmon,
691 struct ovsdb_jsonrpc_monitor *jsonrpc_monitor)
693 struct jsonrpc_monitor_node *jm;
695 if (list_is_empty(&dbmon->jsonrpc_monitors)) {
696 ovsdb_monitor_destroy(dbmon);
700 /* Find and remove the jsonrpc monitor from the list. */
701 LIST_FOR_EACH(jm, node, &dbmon->jsonrpc_monitors) {
702 if (jm->jsonrpc_monitor == jsonrpc_monitor) {
703 list_remove(&jm->node);
706 /* Destroy ovsdb monitor if this is the last user. */
707 if (list_is_empty(&dbmon->jsonrpc_monitors)) {
708 ovsdb_monitor_destroy(dbmon);
715 /* Should never reach here. jsonrpc_monitor should be on the list. */
720 ovsdb_monitor_table_equal(const struct ovsdb_monitor_table *a,
721 const struct ovsdb_monitor_table *b)
725 if ((a->table != b->table) ||
726 (a->select != b->select) ||
727 (a->n_columns != b->n_columns)) {
731 for (i = 0; i < a->n_columns; i++) {
732 if ((a->columns[i].column != b->columns[i].column) ||
733 (a->columns[i].select != b->columns[i].select)) {
742 ovsdb_monitor_equal(const struct ovsdb_monitor *a,
743 const struct ovsdb_monitor *b)
745 struct shash_node *node;
747 if (shash_count(&a->tables) != shash_count(&b->tables)) {
751 SHASH_FOR_EACH(node, &a->tables) {
752 const struct ovsdb_monitor_table *mta = node->data;
753 const struct ovsdb_monitor_table *mtb;
755 mtb = shash_find_data(&b->tables, node->name);
760 if (!ovsdb_monitor_table_equal(mta, mtb)) {
769 ovsdb_monitor_hash(const struct ovsdb_monitor *dbmon, size_t basis)
771 const struct shash_node **nodes;
774 nodes = shash_sort(&dbmon->tables);
775 n = shash_count(&dbmon->tables);
777 for (i = 0; i < n; i++) {
778 struct ovsdb_monitor_table *mt = nodes[i]->data;
780 basis = hash_pointer(mt->table, basis);
781 basis = hash_3words(mt->select, mt->n_columns, basis);
783 for (j = 0; j < mt->n_columns; j++) {
784 basis = hash_pointer(mt->columns[j].column, basis);
785 basis = hash_2words(mt->columns[j].select, basis);
793 struct ovsdb_monitor *
794 ovsdb_monitor_add(struct ovsdb_monitor *new_dbmon)
796 struct ovsdb_monitor *dbmon;
799 /* New_dbmon should be associated with only one jsonrpc
801 ovs_assert(list_is_singleton(&new_dbmon->jsonrpc_monitors));
803 hash = ovsdb_monitor_hash(new_dbmon, 0);
804 HMAP_FOR_EACH_WITH_HASH(dbmon, hmap_node, hash, &ovsdb_monitors) {
805 if (ovsdb_monitor_equal(dbmon, new_dbmon)) {
810 hmap_insert(&ovsdb_monitors, &new_dbmon->hmap_node, hash);
815 ovsdb_monitor_destroy(struct ovsdb_monitor *dbmon)
817 struct shash_node *node;
819 list_remove(&dbmon->replica.node);
821 if (!hmap_node_is_null(&dbmon->hmap_node)) {
822 hmap_remove(&ovsdb_monitors, &dbmon->hmap_node);
825 SHASH_FOR_EACH (node, &dbmon->tables) {
826 struct ovsdb_monitor_table *mt = node->data;
827 struct ovsdb_monitor_changes *changes, *next;
829 HMAP_FOR_EACH_SAFE (changes, next, hmap_node, &mt->changes) {
830 hmap_remove(&mt->changes, &changes->hmap_node);
831 ovsdb_monitor_changes_destroy(changes);
836 shash_destroy(&dbmon->tables);
840 static struct ovsdb_error *
841 ovsdb_monitor_commit(struct ovsdb_replica *replica,
842 const struct ovsdb_txn *txn,
843 bool durable OVS_UNUSED)
845 struct ovsdb_monitor *m = ovsdb_monitor_cast(replica);
846 struct ovsdb_monitor_aux aux;
848 ovsdb_monitor_init_aux(&aux, m);
849 ovsdb_txn_for_each_change(txn, ovsdb_monitor_change_cb, &aux);
856 ovsdb_monitor_destroy_callback(struct ovsdb_replica *replica)
858 struct ovsdb_monitor *dbmon = ovsdb_monitor_cast(replica);
859 struct jsonrpc_monitor_node *jm, *next;
861 /* Delete all front end monitors. Removing the last front
862 * end monitor will also destroy the corresponding 'ovsdb_monitor'.
863 * ovsdb monitor will also be destroied. */
864 LIST_FOR_EACH_SAFE(jm, next, node, &dbmon->jsonrpc_monitors) {
865 ovsdb_jsonrpc_monitor_destroy(jm->jsonrpc_monitor);
869 static const struct ovsdb_replica_class ovsdb_jsonrpc_replica_class = {
870 ovsdb_monitor_commit,
871 ovsdb_monitor_destroy_callback,