From f3252b34114236c65624862d2a572f5e290e8cc8 Mon Sep 17 00:00:00 2001
From: Linus Nordberg <linus@nordberg.se>
Date: Fri, 1 Mar 2013 14:34:21 +0100
Subject: Revamping for listeners.

Split rs_connection into rs_baseconn plus rs_connection and rs_listener.

Connections now has a state variable.

Connect buffer event and fd of _source_ connection, not that of
conn->active_peer. The connection object referred to by a peer is not
meant for using as a connection, only for reporting errors on.

Make sure things are sane even when not using a config file.

Bump library interface version to 1.0.0 since it's changed.
---
 lib/tcp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'lib/tcp.c')

diff --git a/lib/tcp.c b/lib/tcp.c
index b8d7906..f5673f5 100644
--- a/lib/tcp.c
+++ b/lib/tcp.c
@@ -109,7 +109,8 @@ _read_message (struct rs_message *msg)
       /* Find out what happens if there's data left in the buffer.  */
       {
 	size_t rest = 0;
-	rest = evbuffer_get_length (bufferevent_get_input (msg->conn->bev));
+	rest =
+          evbuffer_get_length (bufferevent_get_input (msg->conn->base_.bev));
 	if (rest)
 	  rs_debug (("%s: returning with %d octets left in buffer\n", __func__,
 		     rest));
@@ -178,11 +179,10 @@ tcp_event_cb (struct bufferevent *bev, short events, void *user_data)
   assert (msg->conn);
   conn = msg->conn;
 #if defined (DEBUG)
-  assert (msg->conn->active_peer);
-  p = conn->active_peer;
+  assert (msg->conn->base_.active_peer);
+  p = conn->base_.active_peer;
 #endif
 
-  conn->is_connecting = 0;
   if (events & BEV_EVENT_CONNECTED)
     {
       if (conn->tev)
@@ -213,7 +213,7 @@ tcp_event_cb (struct bufferevent *bev, short events, void *user_data)
 	}
       else
 	{
-	  rs_debug (("%s: %d: %d (%s)\n", __func__, conn->fd, sockerr,
+	  rs_debug (("%s: %d: %d (%s)\n", __func__, conn->base_.fd, sockerr,
 		     evutil_socket_error_to_string (sockerr)));
 	  rs_err_conn_push_fl (conn, RSE_SOCKERR, __FILE__, __LINE__,
 			       "%d: %d (%s)", conn->base_.fd, sockerr,
-- 
cgit v1.1