1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

varlink: add varlink_close_unref() helper

This commit is contained in:
Lennart Poettering 2019-05-28 14:18:49 +02:00
parent e10720818e
commit 9652d74092
2 changed files with 11 additions and 1 deletions

View File

@ -1193,6 +1193,15 @@ int varlink_close(Varlink *v) {
return 1; return 1;
} }
Varlink* varlink_close_unref(Varlink *v) {
if (!v)
return NULL;
(void) varlink_close(v);
return varlink_unref(v);
}
Varlink* varlink_flush_close_unref(Varlink *v) { Varlink* varlink_flush_close_unref(Varlink *v) {
if (!v) if (!v)
@ -1200,7 +1209,6 @@ Varlink* varlink_flush_close_unref(Varlink *v) {
(void) varlink_flush(v); (void) varlink_flush(v);
(void) varlink_close(v); (void) varlink_close(v);
return varlink_unref(v); return varlink_unref(v);
} }

View File

@ -73,6 +73,7 @@ int varlink_flush(Varlink *v);
int varlink_close(Varlink *v); int varlink_close(Varlink *v);
Varlink* varlink_flush_close_unref(Varlink *v); Varlink* varlink_flush_close_unref(Varlink *v);
Varlink* varlink_close_unref(Varlink *v);
/* Enqueue method call, not expecting a reply */ /* Enqueue method call, not expecting a reply */
int varlink_send(Varlink *v, const char *method, JsonVariant *parameters); int varlink_send(Varlink *v, const char *method, JsonVariant *parameters);
@ -152,6 +153,7 @@ int varlink_server_set_connections_max(VarlinkServer *s, unsigned m);
int varlink_server_set_description(VarlinkServer *s, const char *description); int varlink_server_set_description(VarlinkServer *s, const char *description);
DEFINE_TRIVIAL_CLEANUP_FUNC(Varlink *, varlink_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Varlink *, varlink_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(Varlink *, varlink_close_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(Varlink *, varlink_flush_close_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(Varlink *, varlink_flush_close_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(VarlinkServer *, varlink_server_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(VarlinkServer *, varlink_server_unref);