[PATCH 1/2][RFC] dbus: Don't automatically emit PropertyChanged after Set
by Andrew Zaborowski
Remove the _dbus_object_tree_property_changed call in the complete
handler for property setters so a PropertyChanged/PropertiesChanged
signal is not sent for every successful Set(). This means that the
setter functions will have to emit the signals when the property's value
has changed so it affects ell's clients. This attempts to allow clients
to solve an issue where PropertyChanged signals were generated even if
Set was called with a value equal to the property's current value so the
values was not effectively chaning.
I'm not 100% convinced this small benefit is worth the added work for
clients. Another possibilty would be for the setter functions to give
the complete callback some hint when they want an property change to be
signalled. For example an additional parameter or always when the
'reply' parameter is NULL (as opposed to an successful method return
message). It could also be argued that a Set with a new value same as
old value should return an error reply but that's probably best left to
the client to decide.
---
ell/dbus-service.c | 48 +++-------------------------------------------
1 file changed, 3 insertions(+), 45 deletions(-)
diff --git a/ell/dbus-service.c b/ell/dbus-service.c
index 3ad6c7e..d97eb62 100644
--- a/ell/dbus-service.c
+++ b/ell/dbus-service.c
@@ -1227,28 +1227,13 @@ static void set_property_complete(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message *reply)
{
- const char *property_name;
- struct l_dbus_message_iter variant;
-
if (!reply) {
reply = l_dbus_message_new_method_return(message);
l_dbus_message_set_arguments(reply, "");
}
- l_dbus_send(dbus, l_dbus_message_ref(reply));
-
- if (!l_dbus_message_is_error(reply)) {
- l_dbus_message_get_arguments(message, "sv", &property_name,
- &variant);
-
- _dbus_object_tree_property_changed(dbus,
- l_dbus_message_get_path(message),
- l_dbus_message_get_interface(message),
- property_name);
- }
-
l_dbus_message_unref(message);
- l_dbus_message_unref(reply);
+ l_dbus_send(dbus, reply);
}
static struct l_dbus_message *old_set_property(struct l_dbus *dbus,
@@ -1815,33 +1800,6 @@ static struct l_dbus_message *properties_get(struct l_dbus *dbus,
return reply;
}
-static void properties_set_complete(struct l_dbus *dbus,
- struct l_dbus_message *message,
- struct l_dbus_message *reply)
-{
- const char *interface_name, *property_name;
- struct l_dbus_message_iter variant;
-
- if (!reply) {
- reply = l_dbus_message_new_method_return(message);
- l_dbus_message_set_arguments(reply, "");
- }
-
- l_dbus_send(dbus, l_dbus_message_ref(reply));
-
- if (!l_dbus_message_is_error(reply)) {
- l_dbus_message_get_arguments(message, "ssv", &interface_name,
- &property_name, &variant);
-
- _dbus_object_tree_property_changed(dbus,
- l_dbus_message_get_path(message),
- interface_name, property_name);
- }
-
- l_dbus_message_unref(message);
- l_dbus_message_unref(reply);
-}
-
static struct l_dbus_message *properties_set(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data)
@@ -1900,11 +1858,11 @@ static struct l_dbus_message *properties_set(struct l_dbus *dbus,
interface_name);
reply = property->setter(dbus, l_dbus_message_ref(message), &variant,
- properties_set_complete,
+ set_property_complete,
instance->user_data);
if (reply)
- properties_set_complete(dbus, message, reply);
+ set_property_complete(dbus, message, reply);
return NULL;
}
--
2.17.1
3 years, 9 months
[PATCH] key: export l_key_get_info
by Martin Hundebøll
The function is listed in the header, so it should be exported from the
shared library too.
---
ell/key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ell/key.c b/ell/key.c
index 4093143..6b16e55 100644
--- a/ell/key.c
+++ b/ell/key.c
@@ -398,7 +398,7 @@ static const char *lookup_checksum(enum l_checksum_type checksum)
return ret;
}
-bool l_key_get_info(struct l_key *key, enum l_key_cipher_type cipher,
+LIB_EXPORT bool l_key_get_info(struct l_key *key, enum l_key_cipher_type cipher,
enum l_checksum_type checksum, size_t *bits,
bool *public)
{
--
2.18.0
3 years, 9 months
[PATCH] examples: dhcp_client: fix compile error
by James Prestwood
When building dhcp_client, it appears that including linux/if_arp.h
requires sys/socket.h for the sockaddr definition (at least on my
system). I fixed the same issue with ell/net.c but never build
dhcp_client. Below is one of the errors I saw when building:
In file included from /usr/include/linux/netdevice.h:28,
from /usr/include/linux/if_arp.h:26,
from examples/dhcp-client.c:31:
/usr/include/linux/if.h:234:19: error: field ‘ifru_addr’ has incomplete type
struct sockaddr ifru_addr;
---
examples/dhcp-client.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/examples/dhcp-client.c b/examples/dhcp-client.c
index 550b82b..084f6aa 100644
--- a/examples/dhcp-client.c
+++ b/examples/dhcp-client.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
+#include <sys/socket.h>
#include <linux/if_arp.h>
#include <ell/ell.h>
--
2.7.4
3 years, 10 months
[PATCH 1/2] dbus: Avoid memcmp for string comparison
by Andrew Zaborowski
As discussed in
https://lists.01.org/pipermail/ell/2018-August/001279.html gcc's Address
Sanitizer may complain if we try using memcmp(A, B, len) to compare a
null-terminated A shorter than len against a longer B so use strncmp
instead.
---
ell/dbus-service.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-service.c b/ell/dbus-service.c
index edc46cd..4e70b7b 100644
--- a/ell/dbus-service.c
+++ b/ell/dbus-service.c
@@ -1467,7 +1467,7 @@ bool _dbus_object_tree_add_interface(struct _dbus_object_tree *tree,
manager = entry->data;
path_len = strlen(manager->path);
- if (memcmp(path, manager->path, path_len) ||
+ if (strncmp(path, manager->path, path_len) ||
(path[path_len] != '\0' &&
path[path_len] != '/' && path_len > 1))
continue;
@@ -1544,7 +1544,7 @@ bool _dbus_object_tree_remove_interface(struct _dbus_object_tree *tree,
manager = entry->data;
path_len = strlen(manager->path);
- if (memcmp(path, manager->path, path_len) ||
+ if (strncmp(path, manager->path, path_len) ||
(path[path_len] != '\0' &&
path[path_len] != '/' && path_len > 1))
continue;
--
2.14.1
3 years, 10 months
[PATCH 1/3] dbus: Fix subpath comparisons in object tree walk
by Andrew Zaborowski
By only using strncmp(child->subpath, path, len) we'd only check that
child->subpath had path as its prefix in makepath_recurse. As a
result, if an object at /ab was added first and at /a second, the
second object would not get a new node created and strangely none of
our tests or users have caught this.
---
ell/dbus-service.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-service.c b/ell/dbus-service.c
index 43c7a5c..cf787bc 100644
--- a/ell/dbus-service.c
+++ b/ell/dbus-service.c
@@ -649,7 +649,8 @@ static struct object_node *makepath_recurse(struct object_node *node,
child = node->children;
while (child) {
- if (!strncmp(child->subpath, path, end - path))
+ if (!strncmp(child->subpath, path, end - path) &&
+ child->subpath[end - path] == '\0')
goto done;
child = child->next;
@@ -690,7 +691,8 @@ static struct object_node *lookup_recurse(struct object_node *node,
child = node->children;
while (child) {
- if (!strncmp(child->subpath, path, end - path))
+ if (!strncmp(child->subpath, path, end - path) &&
+ child->subpath[end - path] == '\0')
return lookup_recurse(child->node, end);
child = child->next;
--
2.14.1
3 years, 10 months
[PATCH] dbus: Fix subpath comparisons in object tree walk
by Andrew Zaborowski
By only using strncmp(child->subpath, path, len) we'd only check that
child->subpath had path as its prefix in makepath_recurse. As a
result, if an object at /ab was added first and at /a second, the
second object would not get a new node created and strangely none of
our tests or users have caught this.
---
ell/dbus-service.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ell/dbus-service.c b/ell/dbus-service.c
index 43c7a5c..cd9d402 100644
--- a/ell/dbus-service.c
+++ b/ell/dbus-service.c
@@ -649,7 +649,8 @@ static struct object_node *makepath_recurse(struct object_node *node,
child = node->children;
while (child) {
- if (!strncmp(child->subpath, path, end - path))
+ if (!memcmp(child->subpath, path, end - path) &&
+ child->subpath[end - path] == '\0')
goto done;
child = child->next;
@@ -690,7 +691,8 @@ static struct object_node *lookup_recurse(struct object_node *node,
child = node->children;
while (child) {
- if (!strncmp(child->subpath, path, end - path))
+ if (!memcmp(child->subpath, path, end - path) &&
+ child->subpath[end - path] == '\0')
return lookup_recurse(child->node, end);
child = child->next;
--
2.14.1
3 years, 10 months
[PATCH 1/2] fswatch: Notify about L_FSWATCH_EVENT_ATTRIB events
by Andrew Zaborowski
Also emit events on file attribute changes, this was actually my
original intent but I must have missed this bit in the bitmask.
---
ell/fswatch.c | 7 ++++++-
ell/fswatch.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ell/fswatch.c b/ell/fswatch.c
index c5980d3..f7719b3 100644
--- a/ell/fswatch.c
+++ b/ell/fswatch.c
@@ -48,7 +48,8 @@ struct l_fswatch {
};
#define EVENT_MASK (IN_CREATE | IN_DELETE | IN_DELETE_SELF | \
- IN_MODIFY | IN_MOVE | IN_MOVE_SELF)
+ IN_MODIFY | IN_MOVE | IN_MOVE_SELF | \
+ IN_ATTRIB)
static void l_fswatch_free(void *data)
{
@@ -125,6 +126,10 @@ static bool inotify_read_cb(struct l_io *io, void *user_data)
watch->cb(watch, name, L_FSWATCH_EVENT_DELETE,
watch->user_data);
+ if ((event->mask & IN_ATTRIB) && watch->cb)
+ watch->cb(watch, name, L_FSWATCH_EVENT_ATTRIB,
+ watch->user_data);
+
if (event->mask & IN_IGNORED) {
stale_items = true;
watch->cb = NULL;
diff --git a/ell/fswatch.h b/ell/fswatch.h
index 419df09..425dc3e 100644
--- a/ell/fswatch.h
+++ b/ell/fswatch.h
@@ -30,6 +30,7 @@ enum l_fswatch_event {
L_FSWATCH_EVENT_MOVE,
L_FSWATCH_EVENT_MODIFY,
L_FSWATCH_EVENT_DELETE,
+ L_FSWATCH_EVENT_ATTRIB,
};
typedef void (*l_fswatch_cb_t) (struct l_fswatch *watch, const char *filename,
--
2.14.1
3 years, 10 months