summaryrefslogtreecommitdiff
path: root/lib/reconnect.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2020-11-18 16:39:46 -0800
committerBen Pfaff <blp@ovn.org>2020-12-18 18:06:29 -0800
commit4241d652e465827d5111b24092b27bff630980e8 (patch)
tree71deb76b5774bc577aafbda86ab96cfb65919912 /lib/reconnect.h
parent252e1e5764439085e32f07695b45848a079ba4df (diff)
downloadopenvswitch-4241d652e465827d5111b24092b27bff630980e8.tar.gz
jsonrpc: Avoid disconnecting prematurely due to long poll intervals.
Open vSwitch has a few different jsonrpc-based protocols that depend on jsonrpc_session to make sure that the connection is up and working. In turn, jsonrpc_session uses the "reconnect" state machine to send probes if nothing is received. This works fine in normal circumstances. In unusual circumstances, though, it can happen that the program is busy and doesn't even try to receive anything for a long time. Then the timer can time out without a good reason; if it had tried to receive something, it would have. There's a solution that the clients of jsonrpc_session could adopt. Instead of first calling jsonrpc_session_run(), which is what calls into "reconnect" to deal with timing out, and then calling into jsonrpc_session_recv(), which is what tries to receive something, they could use the opposite order. That would make sure that the timeout was always based on a recent attempt to receive something. Great. The actual code in OVS that uses jsonrpc_session, though, tends to use the opposite order, and there are enough users and this is a subtle enough issue that it could get flipped back around even if we fixed it now. So this commit takes a different approach. Instead of fixing this in the users of jsonrpc_session, we fix it in the users of reconnect: make them tell when they've tried to receive something (or disable this particular feature). This commit fixes the problem that way. It's kind of hard to reproduce but I'm pretty sure that I've seen it a number of times in testing. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib/reconnect.h')
-rw-r--r--lib/reconnect.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/reconnect.h b/lib/reconnect.h
index 9f2d469e2..40cc569c4 100644
--- a/lib/reconnect.h
+++ b/lib/reconnect.h
@@ -83,6 +83,7 @@ void reconnect_connected(struct reconnect *, long long int now);
void reconnect_connect_failed(struct reconnect *, long long int now,
int error);
void reconnect_activity(struct reconnect *, long long int now);
+void reconnect_receive_attempted(struct reconnect *, long long int now);
enum reconnect_action {
RECONNECT_CONNECT = 1,