Avoid double locking with start_sig

This commit is contained in:
RipleyTom 2020-09-25 12:45:38 +02:00 committed by Ivan
parent abaa8f855f
commit 344c813eb1
3 changed files with 9 additions and 2 deletions

View File

@ -4468,7 +4468,7 @@ error_code sceNpSignalingGetCtxOpt(u32 ctx_id, s32 optname, vm::ptr<s32> optval)
error_code sceNpSignalingActivateConnection(u32 ctx_id, vm::ptr<SceNpId> npId, vm::ptr<u32> conn_id)
{
sceNp.warning("sceNpSignalingActivateConnection(ctx_id=%d, npId=*0x%x, conn_id=%d)", ctx_id, npId, conn_id);
sceNp.warning("sceNpSignalingActivateConnection(ctx_id=%d, npId=*0x%x, conn_id=*0x%x)", ctx_id, npId, conn_id);
const auto nph = g_fxo->get<named_thread<np_handler>>();

View File

@ -503,7 +503,11 @@ std::shared_ptr<signaling_info> signaling_handler::get_signaling_ptr(const signa
void signaling_handler::start_sig(u32 conn_id, u32 addr, u16 port)
{
std::lock_guard lock(data_mutex);
start_sig_nl(conn_id, addr, port);
}
void signaling_handler::start_sig_nl(u32 conn_id, u32 addr, u16 port)
{
auto& sent_packet = sig1_packet;
sent_packet.command = signal_connect;
@ -593,7 +597,7 @@ u32 signaling_handler::init_sig_infos(const SceNpId* npid)
{
sign_log.trace("Activating already peer activated connection");
sig1_peers[conn_id]->ext_status = ext_sign_mutual;
start_sig(conn_id, sig1_peers[conn_id]->addr, sig1_peers[conn_id]->port);
start_sig_nl(conn_id, sig1_peers[conn_id]->addr, sig1_peers[conn_id]->port);
signal_sig_callback(conn_id, SCE_NP_SIGNALING_EVENT_ESTABLISHED);
signal_ext_sig_callback(conn_id, SCE_NP_SIGNALING_EVENT_EXT_MUTUAL_ACTIVATED);
}

View File

@ -123,6 +123,9 @@ private:
void signal_ext_sig_callback(u32 conn_id, int event);
void signal_sig2_callback(u64 room_id, u16 member_id, SceNpMatching2Event event);
private:
void start_sig_nl(u32 conn_id, u32 addr, u16 port);
private:
bool validate_signaling_packet(const signaling_packet* sp);
void reschedule_packet(std::shared_ptr<signaling_info>& si, SignalingCommand cmd, std::chrono::time_point<std::chrono::system_clock> new_timepoint);