-/* Disconnects 'rc'. 'error' is used only for logging purposes. If it is
- * nonzero, then it should be EOF to indicate the connection was closed by the
- * peer in a normal fashion or a positive errno value. */
+/* Reports that 'error' caused 'rc' to disconnect. 'error' may be a positive
+ * errno value, or it may be EOF to indicate that the connection was closed
+ * normally. */
+static void
+report_error(struct rconn *rc, int error)
+{
+ if (error == EOF) {
+ /* If 'rc' isn't reliable, then we don't really expect this connection
+ * to last forever anyway (probably it's a connection that we received
+ * via accept()), so use DBG level to avoid cluttering the logs. */
+ enum vlog_level level = rc->reliable ? VLL_INFO : VLL_DBG;
+ VLOG(level, "%s: connection closed by peer", rc->name);
+ } else {
+ VLOG_WARN("%s: connection dropped (%s)", rc->name, strerror(error));
+ }
+}
+
+/* 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.
+ */