From 22f156fd06afb565c90ac9346d35a30612ba88e5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 16 Nov 2009 16:18:02 -0800 Subject: [PATCH] ovsdb-server: Ignore replies to echo requests. 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index a42696ac..977d3024 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -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; } -- 2.30.2