struct jsonrpc_msg *msg;
jsonrpc_recv(s->rpc, &msg);
if (msg) {
- reconnect_received(s->reconnect, time_msec());
+ reconnect_activity(s->reconnect, time_msec());
if (msg->type == JSONRPC_REQUEST && !strcmp(msg->method, "echo")) {
/* Echo request. Send reply. */
struct jsonrpc_msg *reply;
/*
- * Copyright (c) 2008, 2009, 2010 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
enum state state;
long long int state_entered;
int backoff;
- long long int last_received;
+ long long int last_activity;
long long int last_connected;
long long int last_disconnected;
unsigned int max_tries;
fsm->state = S_VOID;
fsm->state_entered = now;
fsm->backoff = 0;
- fsm->last_received = now;
+ fsm->last_activity = now;
fsm->last_connected = LLONG_MAX;
fsm->last_disconnected = LLONG_MAX;
fsm->max_tries = UINT_MAX;
/* Returns the "probe interval" for 'fsm' in milliseconds. If this is zero, it
* disables the connection keepalive feature. If it is nonzero, then if the
- * interval passes while 'fsm' is connected and without reconnect_received()
+ * interval passes while 'fsm' is connected and without reconnect_activity()
* being called for 'fsm', reconnect_run() returns RECONNECT_PROBE. If the
- * interval passes again without reconnect_received() being called,
+ * interval passes again without reconnect_activity() being called,
* reconnect_run() returns RECONNECT_DISCONNECT for 'fsm'. */
int
reconnect_get_probe_interval(const struct reconnect *fsm)
/* Sets the "probe interval" for 'fsm' to 'probe_interval', in milliseconds.
* If this is zero, it disables the connection keepalive feature. If it is
* nonzero, then if the interval passes while 'fsm' is connected and without
- * reconnect_received() being called for 'fsm', reconnect_run() returns
- * RECONNECT_PROBE. If the interval passes again without reconnect_received()
+ * reconnect_activity() being called for 'fsm', reconnect_run() returns
+ * RECONNECT_PROBE. If the interval passes again without reconnect_activity()
* being called, reconnect_run() returns RECONNECT_DISCONNECT for 'fsm'.
*
* If 'probe_interval' is nonzero, then it will be forced to a value of at
}
/* Back off. */
if (fsm->state & (S_ACTIVE | S_IDLE)
- && (fsm->last_received - fsm->last_connected >= fsm->backoff
+ && (fsm->last_activity - fsm->last_connected >= fsm->backoff
|| fsm->passive)) {
fsm->backoff = fsm->passive ? 0 : fsm->min_backoff;
} else {
/* Tell 'fsm' that the connection was successful.
*
* The FSM will start the probe interval timer, which is reset by
- * reconnect_received(). If the timer expires, a probe will be sent (by
+ * reconnect_activity(). If the timer expires, a probe will be sent (by
* returning RECONNECT_PROBE from reconnect_run()). If the timer expires
* again without being reset, the connection will be aborted (by returning
* RECONNECT_DISCONNECT from reconnect_run()). */
reconnect_disconnected(fsm, now, error);
}
-/* Tell 'fsm' that some data was received. This resets the probe interval
- * timer, so that the connection is known not to be idle. */
+/* Tell 'fsm' that some activity has occurred on the connection. This resets
+ * the probe interval timer, so that the connection is known not to be idle. */
void
-reconnect_received(struct reconnect *fsm, long long int now)
+reconnect_activity(struct reconnect *fsm, long long int now)
{
if (fsm->state != S_ACTIVE) {
reconnect_transition__(fsm, now, S_ACTIVE);
}
- fsm->last_received = now;
+ fsm->last_activity = now;
}
static void
case S_ACTIVE:
if (fsm->probe_interval) {
- long long int base = MAX(fsm->last_received, fsm->state_entered);
+ long long int base = MAX(fsm->last_activity, fsm->state_entered);
return base + fsm->probe_interval;
}
return LLONG_MAX;
case S_ACTIVE:
VLOG_DBG("%s: idle %lld ms, sending inactivity probe", fsm->name,
- now - MAX(fsm->last_received, fsm->state_entered));
+ now - MAX(fsm->last_activity, fsm->state_entered));
reconnect_transition__(fsm, now, S_IDLE);
return RECONNECT_PROBE;
struct reconnect_stats *stats)
{
stats->creation_time = fsm->creation_time;
- stats->last_received = fsm->last_received;
+ stats->last_activity = fsm->last_activity;
stats->last_connected = fsm->last_connected;
stats->last_disconnected = fsm->last_disconnected;
stats->backoff = fsm->backoff;
/*
- * Copyright (c) 2009, 2010 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void reconnect_connected(struct reconnect *, long long int now);
void reconnect_connect_failed(struct reconnect *, long long int now,
int error);
-void reconnect_received(struct reconnect *, long long int now);
+void reconnect_activity(struct reconnect *, long long int now);
enum reconnect_action {
RECONNECT_CONNECT = 1,
struct reconnect_stats {
/* All times and durations in this structure are in milliseconds. */
long long int creation_time; /* Time reconnect_create() called. */
- long long int last_received; /* Last call to reconnect_received(). */
+ long long int last_activity; /* Last call to reconnect_activity(). */
long long int last_connected; /* Last call to reconnect_connected(). */
long long int last_disconnected; /* Last call to reconnect_disconnected(). */
int backoff; /* Current backoff duration. */
if self.rpc is not None:
error, msg = self.rpc.recv()
if not error:
- self.reconnect.received(ovs.timeval.msec())
+ self.reconnect.activity(ovs.timeval.msec())
if msg.type == Message.T_REQUEST and msg.method == "echo":
# Echo request. Send reply.
self.send(Message.create_reply(msg.params, msg.id))
@staticmethod
def deadline(fsm):
if fsm.probe_interval:
- base = max(fsm.last_received, fsm.state_entered)
+ base = max(fsm.last_activity, fsm.state_entered)
return base + fsm.probe_interval
return None
def run(fsm, now):
vlog.dbg("%s: idle %d ms, sending inactivity probe"
% (fsm.name,
- now - max(fsm.last_received, fsm.state_entered)))
+ now - max(fsm.last_activity, fsm.state_entered)))
fsm._transition(now, Reconnect.Idle)
return PROBE
self.state = Reconnect.Void
self.state_entered = now
self.backoff = 0
- self.last_received = now
+ self.last_activity = now
self.last_connected = None
self.last_disconnected = None
self.max_tries = None
"""Returns the "probe interval" in milliseconds. If this is zero, it
disables the connection keepalive feature. If it is nonzero, then if
the interval passes while the FSM is connected and without
- self.received() being called, self.run() returns ovs.reconnect.PROBE.
- If the interval passes again without self.received() being called,
+ self.activity() being called, self.run() returns ovs.reconnect.PROBE.
+ If the interval passes again without self.activity() being called,
self.run() returns ovs.reconnect.DISCONNECT."""
return self.probe_interval
"""Sets the "probe interval" to 'probe_interval', in milliseconds. If
this is zero, it disables the connection keepalive feature. If it is
nonzero, then if the interval passes while this FSM is connected and
- without self.received() being called, self.run() returns
+ without self.activity() being called, self.run() returns
ovs.reconnect.PROBE. If the interval passes again without
- self.received() being called, self.run() returns
+ self.activity() being called, self.run() returns
ovs.reconnect.DISCONNECT.
If 'probe_interval' is nonzero, then it will be forced to a value of at
# Back off
if (self.state in (Reconnect.Active, Reconnect.Idle) and
- (self.last_received - self.last_connected >= self.backoff or
+ (self.last_activity - self.last_connected >= self.backoff or
self.passive)):
if self.passive:
self.backoff = 0
"""Tell this FSM that the connection was successful.
The FSM will start the probe interval timer, which is reset by
- self.received(). If the timer expires, a probe will be sent (by
+ self.activity(). If the timer expires, a probe will be sent (by
returning ovs.reconnect.PROBE from self.run(). If the timer expires
again without being reset, the connection will be aborted (by returning
ovs.reconnect.DISCONNECT from self.run()."""
self.connecting(now)
self.disconnected(now, error)
- def received(self, now):
- """Tell this FSM that some data was received. This resets the probe
- interval timer, so that the connection is known not to be idle."""
+ def activity(self, now):
+ """Tell this FSM that some activity occurred on the connection. This
+ resets the probe interval timer, so that the connection is known not to
+ be idle."""
if self.state != Reconnect.Active:
self._transition(now, Reconnect.Active)
- self.last_received = now
+ self.last_activity = now
def _transition(self, now, state):
if self.state == Reconnect.ConnectInProgress:
stats.creation_time = self.creation_time
stats.last_connected = self.last_connected
stats.last_disconnected = self.last_disconnected
- stats.last_received = self.last_received
+ stats.last_activity = self.last_activity
stats.backoff = self.backoff
stats.seqno = self.seqno
stats.is_connected = self.is_connected()
should connect
connected
in ACTIVE for 0 ms (0 ms backoff)
- created 1000, last received 1000, last connected 1000
+ created 1000, last activity 1000, last connected 1000
1 successful connections out of 1 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
run
connected
in ACTIVE for 0 ms (0 ms backoff)
- created 1000, last received 1000, last connected 1500
+ created 1000, last activity 1000, last connected 1500
1 successful connections out of 1 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
should connect
connected
in ACTIVE for 0 ms (0 ms backoff)
- created 1000, last received 1000, last connected 1000
+ created 1000, last activity 1000, last connected 1000
1 successful connections out of 1 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
should connect
connected
in ACTIVE for 0 ms (1000 ms backoff)
- created 1000, last received 1000, last connected 12000
+ created 1000, last activity 1000, last connected 12000
2 successful connections out of 2 attempts, seqno 3
connected
last connected 0 ms ago, connected 10000 ms total
should connect
connected
in ACTIVE for 0 ms (2000 ms backoff)
- created 1000, last received 1000, last connected 24000
+ created 1000, last activity 1000, last connected 24000
3 successful connections out of 3 attempts, seqno 5
connected
last connected 0 ms ago, connected 20000 ms total
run
connected
in ACTIVE for 0 ms (2000 ms backoff)
- created 1000, last received 1000, last connected 6500
+ created 1000, last activity 1000, last connected 6500
1 successful connections out of 3 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
# Connection receives 3 chunks of data spaced 250 ms apart.
advance 250
run
-received
+activity
advance 250
run
-received
+activity
advance 250
run
-received
+activity
# Connection drops.
disconnected
run
connected
in ACTIVE for 0 ms (2000 ms backoff)
- created 1000, last received 1000, last connected 6500
+ created 1000, last activity 1000, last connected 6500
1 successful connections out of 3 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
### t=6750 ###
in ACTIVE for 250 ms (2000 ms backoff)
run
-received
- created 1000, last received 6750, last connected 6500
+activity
+ created 1000, last activity 6750, last connected 6500
advance 250
### t=7000 ###
in ACTIVE for 500 ms (2000 ms backoff)
run
-received
- created 1000, last received 7000, last connected 6500
+activity
+ created 1000, last activity 7000, last connected 6500
advance 250
### t=7250 ###
in ACTIVE for 750 ms (2000 ms backoff)
run
-received
- created 1000, last received 7250, last connected 6500
+activity
+ created 1000, last activity 7250, last connected 6500
# Connection drops.
disconnected
# Connection receives 3 chunks of data spaced 2000 ms apart.
advance 2000
run
-received
+activity
advance 2000
run
-received
+activity
advance 2000
run
-received
+activity
# Connection drops.
disconnected
run
connected
in ACTIVE for 0 ms (2000 ms backoff)
- created 1000, last received 1000, last connected 6500
+ created 1000, last activity 1000, last connected 6500
1 successful connections out of 3 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
### t=8500 ###
in ACTIVE for 2000 ms (2000 ms backoff)
run
-received
- created 1000, last received 8500, last connected 6500
+activity
+ created 1000, last activity 8500, last connected 6500
advance 2000
### t=10500 ###
in ACTIVE for 4000 ms (2000 ms backoff)
run
-received
- created 1000, last received 10500, last connected 6500
+activity
+ created 1000, last activity 10500, last connected 6500
advance 2000
### t=12500 ###
in ACTIVE for 6000 ms (2000 ms backoff)
run
-received
- created 1000, last received 12500, last connected 6500
+activity
+ created 1000, last activity 12500, last connected 6500
# Connection drops.
disconnected
should connect
connected
in ACTIVE for 0 ms (0 ms backoff)
- created 1000, last received 1000, last connected 1000
+ created 1000, last activity 1000, last connected 1000
1 successful connections out of 1 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
# Connection accepted.
connected
-received
+activity
advance 1000
-received
+activity
# Connection times out.
timeout
# Connection accepted.
connected
in ACTIVE for 0 ms (1000 ms backoff)
- created 1000, last received 1000, last connected 2000
+ created 1000, last activity 1000, last connected 2000
1 successful connections out of 1 attempts, seqno 1
connected
last connected 0 ms ago, connected 0 ms total
-received
- created 1000, last received 2000, last connected 2000
+activity
+ created 1000, last activity 2000, last connected 2000
advance 1000
### t=3000 ###
in ACTIVE for 1000 ms (1000 ms backoff)
-received
- created 1000, last received 3000, last connected 2000
+activity
+ created 1000, last activity 3000, last connected 2000
# Connection times out.
timeout
/*
- * Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
static void
-do_received(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+do_activity(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
- reconnect_received(reconnect, now);
+ reconnect_activity(reconnect, now);
}
static void
new->state, new->state_elapsed, new->backoff);
}
if (old->creation_time != new->creation_time
- || old->last_received != new->last_received
+ || old->last_activity != new->last_activity
|| old->last_connected != new->last_connected) {
- printf(" created %lld, last received %lld, last connected %lld\n",
- new->creation_time, new->last_received, new->last_connected);
+ printf(" created %lld, last activity %lld, last connected %lld\n",
+ new->creation_time, new->last_activity, new->last_connected);
}
if (old->n_successful_connections != new->n_successful_connections
|| old->n_attempted_connections != new->n_attempted_connections
{ "connecting", 0, 0, do_connecting },
{ "connect-failed", 0, 1, do_connect_failed },
{ "connected", 0, 0, do_connected },
- { "received", 0, 0, do_received },
+ { "activity", 0, 0, do_activity },
{ "run", 0, 1, do_run },
{ "advance", 1, 1, do_advance },
{ "timeout", 0, 0, do_timeout },
-# Copyright (c) 2009, 2010 Nicira, Inc.
+# Copyright (c) 2009, 2010, 2012 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
r.connected(now)
-def do_received(_):
- r.received(now)
+def do_activity(_):
+ r.activity(now)
def do_run(arg):
% (new.state, new.state_elapsed, new.backoff))
if (old.creation_time != new.creation_time or
- old.last_received != new.last_received or
+ old.last_activity != new.last_activity or
old.last_connected != new.last_connected):
- print(" created %d, last received %d, last connected %d"
- % (new.creation_time, new.last_received, new.last_connected))
+ print(" created %d, last activity %d, last connected %d"
+ % (new.creation_time, new.last_activity, new.last_connected))
if (old.n_successful_connections != new.n_successful_connections or
old.n_attempted_connections != new.n_attempted_connections or
"connecting": do_connecting,
"connect-failed": do_connect_failed,
"connected": do_connected,
- "received": do_received,
+ "activity": do_activity,
"run": do_run,
"advance": do_advance,
"timeout": do_timeout,