Skip to content

Commit

Permalink
ovsdb-monitor: refactoring ovsdb_monitor_get_initial
Browse files Browse the repository at this point in the history
Refactoring ovsdb_monitor_get_initial() to not generate JSON object.
It only collect changes within the ovsdb_monitor().
ovsdb_jsonrpc_monitor_compose_table_update() is then used to generate
JSON object.

This change will also make future patch easier.

Signed-off-by: Andy Zhou <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
azhou-nicira committed May 30, 2015
1 parent 2fa1df7 commit 61b6301
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 7 additions & 2 deletions ovsdb/jsonrpc-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cancel(
static void ovsdb_jsonrpc_monitor_remove_all(struct ovsdb_jsonrpc_session *);
static void ovsdb_jsonrpc_monitor_flush_all(struct ovsdb_jsonrpc_session *);
static bool ovsdb_jsonrpc_monitor_needs_flush(struct ovsdb_jsonrpc_session *);
static struct json *ovsdb_jsonrpc_monitor_compose_table_update(
const struct ovsdb_jsonrpc_monitor *monitor, bool initial);


/* JSON-RPC database server. */

Expand Down Expand Up @@ -1228,8 +1231,10 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db,
}
}

return jsonrpc_create_reply(ovsdb_monitor_get_initial(m->dbmon),
request_id);
ovsdb_monitor_get_initial(m->dbmon);
json = ovsdb_jsonrpc_monitor_compose_table_update(m, true);
json = json ? json : json_object_create();
return jsonrpc_create_reply(json, request_id);

error:
if (m) {
Expand Down
5 changes: 1 addition & 4 deletions ovsdb/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,11 @@ ovsdb_monitor_change_cb(const struct ovsdb_row *old,
return true;
}

struct json *
void
ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon)
{
struct ovsdb_monitor_aux aux;
struct shash_node *node;
struct json *json;

ovsdb_monitor_init_aux(&aux, dbmon);
SHASH_FOR_EACH (node, &dbmon->tables) {
Expand All @@ -524,8 +523,6 @@ ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon)
}
}
}
json = ovsdb_monitor_compose_table_update(dbmon, true);
return json ? json : json_object_create();
}

void
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void ovsdb_monitor_table_add_select(struct ovsdb_monitor *dbmon,

bool ovsdb_monitor_needs_flush(struct ovsdb_monitor *dbmon);

struct json *ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon);
void ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon);

void ovsdb_monitor_destroy(struct ovsdb_monitor *dbmon);
#endif

0 comments on commit 61b6301

Please sign in to comment.