On Fri, Jun 24, 2016 at 04:44:03PM -0700, Ben Pfaff wrote:
> From: Mario Cabrera <mario.cabr...@hpe.com>
> 
> Replication is enabled by using the following option when starting the
> database server:
> 
> --sync-from=server
> 
> Where 'server' can take any form described in the ovsdb-client(1)
> manpage as an active connection. If this option is specified, the
> replication process is immediately started.
> 
> Signed-off-by: Mario Cabrera <mario.cabr...@hpe.com>

Thanks for the patch.

I noticed a few odd indentations and a strdup() that should have been an
xstrdup(), so I'm folding in the following incremental.

Most of our code doesn't do blocking RPC calls in the way that this code
does.  That's probably something to consider replacing by a state
machine in the future.

--8<--------------------------cut here-------------------------->8--

diff --git a/ovsdb/replication.c b/ovsdb/replication.c
index d9e609e..669f475 100644
--- a/ovsdb/replication.c
+++ b/ovsdb/replication.c
@@ -105,7 +105,7 @@ replication_run(struct shash *all_dbs)
 void
 set_remote_ovsdb_server(const char *remote_server)
 {
-    remote_ovsdb_server = remote_server ? strdup(remote_server) : NULL;
+    remote_ovsdb_server = remote_server ? xstrdup(remote_server) : NULL;
 }
 
 void
@@ -125,7 +125,7 @@ find_db(const struct shash *all_dbs, const char *db_name)
 {
     struct shash_node *node;
 
-    SHASH_FOR_EACH(node, all_dbs) {
+    SHASH_FOR_EACH (node, all_dbs) {
         struct db *db = node->data;
         if (!strcmp(db->db->schema->name, db_name)) {
             return db;
@@ -141,7 +141,7 @@ reset_databases(struct shash *all_dbs)
     struct shash_node *db_node;
     struct ovsdb_error *error = NULL;
 
-    SHASH_FOR_EACH(db_node, all_dbs) {
+    SHASH_FOR_EACH (db_node, all_dbs) {
         struct db *db = db_node->data;
         struct ovsdb_txn *txn = ovsdb_txn_create(db->db);
         reset_database(db->db, txn);
@@ -156,7 +156,7 @@ reset_database(struct ovsdb *db, struct ovsdb_txn *txn)
 {
     struct shash_node *table_node;
 
-    SHASH_FOR_EACH(table_node, &db->tables) {
+    SHASH_FOR_EACH (table_node, &db->tables) {
         struct ovsdb_table *table = table_node->data;
         struct ovsdb_row *row;
 
@@ -173,7 +173,7 @@ open_jsonrpc(const char *server)
     int error;
 
     error = stream_open_block(jsonrpc_stream_open(server, &stream,
-                              DSCP_DEFAULT), &stream);
+                                                  DSCP_DEFAULT), &stream);
 
     return error ? NULL : jsonrpc_open(stream);
 }
@@ -225,9 +225,9 @@ fetch_dbs(struct jsonrpc *rpc, struct svec *dbs)
 
         if (name->type != JSON_STRING) {
             ovsdb_error_assert(ovsdb_error(
-                               "list_dbs failed",
-                               "list_dbs response %"PRIuSIZE" is not string",
-                               i));
+                                   "list_dbs failed",
+                                   "list_dbs response %"PRIuSIZE" is not 
string",
+                                   i));
         }
         svec_add(dbs, name->u.string);
     }
@@ -289,7 +289,7 @@ send_monitor_requests(struct shash *all_dbs)
                 monitor_request = json_object_create();
                 size_t n = shash_count(&local_schema->tables);
                 const struct shash_node **nodes = shash_sort(
-                                                     &local_schema->tables);
+                    &local_schema->tables);
 
                 for (int j = 0; j < n; j++) {
                     struct ovsdb_table_schema *table = nodes[j]->data;
@@ -298,13 +298,13 @@ send_monitor_requests(struct shash *all_dbs)
                 free(nodes);
 
                 /* Send monitor request. */
-                 monitor = json_array_create_3(
-                              json_string_create(db_name),
-                              json_string_create(db_name),
-                              monitor_request);
-                 request = jsonrpc_create_request("monitor", monitor, NULL);
-                 jsonrpc_send(rpc, request);
-                 get_initial_db_state(database);
+                monitor = json_array_create_3(
+                    json_string_create(db_name),
+                    json_string_create(db_name),
+                    monitor_request);
+                request = jsonrpc_create_request("monitor", monitor, NULL);
+                jsonrpc_send(rpc, request);
+                get_initial_db_state(database);
             }
             ovsdb_schema_destroy(remote_schema);
         }
@@ -358,7 +358,7 @@ check_for_notifications(struct shash *all_dbs)
     }
     if (msg->type == JSONRPC_REQUEST && !strcmp(msg->method, "echo")) {
         jsonrpc_send(rpc, jsonrpc_create_reply(json_clone(msg->params),
-                     msg->id));
+                                               msg->id));
     } else if (msg->type == JSONRPC_NOTIFY
                && !strcmp(msg->method, "update")) {
         struct json *params = msg->params;
@@ -369,7 +369,7 @@ check_for_notifications(struct shash *all_dbs)
             if (database) {
                 process_notification(params->u.array.elems[1], database->db);
             }
-       }
+        }
     }
     jsonrpc_msg_destroy(msg);
     jsonrpc_run(rpc);
@@ -391,7 +391,7 @@ process_notification(struct json *table_updates, struct 
ovsdb *database)
 
     /* Process each table update. */
     struct shash_node *node;
-    SHASH_FOR_EACH(node, json_object(table_updates)) {
+    SHASH_FOR_EACH (node, json_object(table_updates)) {
         struct json *table_update = node->data;
         if (table_update) {
             error = process_table_update(table_update, node->name, database, 
txn);
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to