conn: don't set tcp keepalives for disconnected connection

In XMPP_CONN_DISCONNECTED state conn->sock is undefined.
This commit is contained in:
Dmitry Podgorny
2016-04-08 18:17:07 +00:00
parent 5518a9e10a
commit 367aeb5844

View File

@@ -188,6 +188,12 @@ xmpp_conn_t *xmpp_conn_clone(xmpp_conn_t * const conn)
void xmpp_conn_set_keepalive(xmpp_conn_t * const conn, int timeout, int interval)
{
int ret;
if (conn->state == XMPP_STATE_DISCONNECTED) {
xmpp_error(conn->ctx, "xmpp", "Setting TCP keepalive impossible on"
"disconnected connection");
return;
}
ret = sock_set_keepalive(conn->sock, timeout, interval);
if (ret < 0) {
xmpp_error(conn->ctx, "xmpp", "Setting TCP keepalive (%d,%d) error: %d",