Skip to content

Commit

Permalink
lock/unlock reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Aug 7, 2023
1 parent 1bb095a commit ee0b0d4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ void tcp::packet_handler(packet *const pkt)

bool delete_entry = false;

bool notify_unacked_cv = false;

do
{
bool notify_unacked_cv = false;

std::shared_lock<std::shared_mutex> lck(sessions_lock);

auto cur_it = sessions.find(id);
Expand Down Expand Up @@ -692,6 +692,12 @@ void tcp::packet_handler(packet *const pkt)

if (delete_entry)
cur_session->set_is_terminating();

if (notify_unacked_cv) {
unacked_cv_mem = true;

unacked_cv.notify_one();
}
}
while(0);

Expand Down Expand Up @@ -730,11 +736,6 @@ void tcp::packet_handler(packet *const pkt)
}

delete pkt;

if (notify_unacked_cv) {
unacked_cv_mem = true;
unacked_cv.notify_one();
}
}

void tcp::session_cleaner()
Expand Down

0 comments on commit ee0b0d4

Please sign in to comment.