Subject: Enhancement for sock_state_cb and sock_create_cb - allow to use user data

Enhancement for sock_state_cb and sock_create_cb - allow to use user data

From: <daniel_at_poradnik-webmastera.com>
Date: Mon, 21 Sep 2015 18:11:51 +0200

Hi,
I am trying to integrate c-ares with our application. Currently user
can specify any data pointer when registering callbacks for sock_state
and sock_create events, what is good if you use any wrapper classes or
something like this. Unfortunately this does not cover case when code
uses wrappers for socket descriptors, and this is my case. I can
create new socket wrapper in sock_create callback but cannot return it
- I have to store it locally in map in channel wrapper object. Later
when sock_state callback is called, I have to search map for my
wrapper object to do further processing.

Because of this I am proposing new enhancement for these callbacks:
allow to return extra pointer from sock_create callback, and then pass
it to sock_state callback.

In order to be backward compatible some extra code would be needed. I
propose adding new ARES_FLAG for this - if it will be specified, new
callback types (with extra arg) will be used. If not, code will use
current ones.

What do you think about this?

Regards,
Daniel
Received on 2015-09-21