From: Ben Pfaff Date: Fri, 8 Jan 2010 23:36:06 +0000 (-0800) Subject: jsonrpc: Properly implement connection timeout. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1ae9a4316a5d43b54b7e6f746bf43dfe56df302;p=openvswitch jsonrpc: Properly implement connection timeout. jsonrpc_session_connect() indirectly called reconnect_disconnected(), which told the reconnect object that the connection had failed, before it told it that the connection attempt had started. When the connection didn't complete immediately, this caused the connection to time out immediately, without any backoff. Reported by Jeremy Stribling. --- diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index f42035e8..aeb1dd82 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -686,7 +686,6 @@ jsonrpc_session_close(struct jsonrpc_session *s) static void jsonrpc_session_disconnect(struct jsonrpc_session *s) { - reconnect_disconnected(s->reconnect, time_msec(), 0); if (s->rpc) { jsonrpc_error(s->rpc, EOF); jsonrpc_close(s->rpc); @@ -723,6 +722,7 @@ jsonrpc_session_run(struct jsonrpc_session *s) jsonrpc_run(s->rpc); error = jsonrpc_get_status(s->rpc); if (error) { + reconnect_disconnected(s->reconnect, time_msec(), 0); jsonrpc_session_disconnect(s); } } else if (s->stream) { @@ -747,6 +747,7 @@ jsonrpc_session_run(struct jsonrpc_session *s) break; case RECONNECT_DISCONNECT: + reconnect_disconnected(s->reconnect, time_msec(), 0); jsonrpc_session_disconnect(s); break;