Fix polling ares_event_configchg_init: initialize mutex - #974
Merged
Conversation
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used.
Member
|
thanks, interesting this mutex initialization was missed. Guess this wasn't well tested on platforms outside of Windows/Linux/MacOS since none of those use this polling logic. |
Member
|
If you update your branch the CI builds should work. |
bradh352
pushed a commit
that referenced
this pull request
Apr 8, 2025
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
bradh352
pushed a commit
that referenced
this pull request
Apr 8, 2025
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
bradh352
pushed a commit
that referenced
this pull request
Apr 8, 2025
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
bradh352
pushed a commit
that referenced
this pull request
Apr 8, 2025
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
bradh352
pushed a commit
that referenced
this pull request
Apr 8, 2025
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
Contributor
Author
|
Thanks for merging @bradh352! |
michael-dev
pushed a commit
to HamelinPorts/android_external_c-ares
that referenced
this pull request
Apr 25, 2026
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
michael-dev
pushed a commit
to HamelinPorts/android_external_c-ares
that referenced
this pull request
Apr 25, 2026
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
michael-dev
pushed a commit
to HamelinPorts/android_external_c-ares
that referenced
this pull request
Apr 25, 2026
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
michael-dev
pushed a commit
to HamelinPorts/android_external_c-ares
that referenced
this pull request
Apr 25, 2026
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
michael-dev
pushed a commit
to HamelinPorts/android_external_c-ares
that referenced
this pull request
Apr 25, 2026
The polling-based implementation of ares_event_configchg_init previously did not initialize the mutex ares_event_configchg_t->lock. This caused ares_thread_cond_timedwait to immediately return, which means that the thread running ares_event_configchg_thread is busy-waiting without sleeping between config change checks. In addition to the high CPU usage this causes, the DNS config is actually never checked in this case. This commit fixes the issue by initializing the mutex. Thereby, the config polling thread correctly only wakes up every 30 seconds and properly checks for a config change. Note: the bug only came into effect if the combination of the polling- based implementation of ares_event_configchg_init and the pthread-based implementation of ares_thread_cond_timedwait was used. Fix By: Florian Pfisterer (@FlorianPfisterer)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The polling-based implementation of ares_event_configchg_init previously
did not initialize the mutex ares_event_configchg_t->lock. This caused
ares_thread_cond_timedwait to immediately return, which means that the
thread running ares_event_configchg_thread is busy-waiting without
sleeping between config change checks. In addition to the high CPU usage
this causes, the DNS config is actually never checked in this case.
This commit fixes the issue by initializing the mutex. Thereby, the
config polling thread correctly only wakes up every 30 seconds and
properly checks for a config change.
Note: the bug only came into effect if the combination of the polling-
based implementation of ares_event_configchg_init and the pthread-based
implementation of ares_thread_cond_timedwait was used.