From 686e34c8b7406e3a6dabe78eeab52d51780ee120 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 27 Aug 2008 11:29:53 -0700 Subject: [PATCH] Make the secchan report a few more switch-status items. --- include/rconn.h | 2 ++ lib/rconn.c | 15 +++++++++++++++ secchan/secchan.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/include/rconn.h b/include/rconn.h index 036f030fe..df17a5c01 100644 --- a/include/rconn.h +++ b/include/rconn.h @@ -87,5 +87,7 @@ unsigned int rconn_get_successful_connections(const struct rconn *); time_t rconn_get_last_connection(const struct rconn *); time_t rconn_get_creation_time(const struct rconn *); unsigned long int rconn_get_total_time_connected(const struct rconn *); +int rconn_get_backoff(const struct rconn *); +unsigned int rconn_get_state_elapsed(const struct rconn *); #endif /* rconn.h */ diff --git a/lib/rconn.c b/lib/rconn.c index ee995e499..26e2e6146 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -623,6 +623,21 @@ rconn_get_total_time_connected(const struct rconn *rc) return (rc->total_time_connected + (rconn_is_connected(rc) ? elapsed_in_this_state(rc) : 0)); } + +/* Returns the current amount of backoff, in seconds. This is the amount of + * time after which the rconn will transition from BACKOFF to CONNECTING. */ +int +rconn_get_backoff(const struct rconn *rc) +{ + return rc->backoff; +} + +/* Returns the number of seconds spent in this state so far. */ +unsigned int +rconn_get_state_elapsed(const struct rconn *rc) +{ + return elapsed_in_this_state(rc); +} /* Tries to send a packet from 'rc''s send buffer. Returns 0 if successful, * otherwise a positive errno value. */ diff --git a/secchan/secchan.c b/secchan/secchan.c index 92d5ed73b..68e7df327 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -1092,6 +1092,7 @@ rconn_status_cb(struct status_reply *sr, void *rconn_) status_reply_put(sr, "name=%s", rconn_get_name(rconn)); status_reply_put(sr, "state=%s", rconn_get_state(rconn)); + status_reply_put(sr, "backoff=%d", rconn_get_backoff(rconn)); status_reply_put(sr, "is-connected=%s", rconn_is_connected(rconn) ? "true" : "false"); status_reply_put(sr, "sent-msgs=%u", rconn_packets_sent(rconn)); @@ -1104,6 +1105,7 @@ rconn_status_cb(struct status_reply *sr, void *rconn_) (long int) (now - rconn_get_last_connection(rconn))); status_reply_put(sr, "time-connected=%lu", rconn_get_total_time_connected(rconn)); + status_reply_put(sr, "state-elapsed=%u", rconn_get_state_elapsed(rconn)); } static void -- 2.45.2