summaryrefslogtreecommitdiff
path: root/lib/conn.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/conn.c')
-rw-r--r--lib/conn.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/conn.c b/lib/conn.c
index f89ac70..499c330 100644
--- a/lib/conn.c
+++ b/lib/conn.c
@@ -20,19 +20,6 @@
#include "tcp.h"
int
-conn_close (struct rs_connection **connp)
-{
- int r = 0;
- assert (connp);
- assert (*connp);
- if ((*connp)->is_connected)
- r = rs_conn_disconnect (*connp);
- if (r == RSE_OK)
- *connp = NULL;
- return r;
-}
-
-int
conn_user_dispatch_p (const struct rs_connection *conn)
{
assert (conn);
@@ -145,6 +132,25 @@ rs_conn_disconnect (struct rs_connection *conn)
assert (conn);
+ if (conn->is_connected)
+ event_on_disconnect (conn);
+
+ if (conn->bev)
+ {
+ bufferevent_free (conn->bev);
+ conn->bev = NULL;
+ }
+ if (conn->rev)
+ {
+ event_free (conn->rev);
+ conn->rev = NULL;
+ }
+ if (conn->wev)
+ {
+ event_free (conn->wev);
+ conn->wev = NULL;
+ }
+
err = evutil_closesocket (conn->fd);
conn->fd = -1;
return err;