Add disconnection notification on send/recv errors.

This commit is contained in:
Jack Moffitt
2005-11-19 22:05:00 +00:00
parent 6180bbcc0a
commit 003b0528cd

View File

@@ -83,9 +83,8 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
if (conn->error) { if (conn->error) {
/* FIXME: need to tear down send queues and random other things /* FIXME: need to tear down send queues and random other things
* maybe this should be abstracted */ * maybe this should be abstracted */
xmpp_debug(ctx, "xmpp", "send error occured, tear down socket"); xmpp_debug(ctx, "xmpp", "send error occured, disconnecting");
sock_close(conn->sock); conn_disconnect(conn);
conn->state = XMPP_STATE_DISCONNECTED;
} }
connitem = connitem->next; connitem = connitem->next;
@@ -161,11 +160,7 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
if (sock_connect_error(conn->sock) != 0) { if (sock_connect_error(conn->sock) != 0) {
/* connection failed */ /* connection failed */
xmpp_debug(ctx, "xmpp", "connection failed"); xmpp_debug(ctx, "xmpp", "connection failed");
conn->state = XMPP_STATE_DISCONNECTED; conn_disconnect(conn);
sock_close(conn->sock);
/* notify the connection handler */
conn->conn_handler(conn, XMPP_CONN_FAIL, conn->error,
conn->stream_error, conn->userdata);
break; break;
} }
@@ -186,9 +181,14 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
if (!ret) { if (!ret) {
/* parse error, we need to shut down */ /* parse error, we need to shut down */
/* FIXME */ /* FIXME */
xmpp_debug(ctx, "xmpp", "parse error, disconnecting");
conn_disconnect(conn);
} }
} else {
/* return of 0 means socket closed by server */
xmpp_debug(ctx, "xmpp", "socket closed by remote host");
conn_disconnect(conn);
} }
/* return of 0 means socket closed by server */
} }
break; break;