conn: don't set tcp keepalives for disconnected connection
In XMPP_CONN_DISCONNECTED state conn->sock is undefined.
This commit is contained in:
@@ -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)
|
void xmpp_conn_set_keepalive(xmpp_conn_t * const conn, int timeout, int interval)
|
||||||
{
|
{
|
||||||
int ret;
|
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);
|
ret = sock_set_keepalive(conn->sock, timeout, interval);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
xmpp_error(conn->ctx, "xmpp", "Setting TCP keepalive (%d,%d) error: %d",
|
xmpp_error(conn->ctx, "xmpp", "Setting TCP keepalive (%d,%d) error: %d",
|
||||||
|
|||||||
Reference in New Issue
Block a user