!499 同步上游社区补丁
From: @hongjinghao Reviewed-by: @licunlong Signed-off-by: @licunlong
This commit is contained in:
commit
2af0ecafd1
36
backport-json-use-unsigned-for-refernce-counter.patch
Normal file
36
backport-json-use-unsigned-for-refernce-counter.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
From 6dd18b34cf53ab663140f43f8814904c71cc29f7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 06:46:25 +0900
|
||||||
|
Subject: [PATCH] json: use unsigned for refernce counter
|
||||||
|
|
||||||
|
For other places, we use unsigned for reference counter.
|
||||||
|
|
||||||
|
---
|
||||||
|
src/shared/json.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/shared/json.c b/src/shared/json.c
|
||||||
|
index dff95eda26..f66b7df24c 100644
|
||||||
|
--- a/src/shared/json.c
|
||||||
|
+++ b/src/shared/json.c
|
||||||
|
@@ -41,7 +41,7 @@ assert_cc(DEPTH_MAX <= UINT16_MAX);
|
||||||
|
|
||||||
|
typedef struct JsonSource {
|
||||||
|
/* When we parse from a file or similar, encodes the filename, to indicate the source of a json variant */
|
||||||
|
- size_t n_ref;
|
||||||
|
+ unsigned n_ref;
|
||||||
|
unsigned max_line;
|
||||||
|
unsigned max_column;
|
||||||
|
char name[];
|
||||||
|
@@ -53,7 +53,7 @@ struct JsonVariant {
|
||||||
|
/* We either maintain a reference counter for this variant itself, or we are embedded into an
|
||||||
|
* array/object, in which case only that surrounding object is ref-counted. (If 'embedded' is false,
|
||||||
|
* see below.) */
|
||||||
|
- size_t n_ref;
|
||||||
|
+ unsigned n_ref;
|
||||||
|
|
||||||
|
/* If this JsonVariant is part of an array/object, then this field points to the surrounding
|
||||||
|
* JSON_VARIANT_ARRAY/JSON_VARIANT_OBJECT object. (If 'embedded' is true, see below.) */
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
31
backport-macro-check-over-flow-in-reference-counter.patch
Normal file
31
backport-macro-check-over-flow-in-reference-counter.patch
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
From c8431e9e35a904673cf659fd238cb63b3c3896fc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 06:54:50 +0900
|
||||||
|
Subject: [PATCH] macro: check over flow in reference counter
|
||||||
|
|
||||||
|
---
|
||||||
|
src/basic/macro.h | 8 ++++++--
|
||||||
|
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/basic/macro.h b/src/basic/macro.h
|
||||||
|
index 68d8b062e8..6e3966ff48 100644
|
||||||
|
--- a/src/basic/macro.h
|
||||||
|
+++ b/src/basic/macro.h
|
||||||
|
@@ -396,8 +396,12 @@ static inline int __coverity_check_and_return__(int condition) {
|
||||||
|
if (!p) \
|
||||||
|
return NULL; \
|
||||||
|
\
|
||||||
|
- assert(p->n_ref > 0); \
|
||||||
|
- p->n_ref++; \
|
||||||
|
+ /* For type check. */ \
|
||||||
|
+ unsigned *q = &p->n_ref; \
|
||||||
|
+ assert(*q > 0); \
|
||||||
|
+ assert(*q < UINT_MAX); \
|
||||||
|
+ \
|
||||||
|
+ (*q)++; \
|
||||||
|
return p; \
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
32
backport-sd-bus-do-not-read-unused-value.patch
Normal file
32
backport-sd-bus-do-not-read-unused-value.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From 6a7ca27740be4229b4c9f540cd610b205ca5752c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 07:25:09 +0900
|
||||||
|
Subject: [PATCH] sd-bus: do not read unused value
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/bus-track.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
index 135dfddc5f..1cbdb46f4c 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
@@ -165,13 +165,13 @@ DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_bus_track, sd_bus_track, track_free);
|
||||||
|
|
||||||
|
static int on_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||||
|
sd_bus_track *track = userdata;
|
||||||
|
- const char *name, *old, *new;
|
||||||
|
+ const char *name;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(message);
|
||||||
|
assert(track);
|
||||||
|
|
||||||
|
- r = sd_bus_message_read(message, "sss", &name, &old, &new);
|
||||||
|
+ r = sd_bus_message_read(message, "sss", &name, NULL, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
From 55bfacc6c33eaf3475762e71172b2ef504be5af8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 07:29:24 +0900
|
||||||
|
Subject: [PATCH] sd-bus: do not return negative errno when unknown name is
|
||||||
|
specified
|
||||||
|
|
||||||
|
When 'recursive' is false, then sd_bus_track_remove_name() does not
|
||||||
|
return negative errno when unknown name is specified. Let's follow the
|
||||||
|
same pattern for the case that 'recursive' is true.
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/bus-track.c | 5 +----
|
||||||
|
1 file changed, 1 insertion(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
index 1cbdb46f4c..c56bd03fc6 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
@@ -256,12 +256,9 @@ _public_ int sd_bus_track_remove_name(sd_bus_track *track, const char *name) {
|
||||||
|
if (!track) /* Treat a NULL track object as an empty track object */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- if (!track->recursive)
|
||||||
|
- return bus_track_remove_name_fully(track, name);
|
||||||
|
-
|
||||||
|
i = hashmap_get(track->names, name);
|
||||||
|
if (!i)
|
||||||
|
- return -EUNATCH;
|
||||||
|
+ return 0;
|
||||||
|
|
||||||
|
assert(i->n_ref >= 1);
|
||||||
|
if (i->n_ref <= 1)
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
From b21f237d996c8c18991a68e1204f060d07dc4745 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 07:05:07 +0900
|
||||||
|
Subject: [PATCH] sd-bus: fix reference counter to be incremented
|
||||||
|
|
||||||
|
Fixes #23097.
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/bus-track.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
index bc36673b83..891fd0c899 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
@@ -191,12 +191,12 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
||||||
|
i = hashmap_get(track->names, name);
|
||||||
|
if (i) {
|
||||||
|
if (track->recursive) {
|
||||||
|
- unsigned k = track->n_ref + 1;
|
||||||
|
+ unsigned k = i->n_ref + 1;
|
||||||
|
|
||||||
|
- if (k < track->n_ref) /* Check for overflow */
|
||||||
|
+ if (k < i->n_ref) /* Check for overflow */
|
||||||
|
return -EOVERFLOW;
|
||||||
|
|
||||||
|
- track->n_ref = k;
|
||||||
|
+ i->n_ref = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
bus_track_remove_from_queue(track);
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
From c2d7dd35d2a8cda439384a385b0c1bec804b9b79 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 07:20:16 +0900
|
||||||
|
Subject: [PATCH] sd-bus: introduce ref/unref function for track_item
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/bus-track.c | 35 ++++++++++++++-----------------
|
||||||
|
1 file changed, 16 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
index 891fd0c899..135dfddc5f 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
@@ -40,7 +40,6 @@ struct sd_bus_track {
|
||||||
|
"arg0='", name, "'")
|
||||||
|
|
||||||
|
static struct track_item* track_item_free(struct track_item *i) {
|
||||||
|
-
|
||||||
|
if (!i)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
@@ -49,7 +48,8 @@ static struct track_item* track_item_free(struct track_item *i) {
|
||||||
|
return mfree(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct track_item*, track_item_free);
|
||||||
|
+DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(struct track_item, track_item, track_item_free);
|
||||||
|
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct track_item*, track_item_unref);
|
||||||
|
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(track_item_hash_ops, char, string_hash_func, string_compare_func,
|
||||||
|
struct track_item, track_item_free);
|
||||||
|
|
||||||
|
@@ -180,7 +180,7 @@ static int on_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus
|
||||||
|
}
|
||||||
|
|
||||||
|
_public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
||||||
|
- _cleanup_(track_item_freep) struct track_item *n = NULL;
|
||||||
|
+ _cleanup_(track_item_unrefp) struct track_item *n = NULL;
|
||||||
|
struct track_item *i;
|
||||||
|
const char *match;
|
||||||
|
int r;
|
||||||
|
@@ -190,14 +190,8 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
||||||
|
|
||||||
|
i = hashmap_get(track->names, name);
|
||||||
|
if (i) {
|
||||||
|
- if (track->recursive) {
|
||||||
|
- unsigned k = i->n_ref + 1;
|
||||||
|
-
|
||||||
|
- if (k < i->n_ref) /* Check for overflow */
|
||||||
|
- return -EOVERFLOW;
|
||||||
|
-
|
||||||
|
- i->n_ref = k;
|
||||||
|
- }
|
||||||
|
+ if (track->recursive)
|
||||||
|
+ track_item_ref(i);
|
||||||
|
|
||||||
|
bus_track_remove_from_queue(track);
|
||||||
|
return 0;
|
||||||
|
@@ -207,9 +201,14 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
- n = new0(struct track_item, 1);
|
||||||
|
+ n = new(struct track_item, 1);
|
||||||
|
if (!n)
|
||||||
|
return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ *n = (struct track_item) {
|
||||||
|
+ .n_ref = 1,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
n->name = strdup(name);
|
||||||
|
if (!n->name)
|
||||||
|
return -ENOMEM;
|
||||||
|
@@ -241,8 +240,7 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
- n->n_ref = 1;
|
||||||
|
- n = NULL;
|
||||||
|
+ TAKE_PTR(n);
|
||||||
|
|
||||||
|
bus_track_remove_from_queue(track);
|
||||||
|
track->modified = true;
|
||||||
|
@@ -264,14 +262,13 @@ _public_ int sd_bus_track_remove_name(sd_bus_track *track, const char *name) {
|
||||||
|
i = hashmap_get(track->names, name);
|
||||||
|
if (!i)
|
||||||
|
return -EUNATCH;
|
||||||
|
- if (i->n_ref <= 0)
|
||||||
|
- return -EUNATCH;
|
||||||
|
|
||||||
|
- i->n_ref--;
|
||||||
|
-
|
||||||
|
- if (i->n_ref <= 0)
|
||||||
|
+ assert(i->n_ref >= 1);
|
||||||
|
+ if (i->n_ref <= 1)
|
||||||
|
return bus_track_remove_name_fully(track, name);
|
||||||
|
|
||||||
|
+ track_item_unref(i);
|
||||||
|
+
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
51
backport-sd-bus-switch-to-a-manual-overflow-check-in.patch
Normal file
51
backport-sd-bus-switch-to-a-manual-overflow-check-in.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 65d848e9b31bdc6caedcac378375943e72d1011f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lennart Poettering <lennart@poettering.net>
|
||||||
|
Date: Wed, 20 Apr 2022 22:30:22 +0200
|
||||||
|
Subject: [PATCH] sd-bus: switch to a manual overflow check in
|
||||||
|
sd_bus_track_add_name()
|
||||||
|
|
||||||
|
This is generally used in a directly client controllable way, hence we
|
||||||
|
should handle ref count overflow gracefully, instead of hitting an
|
||||||
|
assert().
|
||||||
|
|
||||||
|
As discussed:
|
||||||
|
|
||||||
|
https://github.com/systemd/systemd/pull/23099#discussion_r854341850
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/bus-track.c | 16 +++++++++++++---
|
||||||
|
1 file changed, 13 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
index 4c44162108c4d..e403555f8f83c 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
@@ -48,7 +48,7 @@ static struct track_item* track_item_free(struct track_item *i) {
|
||||||
|
return mfree(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
-DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(struct track_item, track_item, track_item_free);
|
||||||
|
+DEFINE_PRIVATE_TRIVIAL_UNREF_FUNC(struct track_item, track_item, track_item_free);
|
||||||
|
DEFINE_TRIVIAL_CLEANUP_FUNC(struct track_item*, track_item_unref);
|
||||||
|
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(track_item_hash_ops, char, string_hash_func, string_compare_func,
|
||||||
|
struct track_item, track_item_free);
|
||||||
|
@@ -190,8 +190,18 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
||||||
|
|
||||||
|
i = hashmap_get(track->names, name);
|
||||||
|
if (i) {
|
||||||
|
- if (track->recursive)
|
||||||
|
- track_item_ref(i);
|
||||||
|
+ if (track->recursive) {
|
||||||
|
+ assert(i->n_ref > 0);
|
||||||
|
+
|
||||||
|
+ /* Manual oveflow check (instead of a DEFINE_TRIVIAL_REF_FUNC() helper or so), so
|
||||||
|
+ * that we can return a proper error, given this is almost always called in a
|
||||||
|
+ * directly client controllable way, and thus better should never hit an assertion
|
||||||
|
+ * here. */
|
||||||
|
+ if (i->n_ref >= UINT_MAX)
|
||||||
|
+ return -EOVERFLOW;
|
||||||
|
+
|
||||||
|
+ i->n_ref++;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
bus_track_remove_from_queue(track);
|
||||||
|
return 0;
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
From c399ed923d6fa4bf731455d485cac5f00e060806 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 08:00:20 +0900
|
||||||
|
Subject: [PATCH] sd-bus: use hashmap_contains() and drop unnecessary cast
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/bus-track.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
index c56bd03fc6..4c44162108 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/bus-track.c
|
||||||
|
@@ -287,7 +287,7 @@ _public_ const char* sd_bus_track_contains(sd_bus_track *track, const char *name
|
||||||
|
if (!track) /* Let's consider a NULL object equivalent to an empty object */
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- return hashmap_get(track->names, (void*) name) ? name : NULL;
|
||||||
|
+ return hashmap_contains(track->names, name) ? name : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_public_ const char* sd_bus_track_first(sd_bus_track *track) {
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
97
backport-test-add-several-tests-for-track-item.patch
Normal file
97
backport-test-add-several-tests-for-track-item.patch
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
From 056a18e465bedb1bd35ce0bf78831be168c636cb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 07:58:45 +0900
|
||||||
|
Subject: [PATCH] test: add several tests for track item
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/test-bus-track.c | 58 +++++++++++++++++++++++++-
|
||||||
|
1 file changed, 57 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c
|
||||||
|
index 238934a880..5604e84f52 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/test-bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/test-bus-track.c
|
||||||
|
@@ -10,6 +10,7 @@
|
||||||
|
|
||||||
|
static bool track_cb_called_x = false;
|
||||||
|
static bool track_cb_called_y = false;
|
||||||
|
+static bool track_destroy_called_z = false;
|
||||||
|
|
||||||
|
static int track_cb_x(sd_bus_track *t, void *userdata) {
|
||||||
|
|
||||||
|
@@ -39,9 +40,17 @@ static int track_cb_y(sd_bus_track *t, void *userdata) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int track_cb_z(sd_bus_track *t, void *userdata) {
|
||||||
|
+ assert_not_reached("");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void track_destroy_z(void *userdata) {
|
||||||
|
+ track_destroy_called_z = true;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
|
||||||
|
- _cleanup_(sd_bus_track_unrefp) sd_bus_track *x = NULL, *y = NULL;
|
||||||
|
+ _cleanup_(sd_bus_track_unrefp) sd_bus_track *x = NULL, *y = NULL, *z = NULL;
|
||||||
|
_cleanup_(sd_bus_unrefp) sd_bus *a = NULL, *b = NULL;
|
||||||
|
bool use_system_bus = false;
|
||||||
|
const char *unique;
|
||||||
|
@@ -83,6 +92,53 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
assert_se(sd_bus_track_add_name(y, unique) >= 0);
|
||||||
|
|
||||||
|
+ /* Basic tests. */
|
||||||
|
+ assert_se(sd_bus_track_new(a, &z, track_cb_z, NULL) >= 0);
|
||||||
|
+
|
||||||
|
+ /* non-recursive case */
|
||||||
|
+ assert_se(sd_bus_track_set_recursive(z, false) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_get_recursive(z) == 0);
|
||||||
|
+ assert_se(!sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 0);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(z, unique) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(z, unique) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(z, unique) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_set_recursive(z, true) == -EBUSY);
|
||||||
|
+ assert_se(sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 1);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 1);
|
||||||
|
+ assert_se(!sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 0);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 0);
|
||||||
|
+
|
||||||
|
+ /* recursive case */
|
||||||
|
+ assert_se(sd_bus_track_set_recursive(z, true) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_get_recursive(z) == 1);
|
||||||
|
+ assert_se(!sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 0);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(z, unique) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(z, unique) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(z, unique) >= 0);
|
||||||
|
+ assert_se(sd_bus_track_set_recursive(z, false) == -EBUSY);
|
||||||
|
+ assert_se(sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 3);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 1);
|
||||||
|
+ assert_se(sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 2);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 1);
|
||||||
|
+ assert_se(sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 1);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 1);
|
||||||
|
+ assert_se(!sd_bus_track_contains(z, unique));
|
||||||
|
+ assert_se(sd_bus_track_count_name(z, unique) == 0);
|
||||||
|
+ assert_se(sd_bus_track_remove_name(z, unique) == 0);
|
||||||
|
+
|
||||||
|
+ assert_se(sd_bus_track_set_destroy_callback(z, track_destroy_z) >= 0);
|
||||||
|
+ z = sd_bus_track_unref(z);
|
||||||
|
+ assert_se(track_destroy_called_z);
|
||||||
|
+
|
||||||
|
/* Now make b's name disappear */
|
||||||
|
sd_bus_close(b);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
99
backport-test-shorten-code-a-bit.patch
Normal file
99
backport-test-shorten-code-a-bit.patch
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
From 63ec7a849039fab830961fd7fee0c1e266735fc8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 17 Apr 2022 07:35:05 +0900
|
||||||
|
Subject: [PATCH] test: shorten code a bit
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-bus/test-bus-track.c | 39 +++++++++-----------------
|
||||||
|
1 file changed, 13 insertions(+), 26 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c
|
||||||
|
index 68a0010..9707ffd 100644
|
||||||
|
--- a/src/libsystemd/sd-bus/test-bus-track.c
|
||||||
|
+++ b/src/libsystemd/sd-bus/test-bus-track.c
|
||||||
|
@@ -26,7 +26,6 @@ static int track_cb_x(sd_bus_track *t, void *userdata) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int track_cb_y(sd_bus_track *t, void *userdata) {
|
||||||
|
- int r;
|
||||||
|
|
||||||
|
log_error("TRACK CB Y");
|
||||||
|
|
||||||
|
@@ -35,8 +34,7 @@ static int track_cb_y(sd_bus_track *t, void *userdata) {
|
||||||
|
|
||||||
|
/* We got disconnected, let's close everything */
|
||||||
|
|
||||||
|
- r = sd_event_exit(sd_bus_get_event(sd_bus_track_get_bus(t)), EXIT_SUCCESS);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_event_exit(sd_bus_get_event(sd_bus_track_get_bus(t)), EXIT_SUCCESS) >= 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -51,8 +49,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
test_setup_logging(LOG_INFO);
|
||||||
|
|
||||||
|
- r = sd_event_default(&event);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_event_default(&event) >= 0);
|
||||||
|
|
||||||
|
r = sd_bus_open_user(&a);
|
||||||
|
if (IN_SET(r, -ECONNREFUSED, -ENOENT)) {
|
||||||
|
@@ -63,43 +60,33 @@ int main(int argc, char *argv[]) {
|
||||||
|
}
|
||||||
|
assert_se(r >= 0);
|
||||||
|
|
||||||
|
- r = sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL) >= 0);
|
||||||
|
|
||||||
|
if (use_system_bus)
|
||||||
|
- r = sd_bus_open_system(&b);
|
||||||
|
+ assert_se(sd_bus_open_system(&b) >= 0);
|
||||||
|
else
|
||||||
|
- r = sd_bus_open_user(&b);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_open_user(&b) >= 0);
|
||||||
|
|
||||||
|
- r = sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL) >= 0);
|
||||||
|
|
||||||
|
/* Watch b's name from a */
|
||||||
|
- r = sd_bus_track_new(a, &x, track_cb_x, NULL);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_track_new(a, &x, track_cb_x, NULL) >= 0);
|
||||||
|
|
||||||
|
- r = sd_bus_get_unique_name(b, &unique);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_get_unique_name(b, &unique) >= 0);
|
||||||
|
|
||||||
|
- r = sd_bus_track_add_name(x, unique);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(x, unique) >= 0);
|
||||||
|
|
||||||
|
/* Watch's a's own name from a */
|
||||||
|
- r = sd_bus_track_new(a, &y, track_cb_y, NULL);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_track_new(a, &y, track_cb_y, NULL) >= 0);
|
||||||
|
|
||||||
|
- r = sd_bus_get_unique_name(a, &unique);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_get_unique_name(a, &unique) >= 0);
|
||||||
|
|
||||||
|
- r = sd_bus_track_add_name(y, unique);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_bus_track_add_name(y, unique) >= 0);
|
||||||
|
|
||||||
|
/* Now make b's name disappear */
|
||||||
|
sd_bus_close(b);
|
||||||
|
|
||||||
|
- r = sd_event_loop(event);
|
||||||
|
- assert_se(r >= 0);
|
||||||
|
+ assert_se(sd_event_loop(event) >= 0);
|
||||||
|
|
||||||
|
assert_se(track_cb_called_x);
|
||||||
|
assert_se(track_cb_called_y);
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
24
systemd.spec
24
systemd.spec
@ -16,7 +16,7 @@
|
|||||||
Name: systemd
|
Name: systemd
|
||||||
Url: https://www.freedesktop.org/wiki/Software/systemd
|
Url: https://www.freedesktop.org/wiki/Software/systemd
|
||||||
Version: 243
|
Version: 243
|
||||||
Release: 70
|
Release: 71
|
||||||
License: MIT and LGPLv2+ and GPLv2+
|
License: MIT and LGPLv2+ and GPLv2+
|
||||||
Summary: System and Service Manager
|
Summary: System and Service Manager
|
||||||
|
|
||||||
@ -283,6 +283,16 @@ Patch0235: backport-udev-fix-potential-memleak.patch
|
|||||||
Patch0236: backport-journalctl-never-fail-at-flushing-when-the-flushed-f.patch
|
Patch0236: backport-journalctl-never-fail-at-flushing-when-the-flushed-f.patch
|
||||||
Patch0237: backport-core-fix-SIGABRT-on-empty-exec-command-argv.patch
|
Patch0237: backport-core-fix-SIGABRT-on-empty-exec-command-argv.patch
|
||||||
Patch0238: backport-core-service-also-check-path-in-exec-commands.patch
|
Patch0238: backport-core-service-also-check-path-in-exec-commands.patch
|
||||||
|
Patch0239: backport-json-use-unsigned-for-refernce-counter.patch
|
||||||
|
Patch0240: backport-macro-check-over-flow-in-reference-counter.patch
|
||||||
|
Patch0241: backport-sd-bus-fix-reference-counter-to-be-incremented.patch
|
||||||
|
Patch0242: backport-sd-bus-introduce-ref-unref-function-for-track_item.patch
|
||||||
|
Patch0243: backport-sd-bus-do-not-read-unused-value.patch
|
||||||
|
Patch0244: backport-sd-bus-do-not-return-negative-errno-when-unknown-nam.patch
|
||||||
|
Patch0245: backport-sd-bus-use-hashmap_contains-and-drop-unnecessary-cas.patch
|
||||||
|
Patch0246: backport-test-shorten-code-a-bit.patch
|
||||||
|
Patch0247: backport-test-add-several-tests-for-track-item.patch
|
||||||
|
Patch0248: backport-sd-bus-switch-to-a-manual-overflow-check-in.patch
|
||||||
|
|
||||||
#openEuler
|
#openEuler
|
||||||
Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch
|
Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch
|
||||||
@ -1690,6 +1700,18 @@ fi
|
|||||||
%exclude /usr/share/man/man3/*
|
%exclude /usr/share/man/man3/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Dec 18 2023 hongjinghao <hongjinghao@huawei.com> - 243-71
|
||||||
|
- add: backport-json-use-unsigned-for-refernce-counter.patch
|
||||||
|
backport-macro-check-over-flow-in-reference-counter.patch
|
||||||
|
backport-sd-bus-fix-reference-counter-to-be-incremented.patch
|
||||||
|
backport-sd-bus-introduce-ref-unref-function-for-track_item.patch
|
||||||
|
backport-sd-bus-do-not-read-unused-value.patch
|
||||||
|
backport-sd-bus-do-not-return-negative-errno-when-unknown-nam.patch
|
||||||
|
backport-sd-bus-use-hashmap_contains-and-drop-unnecessary-cas.patch
|
||||||
|
backport-test-shorten-code-a-bit.patch
|
||||||
|
backport-test-add-several-tests-for-track-item.patch
|
||||||
|
backport-sd-bus-switch-to-a-manual-overflow-check-in.patch
|
||||||
|
|
||||||
* Mon Dec 18 2023 huyubiao <huyubiao@huawei.com> - 243-70
|
* Mon Dec 18 2023 huyubiao <huyubiao@huawei.com> - 243-70
|
||||||
- backport: sync patches from systemd community
|
- backport: sync patches from systemd community
|
||||||
add backport-sd-device-do-no-allocate-strings-of-unknown-length-o.patch
|
add backport-sd-device-do-no-allocate-strings-of-unknown-length-o.patch
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user