Skip to content

implement ares_set_server_state_callback#314

Open
Vizonex wants to merge 7 commits into
saghul:masterfrom
Vizonex:server-state-cb
Open

implement ares_set_server_state_callback#314
Vizonex wants to merge 7 commits into
saghul:masterfrom
Vizonex:server-state-cb

Conversation

@Vizonex

@Vizonex Vizonex commented May 22, 2026

Copy link
Copy Markdown
Contributor

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_callback can 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.

Comment thread src/pycares/__init__.py Outdated

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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take the channel lock before operating on it.

Comment thread src/pycares/__init__.py
@_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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants