Skip to content

Commit

Permalink
Prevent busy-waiting in active wait during 'listener_del'
Browse files Browse the repository at this point in the history
Since the operation of stopping each worker thread listeners is
performed during 'maintenance_loops', the active wait taking place in
'listener_del' is likely to take some time. A sensible delay has been
added to reduce unneccesary load.
  • Loading branch information
JavierJF committed Nov 22, 2024
1 parent 9c56faf commit 8774b31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,11 @@ int MySQL_Threads_Handler::listener_del(const char *iface) {
}
for (i=0;i<num_threads;i++) {
MySQL_Thread *thr=(MySQL_Thread *)mysql_threads[i].worker;
while(__sync_fetch_and_add(&thr->mypolls.pending_listener_del,0));
while(__sync_fetch_and_add(&thr->mypolls.pending_listener_del,0)) {
// Since 'listeners_stop' is performed in 'maintenance_loops' by the
// workers this active-wait is likely to take some time.
usleep(std::min(std::max(mysql_thread___poll_timeout/20, 10000), 40000));
}
}
MLM->del(idx);
#ifdef SO_REUSEPORT
Expand Down

0 comments on commit 8774b31

Please sign in to comment.