diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-04 01:05:16 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-05 13:19:02 +0900 |
commit | b3ae7237c6cc84953759280ab3fd95933ede7390 (patch) | |
tree | df3f7e714fd395dbbe206d321a554f4e0dbe28e1 /src | |
parent | a8319dea1d34f4117ea57ea32d85e0eb528358d0 (diff) | |
download | systemd-b3ae7237c6cc84953759280ab3fd95933ede7390.tar.gz |
sd-resolve: introduce sd_resolve_query_{get,set}_floating()
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-resolve/sd-resolve.c | 28 | ||||
-rw-r--r-- | src/systemd/sd-resolve.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index dd33314f53..1fbab9dbf9 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -1157,6 +1157,34 @@ _public_ int sd_resolve_query_set_destroy_callback(sd_resolve_query *q, sd_resol return 0; } +_public_ int sd_resolve_query_get_floating(sd_resolve_query *q) { + assert_return(q, -EINVAL); + + return q->floating; +} + +_public_ int sd_resolve_query_set_floating(sd_resolve_query *q, int b) { + assert_return(q, -EINVAL); + + if (q->floating == !!b) + return 0; + + if (!q->resolve) /* Already disconnected */ + return -ESTALE; + + q->floating = b; + + if (b) { + sd_resolve_query_ref(q); + sd_resolve_unref(q->resolve); + } else { + sd_resolve_ref(q->resolve); + sd_resolve_query_unref(q); + } + + return 1; +} + static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) { sd_resolve *resolve = userdata; int r; diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h index 2696562d77..089fcdee37 100644 --- a/src/systemd/sd-resolve.h +++ b/src/systemd/sd-resolve.h @@ -111,6 +111,8 @@ 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); +int sd_resolve_query_get_floating(sd_resolve_query *q); +int sd_resolve_query_set_floating(sd_resolve_query *q, int b); sd_resolve *sd_resolve_query_get_resolve(sd_resolve_query *q); |