From 77f05f77b497b1d69e8107caefd6d19fa9c609ab Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 6 Apr 2017 23:25:02 +0300 Subject: jabber: omemo: working on 4.4 implemented sessions cleanup on exit --- protocols/JabberG/src/jabber_omemo.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'protocols/JabberG/src/jabber_omemo.cpp') diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 4e2472ff75..5a4c38fce7 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -545,7 +545,16 @@ namespace omemo { session_cipher *cipher; signal_protocol_store_context *store_context; }; - std::map omemo_sessions; + std::map sessions_internal; + void clean_sessions() + { + for (std::map::iterator i = sessions_internal.begin(), end = sessions_internal.end(); i != end; ++i) + { + session_cipher_free(i->second.cipher); + session_builder_free(i->second.builder); + signal_protocol_store_context_destroy(i->second.store_context); + } + } //signal_protocol_session_store callbacks follow /* @@ -720,7 +729,7 @@ db_get_blob sip.user_data = (void*)hContact; signal_protocol_store_context_set_identity_key_store(store_context, &sip); - omemo_sessions[hContact].store_context = store_context; + sessions_internal[hContact].store_context = store_context; return true; //success } @@ -734,9 +743,9 @@ db_get_blob }; session_builder *builder; - session_builder_create(&builder, omemo_sessions[hContact].store_context, &address, global_context); + session_builder_create(&builder, sessions_internal[hContact].store_context, &address, global_context); - omemo_sessions[hContact].builder = builder; + sessions_internal[hContact].builder = builder; mir_free(jid_str); @@ -756,8 +765,8 @@ db_get_blob /* Create the session cipher and encrypt the message */ session_cipher *cipher; - session_cipher_create(&cipher, omemo_sessions[hContact].store_context, &address, global_context); - omemo_sessions[hContact].cipher = cipher; + session_cipher_create(&cipher, sessions_internal[hContact].store_context, &address, global_context); + sessions_internal[hContact].cipher = cipher; return true; //success -- cgit v1.2.3