Fixed a crash related to the whisper system and some minor updates

This commit is contained in:
WolverinDEV 2020-12-19 10:52:24 +01:00
parent 0cff59328f
commit ccd0f7fcfd
5 changed files with 19 additions and 8 deletions

2
rtclib

@ -1 +1 @@
Subproject commit 7f1e1387fcfffd7e82bd51c3a3e0c7f38dcfdd6e
Subproject commit d5a085254595fddc0520de21a75402b43c39f608

View File

@ -676,25 +676,30 @@ bool ConnectedClient::notifyChannelEdited(
if(!v_channel) return false; //Not visible? Important do not remove!
bool send_description_change{false};
size_t property_count{0};
Command notify("notifychanneledited");
for(auto prop : properties) {
const auto& prop_info = property::describe(prop);
if(prop == property::CHANNEL_ORDER)
if(prop == property::CHANNEL_ORDER) {
notify[prop_info.name] = v_channel->previous_channel;
else if(prop == property::CHANNEL_DESCRIPTION) {
property_count++;
} else if(prop == property::CHANNEL_DESCRIPTION) {
send_description_change = true;
} else {
notify[prop_info.name] = channel->properties()[prop].as<string>();
property_count++;
}
}
notify["cid"] = channel->channelId();
notify["reasonid"] = ViewReasonId::VREASON_EDITED;
if(property_count > 0) {
notify["cid"] = channel->channelId();
notify["reasonid"] = ViewReasonId::VREASON_EDITED;
INVOKER(notify, invoker);
this->sendCommand(notify);
INVOKER(notify, invoker);
this->sendCommand(notify);
}
if(send_description_change) {
Command notify_dchange{"notifychanneldescriptionchanged"};

View File

@ -1436,6 +1436,7 @@ ts::command_result ConnectedClient::execute_channel_edit(ChannelId& channel_id,
case property::CHANNEL_CODEC_QUALITY:
case property::CHANNEL_CODEC_IS_UNENCRYPTED:
case property::CHANNEL_DELETE_DELAY:
case property::CHANNEL_SIDEBAR_MODE:
break;
case property::CHANNEL_PASSWORD:
@ -1500,7 +1501,7 @@ ts::command_result ConnectedClient::execute_channel_edit(ChannelId& channel_id,
break;
default:
logCritical(this->getServerId(), "{} Channel property {} reached context validation context but we don't know how to handle it. Please report this bug!", property::describe(key).name);
logCritical(this->getServerId(), "{} Channel property {} reached context validation context but we don't know how to handle it. Please report this bug!", CLIENT_LOG_PREFIX, property::describe(key).name);
continue;
}

View File

@ -18,6 +18,8 @@ WhisperHandler::~WhisperHandler() {
}
bool WhisperHandler::validate_whisper_packet(const protocol::ClientPacketParser &packet, bool& match_last_header, void *&payload_ptr, size_t &payload_length) {
std::lock_guard process_lock{this->whisper_head_mutex};
size_t head_length;
if(packet.flags() & protocol::PacketFlag::NewProtocol) {
if(packet.payload_length() < 3 + 10) {
@ -163,6 +165,8 @@ void WhisperHandler::signal_session_reset() {
}
void WhisperHandler::handle_session_reset() {
std::lock_guard process_lock{this->whisper_head_mutex};
this->session_state = SessionState::Uninitialized;
if(this->whisper_head_ptr) {
::free(this->whisper_head_ptr);

View File

@ -61,6 +61,7 @@ namespace ts::server::whisper {
SessionState session_state{SessionState::Uninitialized};
std::chrono::system_clock::time_point session_timestamp{};
std::mutex whisper_head_mutex{};
void* whisper_head_ptr{nullptr};
size_t whisper_head_length{0};
size_t whisper_head_capacity{0};