diff options
Diffstat (limited to 'lib/conn.c')
-rw-r--r-- | lib/conn.c | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -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; |