mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Cancel autoping timer on disconnect or connection loss
If Profanity is disconnected in any way before ping response is received, the autoping timer will expire after the next connection is established. As result, user will be disconnected immediately. Cancel autoping timer in ev_disconnect_cleanup(), so it is done for all kind of disconnections.
This commit is contained in:
parent
5b4277840a
commit
6138a5f79b
@ -53,6 +53,7 @@ ev_disconnect_cleanup(void)
|
|||||||
ui_disconnected();
|
ui_disconnected();
|
||||||
session_disconnect();
|
session_disconnect();
|
||||||
roster_destroy();
|
roster_destroy();
|
||||||
|
iq_autoping_timer_cancel();
|
||||||
muc_invites_clear();
|
muc_invites_clear();
|
||||||
muc_confserver_clear();
|
muc_confserver_clear();
|
||||||
chat_sessions_clear();
|
chat_sessions_clear();
|
||||||
|
@ -262,6 +262,16 @@ iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback
|
|||||||
g_hash_table_insert(id_handlers, strdup(id), handler);
|
g_hash_table_insert(id_handlers, strdup(id), handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
iq_autoping_timer_cancel(void)
|
||||||
|
{
|
||||||
|
autoping_wait = FALSE;
|
||||||
|
if (autoping_time) {
|
||||||
|
g_timer_destroy(autoping_time);
|
||||||
|
autoping_time = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_autoping_check(void)
|
iq_autoping_check(void)
|
||||||
{
|
{
|
||||||
@ -283,10 +293,8 @@ iq_autoping_check(void)
|
|||||||
if (timeout > 0 && seconds_elapsed >= timeout) {
|
if (timeout > 0 && seconds_elapsed >= timeout) {
|
||||||
cons_show("Autoping response timed out after %u seconds.", timeout);
|
cons_show("Autoping response timed out after %u seconds.", timeout);
|
||||||
log_debug("Autoping check: timed out after %u seconds, disconnecting", timeout);
|
log_debug("Autoping check: timed out after %u seconds, disconnecting", timeout);
|
||||||
|
iq_autoping_timer_cancel();
|
||||||
session_autoping_fail();
|
session_autoping_fail();
|
||||||
autoping_wait = FALSE;
|
|
||||||
g_timer_destroy(autoping_time);
|
|
||||||
autoping_time = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1371,11 +1379,7 @@ _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata)
|
|||||||
static int
|
static int
|
||||||
_auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
_auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
||||||
{
|
{
|
||||||
autoping_wait = FALSE;
|
iq_autoping_timer_cancel();
|
||||||
if (autoping_time) {
|
|
||||||
g_timer_destroy(autoping_time);
|
|
||||||
autoping_time = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *id = xmpp_stanza_get_id(stanza);
|
const char *id = xmpp_stanza_get_id(stanza);
|
||||||
if (id == NULL) {
|
if (id == NULL) {
|
||||||
|
@ -187,6 +187,7 @@ void iq_room_affiliation_set(const char *const room, const char *const jid, char
|
|||||||
void iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason);
|
void iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason);
|
||||||
void iq_room_role_set(const char *const room, const char *const nick, char *role, const char *const reason);
|
void iq_room_role_set(const char *const room, const char *const nick, char *role, const char *const reason);
|
||||||
void iq_room_role_list(const char * const room, char *role);
|
void iq_room_role_list(const char * const room, char *role);
|
||||||
|
void iq_autoping_timer_cancel(void);
|
||||||
void iq_autoping_check(void);
|
void iq_autoping_check(void);
|
||||||
void iq_http_upload_request(HTTPUpload *upload);
|
void iq_http_upload_request(HTTPUpload *upload);
|
||||||
void iq_command_list(const char *const target);
|
void iq_command_list(const char *const target);
|
||||||
|
@ -206,6 +206,7 @@ void iq_room_role_set(const char * const room, const char * const nick, char *ro
|
|||||||
const char * const reason) {}
|
const char * const reason) {}
|
||||||
void iq_room_role_list(const char * const room, char *role) {}
|
void iq_room_role_list(const char * const room, char *role) {}
|
||||||
void iq_last_activity_request(gchar *jid) {}
|
void iq_last_activity_request(gchar *jid) {}
|
||||||
|
void iq_autoping_timer_cancel(void) {}
|
||||||
void iq_autoping_check(void) {}
|
void iq_autoping_check(void) {}
|
||||||
void iq_rooms_cache_clear(void) {}
|
void iq_rooms_cache_clear(void) {}
|
||||||
void iq_command_list(const char *const target) {}
|
void iq_command_list(const char *const target) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user