ovsdb-server: Ignore replies to echo requests.
authorBen Pfaff <blp@nicira.com>
Tue, 17 Nov 2009 00:18:02 +0000 (16:18 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 17 Nov 2009 00:56:07 +0000 (16:56 -0800)
Until this commit, ovsdb-server would send off echo requests when the
connection became idle, but then it would terminate the connection when
the reply arrived, because it didn't recognize that it was a reply to its
own request (!).

ovsdb/jsonrpc-server.c

index a42696a..977d302 100644 (file)
@@ -260,6 +260,10 @@ ovsdb_jsonrpc_session_run(struct ovsdb_jsonrpc_session *s)
                 ovsdb_jsonrpc_session_got_request(s, msg);
             } else if (msg->type == JSONRPC_NOTIFY) {
                 ovsdb_jsonrpc_session_got_notify(s, msg);
+            } else if (msg->type == JSONRPC_REPLY
+                       && msg->id && msg->id->type == JSON_STRING
+                       && !strcmp(msg->id->u.string, "echo")) {
+                /* It's a reply to our echo request.  Ignore it. */
             } else {
                 VLOG_WARN("%s: received unexpected %s message",
                           jsonrpc_get_name(s->rpc),
@@ -301,8 +305,14 @@ ovsdb_jsonrpc_session_run(struct ovsdb_jsonrpc_session *s)
 
     case RECONNECT_PROBE:
         if (s->rpc) {
-            struct json *params = json_array_create_empty();
-            jsonrpc_send(s->rpc, jsonrpc_create_request("echo", params));
+            struct json *params;
+            struct jsonrpc_msg *request;
+
+            params = json_array_create_empty();
+            request = jsonrpc_create_request("echo", params);
+            json_destroy(request->id);
+            request->id = json_string_create("echo");
+            jsonrpc_send(s->rpc, request);
         }
         break;
     }