diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 9310128d62ba447d267035b7eaf2b129e0b42629..46347fb28208a11d0156e4e7cce79a35107e85f0 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -231,7 +231,14 @@ public: wrappedObject->weakCppPtr.~weak_ptr(); } - template <typename CType, + template<typename CppType> + static bool isOwnedByC(void *cObject){ + WrappedBaseObject<CppType> *base = static_cast<WrappedBaseObject<CppType>*>(cObject); + return base->owner == WrappedObjectOwner::External; + } + + template< + typename CType, typename CppType = typename CTypeMetaInfo<CType>::cppType, typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type> static void uninitClonableCppObject(CType *cObject) { diff --git a/src/chat/chat-room/server-group-chat-room-p.h b/src/chat/chat-room/server-group-chat-room-p.h index 0a46c9ee86e28342c7616debb032d0d1f5808a9c..f8767c56ceadc842822d40a59132e4e16e44e693 100644 --- a/src/chat/chat-room/server-group-chat-room-p.h +++ b/src/chat/chat-room/server-group-chat-room-p.h @@ -193,12 +193,10 @@ private: std::map<std::string, RegistrationSubscriptionContext> registrationSubscriptions; /*map of registrationSubscriptions for each participant*/ int unnotifiedRegistrationSubscriptions = 0; /*count of not-yet notified registration subscriptions*/ - std::shared_ptr<ParticipantDevice> - mInitiatorDevice; /*pointer to the ParticipantDevice that is creating the chat room*/ - bool joiningPendingAfterCreation = false; - bool needsUnref = false; + std::shared_ptr<ParticipantDevice> mInitiatorDevice; /*pointer to the ParticipantDevice that is creating the chat room*/ std::unordered_map<std::string, std::queue<std::shared_ptr<Message>>> queuedMessages; Utils::Version protocolVersion; + bool joiningPendingAfterCreation = false; L_DECLARE_PUBLIC(ServerGroupChatRoom); }; diff --git a/src/chat/chat-room/server-group-chat-room.cpp b/src/chat/chat-room/server-group-chat-room.cpp index caec26bec5ef037e2b83a18a21650e1fba7f7be4..0f9546a883e3464d7732a452678039024503181f 100644 --- a/src/chat/chat-room/server-group-chat-room.cpp +++ b/src/chat/chat-room/server-group-chat-room.cpp @@ -223,12 +223,13 @@ void ServerGroupChatRoomPrivate::requestDeletion() { * to make the self-destruction outside of the call stack that leaded to it. * TODO: remove this after switching chatrooms to HybridObject. */ - if (needsUnref) { - LinphoneChatRoom *cChatRoom = L_GET_C_BACK_PTR(chatRoom); - /* If the chatroom was created as "external" mode, explicitely unref the C object to destroy it.*/ - if (cChatRoom) { - q->getCore()->doLater([cChatRoom]() { linphone_chat_room_unref(cChatRoom); }); - } + + LinphoneChatRoom *cChatRoom = L_GET_C_BACK_PTR(chatRoom); + /* If the chatroom was created as "external" mode, explicitely unref the C object to destroy it.*/ + if (cChatRoom && Wrapper::isOwnedByC<ServerGroupChatRoom>(cChatRoom)){ + q->getCore()->doLater([cChatRoom](){ + linphone_chat_room_unref(cChatRoom); + }); } } @@ -1270,6 +1271,10 @@ void ServerGroupChatRoomPrivate::onBye(const shared_ptr<ParticipantDevice> &part bool ServerGroupChatRoomPrivate::dispatchMessagesAfterFullState(const shared_ptr<CallSession> &session) const { L_Q(); auto device = q->findCachedParticipantDevice(session); + if (!device) { + lWarning() << q << " dispatchMessagesAfterFullState on unknown device."; + return false; // Assume it is a recent device. + } return dispatchMessagesAfterFullState(device); } @@ -1425,12 +1430,6 @@ ServerGroupChatRoom::ServerGroupChatRoom(const shared_ptr<Core> &core, SalCallOp session->configure(LinphoneCallIncoming, nullptr, op, from, to); d->protocolVersion = CorePrivate::groupChatProtocolVersion; - /* - * HACK: see comment in ServerGroupChatRoomPrivate::requestDeletion() for details. - * When this constructor is used, a reference to the C object is given to the core. - * Thus, remember that it will have to be released. - */ - d->needsUnref = true; } ServerGroupChatRoom::ServerGroupChatRoom(const shared_ptr<Core> &core, diff --git a/tester/tester.c b/tester/tester.c index 58aee4bdb627d8f859dc81b8b564e43ffbab2a85..ca36c07dd6fc033085ef1e52b698283394de539f 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -86,7 +86,8 @@ const MSAudioDiffParams audio_cmp_params = {10, 200}; /* Default test server infrastructure. You may change to sandbox infrastructure to test changes to the infrastructure * first. */ -const char *flexisip_tester_dns_server = "fs-test-3.linphone.org"; +const char *flexisip_tester_dns_server = "fs-test-7.linphone.org"; + // const char* flexisip_tester_dns_server = "fs-test-sandbox.linphone.org"; bctbx_list_t *flexisip_tester_dns_ip_addresses = NULL;