Skip to content

Commit

Permalink
Fix generation of paths of synced variables
Browse files Browse the repository at this point in the history
Paths should be generated from the parent of the leaf node in
the tree, not from the leaf and then stripping off the last '/'.
Previous method fails when value include '/' characters.

In one instance the excluded path list was being checked against
entire path/value concatenation which then failed to exclude.

Remove an unused global variable.
  • Loading branch information
tony-vanderpeet authored and sparlane committed Oct 18, 2024
1 parent d30b91f commit ac8aac2
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions syncer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static guint sync_timer = 0;

/* keep a list of the paths we are syncing */
GList *paths = NULL;
GList *excluded_paths = NULL;
pthread_rwlock_t paths_lock = PTHREAD_RWLOCK_INITIALIZER;

static uint64_t
Expand Down Expand Up @@ -329,18 +328,13 @@ sync_tree_process (GNode *node, gpointer arg)
{
uint64_t ts;
sync_params *params = (sync_params *) arg;
char *path = apteryx_node_path (node);
char *path = apteryx_node_path (node->parent);

if (path)
{
if (!sync_path_excluded (params->entry, path))
{
/* The timestamp is stored on the parent of the value. */
char *ptr = strrchr (path, '/');
if (ptr)
{
*ptr = '\0';
}
ts = apteryx_timestamp (path);
if (ts && ts > params->ts)
{
Expand Down Expand Up @@ -520,17 +514,11 @@ sync_find_sync_entry (GNode *node)
static gboolean
new_change_process (GNode *node, gpointer arg)
{
char *path = apteryx_node_path (node);
char *path = apteryx_node_path (node->parent);
char *value = NULL;
sync_entry *entry = (sync_entry *) arg;
if (path)
{
char *ptr = strrchr (path, '/');
if (ptr)
{
*ptr = '\0';
}

if (!sync_path_excluded (entry, path))
{
if (node->data && ((char *) node->data)[0] != '\0')
Expand Down

0 comments on commit ac8aac2

Please sign in to comment.