time_t last_connected;
unsigned int packets_sent;
unsigned int seqno;
+ int last_error;
/* In S_ACTIVE and S_IDLE, probably_admitted reports whether we believe
* that the peer has made a (positive) admission control decision on our
} else {
VLOG_WARN("%s: connection failed (%s)", rc->name, strerror(retval));
rc->backoff_deadline = TIME_MAX; /* Prevent resetting backoff. */
- disconnect(rc, 0);
+ disconnect(rc, retval);
}
return retval;
}
} else if (timed_out(rc)) {
VLOG_INFO("%s: connection timed out", rc->name);
rc->backoff_deadline = TIME_MAX; /* Prevent resetting backoff. */
- disconnect(rc, 0);
+ disconnect(rc, ETIMEDOUT);
}
}
VLOG_ERR("%s: no response to inactivity probe after %u "
"seconds, disconnecting",
rc->name, elapsed_in_this_state(rc));
- disconnect(rc, 0);
+ disconnect(rc, ETIMEDOUT);
} else {
do_tx_work(rc);
}
{
return rc->seqno;
}
+
+/* Returns a value that explains why 'rc' last disconnected:
+ *
+ * - 0 means that the last disconnection was caused by a call to
+ * rconn_disconnect(), or that 'rc' is new and has not yet completed its
+ * initial connection or connection attempt.
+ *
+ * - EOF means that the connection was closed in the normal way by the peer.
+ *
+ * - A positive integer is an errno value that represents the error.
+ */
+int
+rconn_get_last_error(const struct rconn *rc)
+{
+ return rc->last_error;
+}
\f
struct rconn_packet_counter *
rconn_packet_counter_create(void)
}
}
-/* Disconnects 'rc'. */
+/* Disconnects 'rc' and records 'error' as the error that caused 'rc''s last
+ * disconnection:
+ *
+ * - 0 means that this disconnection is due to a request by 'rc''s client,
+ * not due to any kind of network error.
+ *
+ * - EOF means that the connection was closed in the normal way by the peer.
+ *
+ * - A positive integer is an errno value that represents the error.
+ */
static void
-disconnect(struct rconn *rc, int error OVS_UNUSED)
+disconnect(struct rconn *rc, int error)
{
+ rc->last_error = error;
if (rc->reliable) {
time_t now = time_now();
/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
int rconn_get_backoff(const struct rconn *);
unsigned int rconn_get_state_elapsed(const struct rconn *);
unsigned int rconn_get_connection_seqno(const struct rconn *);
+int rconn_get_last_error(const struct rconn *);
/* Counts the number of packets queued into an rconn by a given source. */
struct rconn_packet_counter {