mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Don't clear saved account data in session_disconnect()
If connection loss occurs, it calls session_disconnect() eventually. This function clears saved account data which is required for reconnection. Therefore, when reconnect timer expires, we get errors: 02/06/2019 04:53:42: stderr: ERR: (profanity:17115): GLib-CRITICAL **: 04:53:42.305: g_key_file_has_group: assertion 'group_name != NULL' failed 02/06/2019 04:53:43: prof: ERR: Unable to reconnect, account no longer exists: (null) To solve it, don't clear the saved data in session_disconnect(). It will be cleared properly on connection loss if reconnect timer is not configured. But won't be cleared with /disconnect command. So, after /disconnect the data will live in memory until the next /connect. Also, remove some copy-paste in connection loss path.
This commit is contained in:
parent
5b4277840a
commit
4344ee2a5a
@ -113,14 +113,11 @@ session_connect_with_account(const ProfAccount *const account)
|
|||||||
|
|
||||||
log_info("Connecting using account: %s", account->name);
|
log_info("Connecting using account: %s", account->name);
|
||||||
|
|
||||||
|
_session_free_saved_account();
|
||||||
|
_session_free_saved_details();
|
||||||
|
|
||||||
// save account name and password for reconnect
|
// save account name and password for reconnect
|
||||||
if (saved_account.name) {
|
|
||||||
free(saved_account.name);
|
|
||||||
}
|
|
||||||
saved_account.name = strdup(account->name);
|
saved_account.name = strdup(account->name);
|
||||||
if (saved_account.passwd) {
|
|
||||||
free(saved_account.passwd);
|
|
||||||
}
|
|
||||||
saved_account.passwd = strdup(account->password);
|
saved_account.passwd = strdup(account->password);
|
||||||
|
|
||||||
char *jid = NULL;
|
char *jid = NULL;
|
||||||
@ -150,6 +147,9 @@ session_connect_with_details(const char *const jid, const char *const passwd, co
|
|||||||
assert(jid != NULL);
|
assert(jid != NULL);
|
||||||
assert(passwd != NULL);
|
assert(passwd != NULL);
|
||||||
|
|
||||||
|
_session_free_saved_account();
|
||||||
|
_session_free_saved_details();
|
||||||
|
|
||||||
// save details for reconnect, remember name for account creating on success
|
// save details for reconnect, remember name for account creating on success
|
||||||
saved_details.name = strdup(jid);
|
saved_details.name = strdup(jid);
|
||||||
saved_details.passwd = strdup(passwd);
|
saved_details.passwd = strdup(passwd);
|
||||||
@ -196,20 +196,6 @@ session_connect_with_details(const char *const jid, const char *const passwd, co
|
|||||||
void
|
void
|
||||||
session_autoping_fail(void)
|
session_autoping_fail(void)
|
||||||
{
|
{
|
||||||
if (connection_get_status() == JABBER_CONNECTED) {
|
|
||||||
log_info("Closing connection");
|
|
||||||
|
|
||||||
char *account_name = session_get_account_name();
|
|
||||||
const char *fulljid = connection_get_fulljid();
|
|
||||||
plugins_on_disconnect(account_name, fulljid);
|
|
||||||
|
|
||||||
accounts_set_last_activity(session_get_account_name());
|
|
||||||
|
|
||||||
connection_disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
connection_set_disconnected();
|
|
||||||
|
|
||||||
session_lost_connection();
|
session_lost_connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +216,7 @@ session_disconnect(void)
|
|||||||
|
|
||||||
connection_disconnect();
|
connection_disconnect();
|
||||||
|
|
||||||
_session_free_saved_account();
|
|
||||||
_session_free_saved_details();
|
|
||||||
|
|
||||||
connection_clear_data();
|
connection_clear_data();
|
||||||
|
|
||||||
chat_sessions_clear();
|
chat_sessions_clear();
|
||||||
presence_clear_sub_requests();
|
presence_clear_sub_requests();
|
||||||
}
|
}
|
||||||
@ -359,6 +341,7 @@ session_login_failed(void)
|
|||||||
void
|
void
|
||||||
session_lost_connection(void)
|
session_lost_connection(void)
|
||||||
{
|
{
|
||||||
|
/* this callback also clears all cached data */
|
||||||
sv_ev_lost_connection();
|
sv_ev_lost_connection();
|
||||||
if (prefs_get_reconnect() != 0) {
|
if (prefs_get_reconnect() != 0) {
|
||||||
assert(reconnect_timer == NULL);
|
assert(reconnect_timer == NULL);
|
||||||
@ -367,10 +350,6 @@ session_lost_connection(void)
|
|||||||
_session_free_saved_account();
|
_session_free_saved_account();
|
||||||
_session_free_saved_details();
|
_session_free_saved_details();
|
||||||
}
|
}
|
||||||
|
|
||||||
connection_clear_data();
|
|
||||||
chat_sessions_clear();
|
|
||||||
presence_clear_sub_requests();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user