From a1ae9a4316a5d43b54b7e6f746bf43dfe56df302 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 8 Jan 2010 15:36:06 -0800 Subject: [PATCH] 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. --- lib/jsonrpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.30.2