summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-05-28 14:18:49 +0200
committerLennart Poettering <lennart@poettering.net>2019-12-17 20:05:46 +0100
commit9652d740929f9975ee466948a7e3cd428ef1ff5c (patch)
tree55964f89b97ebb57d3c5bf9910a37396502205f9 /src/shared
parente10720818ec36021bc82767d68ec84377ed23221 (diff)
downloadsystemd-9652d740929f9975ee466948a7e3cd428ef1ff5c.tar.gz
varlink: add varlink_close_unref() helper
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/varlink.c10
-rw-r--r--src/shared/varlink.h2
2 files changed, 11 insertions, 1 deletions
diff --git a/src/shared/varlink.c b/src/shared/varlink.c
index e1d956e649..77cea00cb9 100644
--- a/src/shared/varlink.c
+++ b/src/shared/varlink.c
@@ -1193,6 +1193,15 @@ int varlink_close(Varlink *v) {
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) {
if (!v)
@@ -1200,7 +1209,6 @@ Varlink* varlink_flush_close_unref(Varlink *v) {
(void) varlink_flush(v);
(void) varlink_close(v);
-
return varlink_unref(v);
}
diff --git a/src/shared/varlink.h b/src/shared/varlink.h
index 0208802010..0d9617d403 100644
--- a/src/shared/varlink.h
+++ b/src/shared/varlink.h
@@ -73,6 +73,7 @@ int varlink_flush(Varlink *v);
int varlink_close(Varlink *v);
Varlink* varlink_flush_close_unref(Varlink *v);
+Varlink* varlink_close_unref(Varlink *v);
/* Enqueue method call, not expecting a reply */
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);
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(VarlinkServer *, varlink_server_unref);