mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
sd-resolve: introduce sd_resolve_query_{get,set}_destroy_callback()
This commit is contained in:
parent
201bf07f7c
commit
a8319dea1d
@ -94,6 +94,7 @@ struct sd_resolve_query {
|
||||
};
|
||||
|
||||
void *userdata;
|
||||
sd_resolve_destroy_t destroy_callback;
|
||||
|
||||
LIST_FIELDS(sd_resolve_query, queries);
|
||||
};
|
||||
@ -1095,6 +1096,9 @@ static sd_resolve_query *resolve_query_free(sd_resolve_query *q) {
|
||||
|
||||
resolve_query_disconnect(q);
|
||||
|
||||
if (q->destroy_callback)
|
||||
q->destroy_callback(q->userdata);
|
||||
|
||||
resolve_freeaddrinfo(q->addrinfo);
|
||||
free(q->host);
|
||||
free(q->serv);
|
||||
@ -1137,6 +1141,22 @@ _public_ sd_resolve *sd_resolve_query_get_resolve(sd_resolve_query *q) {
|
||||
return q->resolve;
|
||||
}
|
||||
|
||||
_public_ int sd_resolve_query_get_destroy_callback(sd_resolve_query *q, sd_resolve_destroy_t *destroy_callback) {
|
||||
assert_return(q, -EINVAL);
|
||||
|
||||
if (destroy_callback)
|
||||
*destroy_callback = q->destroy_callback;
|
||||
|
||||
return !!q->destroy_callback;
|
||||
}
|
||||
|
||||
_public_ int sd_resolve_query_set_destroy_callback(sd_resolve_query *q, sd_resolve_destroy_t destroy_callback) {
|
||||
assert_return(q, -EINVAL);
|
||||
|
||||
q->destroy_callback = destroy_callback;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
sd_resolve *resolve = userdata;
|
||||
int r;
|
||||
|
@ -42,6 +42,7 @@ typedef struct sd_resolve_query sd_resolve_query;
|
||||
/* A callback on completion */
|
||||
typedef int (*sd_resolve_getaddrinfo_handler_t)(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata);
|
||||
typedef int (*sd_resolve_getnameinfo_handler_t)(sd_resolve_query *q, int ret, const char *host, const char *serv, void *userdata);
|
||||
typedef void (*sd_resolve_destroy_t)(void *userdata);
|
||||
|
||||
enum {
|
||||
SD_RESOLVE_GET_HOST = 1 << 0,
|
||||
@ -108,6 +109,8 @@ int sd_resolve_query_is_done(sd_resolve_query*q);
|
||||
|
||||
void *sd_resolve_query_get_userdata(sd_resolve_query *q);
|
||||
void *sd_resolve_query_set_userdata(sd_resolve_query *q, void *userdata);
|
||||
int sd_resolve_query_get_destroy_callback(sd_resolve_query *q, sd_resolve_destroy_t *destroy_callback);
|
||||
int sd_resolve_query_set_destroy_callback(sd_resolve_query *q, sd_resolve_destroy_t destroy_callback);
|
||||
|
||||
sd_resolve *sd_resolve_query_get_resolve(sd_resolve_query *q);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user