diff options
author | Luboš Doležel <lubos@dolezel.info> | 2020-02-23 09:39:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 09:39:38 +0100 |
commit | 54182649a76f729de853187f455878a40b49d4df (patch) | |
tree | a94b69892c40bf7f89471c0e6b116116c2956d3a /src | |
parent | fb3ce9952b04259b04d33587e19cdf344dae3a26 (diff) | |
parent | cedd7a19a4fb415031b97592129214d2163563aa (diff) | |
download | twinkle-54182649a76f729de853187f455878a40b49d4df.tar twinkle-54182649a76f729de853187f455878a40b49d4df.tar.gz twinkle-54182649a76f729de853187f455878a40b49d4df.tar.lz twinkle-54182649a76f729de853187f455878a40b49d4df.tar.xz twinkle-54182649a76f729de853187f455878a40b49d4df.zip |
Merge pull request #150 from fbriere/issue/88-mutex-lock-failed
Prevent recursive locking of phone_users_mtx in add_phone_user()
Diffstat (limited to 'src')
-rw-r--r-- | src/phone.cpp | 8 | ||||
-rw-r--r-- | src/phone.h | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/phone.cpp b/src/phone.cpp index 1634de3..c97ccce 100644 --- a/src/phone.cpp +++ b/src/phone.cpp @@ -3052,7 +3052,7 @@ bool t_phone::add_phone_user(const t_user &user_config, t_user **dup_user) { // Check if there is already another profile having // the same contact name. if (user->get_contact_name() == user_config.get_contact_name() && - USER_HOST(user, AUTO_IP4_ADDRESS) == USER_HOST(&user_config, AUTO_IP4_ADDRESS) && + phone->get_ip_sip_locked(user, AUTO_IP4_ADDRESS) == phone->get_ip_sip_locked(&user_config, AUTO_IP4_ADDRESS) && (*i)->is_active()) { *dup_user = user; @@ -3158,9 +3158,13 @@ t_presence_epa *t_phone::ref_presence_epa(t_user *user) { } string t_phone::get_ip_sip(const t_user *user, const string &auto_ip) const { + t_rwmutex_reader x(phone_users_mtx); + return get_ip_sip_locked(user, auto_ip); +} + +string t_phone::get_ip_sip_locked(const t_user *user, const string &auto_ip) const { string result; - t_rwmutex_reader x(phone_users_mtx); t_phone_user *pu = find_phone_user(user->get_profile_name()); if (pu) { result = pu->get_ip_sip(auto_ip); diff --git a/src/phone.h b/src/phone.h index 771db3b..52217eb 100644 --- a/src/phone.h +++ b/src/phone.h @@ -256,6 +256,8 @@ protected: */ t_line *find_line_in_dialog_request(t_request *r, t_tid tid); + // Variation of get_ip_sip() for when phone_users_mtx is already locked + string get_ip_sip_locked(const t_user *user, const string &auto_ip) const; // Events void recvd_provisional(t_response *r, t_tuid tuid, t_tid tid); void recvd_success(t_response *r, t_tuid tuid, t_tid tid); |