From 66980be97d99fa80de77e495bd0b7b4ad5079148 Mon Sep 17 00:00:00 2001
From: Justin Pettit <jpettit@nicira.com>
Date: Mon, 6 May 2013 12:43:48 -0700
Subject: [PATCH] ovsdb-client: Avoid assertion with multiple databases.

When using ovsdb-client with an ovsdb-server with multiple databases, an
assertion could trigger due to them being returned in non-sorted order.
This commit changes the fetch_dbs() function to always return databases
in sorted order, since both callers are expecting that behavior.

Bug #16882

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Reported-by: Spiro Kourtessis <spiro@vmware.com>
---
 AUTHORS              | 1 +
 ovsdb/ovsdb-client.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/AUTHORS b/AUTHORS
index 593776dd2..c113f16b9 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -194,6 +194,7 @@ Scott Hendricks         shendricks@nicira.com
 Sean Brady              sbrady@gtfservices.com
 Sebastian Andrzej Siewior  sebastian@breakpoint.cc
 Sébastien RICCIO        sr@swisscenter.com
+Spiro Kourtessis        spiro@vmware.com
 Srini Seetharaman       seethara@stanford.edu
 Stephen Hemminger       shemminger@vyatta.com
 Takayuki HAMA           t-hama@cb.jp.nec.com
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index 53e6bb9c3..81dcc779b 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -392,6 +392,7 @@ fetch_dbs(struct jsonrpc *rpc, struct svec *dbs)
         svec_add(dbs, name->u.string);
     }
     jsonrpc_msg_destroy(reply);
+    svec_sort(&dbs);
 }
 
 static void
@@ -404,7 +405,6 @@ do_list_dbs(struct jsonrpc *rpc, const char *database OVS_UNUSED,
 
     svec_init(&dbs);
     fetch_dbs(rpc, &dbs);
-    svec_sort(&dbs);
     SVEC_FOR_EACH (i, db_name, &dbs) {
         puts(db_name);
     }
-- 
2.47.0