implement ares_set_server_state_callback#314
Open
Vizonex wants to merge 7 commits into
Open
Conversation
saghul
reviewed
May 23, 2026
|
|
||
| userdata = _ffi.new_handle(callback) | ||
| self._server_state_cb_handle = userdata | ||
| _lib.ares_set_server_state_callback(self._channel[0], _lib._server_state_cb, userdata) |
Owner
There was a problem hiding this comment.
Take the channel lock before operating on it.
| @_ffi.def_extern() | ||
| def _server_state_cb(server_string, success, flags, data): | ||
| # same behavior as a socket state callback | ||
| server_state_cb = _ffi.from_handle(data) |
Owner
There was a problem hiding this comment.
I suspect we need to put it in the shutdown queue just like the socket state callback, since its lifetime is tied with the channel.
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.
I thought this would be a good function to implement here and I have a similar idea for cyares also.
This function enables tracing server callbacks and figuring out which server succeeded and which ones do not and they enable seeing what protocol was used such as TCP or UDP.
Some more information on
ares_set_server_state_callbackcan be found in the documentation. I this think would also do well with aiodns where the loop can create an asynchronous task for it when it has been called but I'll implement that in after pycares gets another update.