summaryrefslogtreecommitdiff
path: root/lib/conn.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/conn.c')
-rw-r--r--lib/conn.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/lib/conn.c b/lib/conn.c
index 7522782..499c330 100644
--- a/lib/conn.c
+++ b/lib/conn.c
@@ -1,5 +1,5 @@
-/* Copyright 2010, 2011 NORDUnet A/S. All rights reserved.
- See LICENSE for licensing information. */
+/* Copyright 2010-2013 NORDUnet A/S. All rights reserved.
+ See LICENSE for licensing information. */
#if defined HAVE_CONFIG_H
#include <config.h>
@@ -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;