diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-16 12:35:37 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-16 12:35:37 +0300 |
commit | eb84e01cdc1c9558f06a6cc99848d54fe19dc004 (patch) | |
tree | 913344f3a8b82b47c8732a454476306d227c349f /protocols | |
parent | 4ef73611c5a7ced80710666dd35131e8b6c8c219 (diff) |
fixes #2065 (Jabber: race condition in status changing)
Diffstat (limited to 'protocols')
-rwxr-xr-x | protocols/JabberG/src/jabber_misc.cpp | 8 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index ed77e4595a..f41edad6c6 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -207,8 +207,10 @@ void CJabberProto::ResolveTransportNicks(const char *jid) void CJabberProto::SetServerStatus(int iNewStatus)
{
- if (!m_bJabberOnline)
+ if (!m_bJabberOnline) {
+ m_iDesiredStatus = m_iStatus;
return;
+ }
// change status
int oldStatus = m_iStatus;
@@ -230,8 +232,10 @@ void CJabberProto::SetServerStatus(int iNewStatus) return;
}
- if (m_iStatus == oldStatus)
+ if (m_iStatus == oldStatus) {
+ m_iDesiredStatus = m_iStatus;
return;
+ }
// send presence update
SendPresence(m_iStatus, true);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 752ae2cda8..3ac61aec58 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -1118,8 +1118,11 @@ int CJabberProto::SetStatus(int iNewStatus) }
else if (m_bJabberOnline)
SetServerStatus(iNewStatus);
- else
- ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ else {
+ // race condition: old thread is dying, but we're already offline. report failure
+ m_iDesiredStatus = oldStatus;
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)oldStatus, m_iStatus);
+ }
return 0;
}
|