Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: alliedtelesis/apteryx
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.32
Choose a base ref
...
head repository: alliedtelesis/apteryx
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jan 24, 2024

  1. Do not try and retrieve pid/ns for non UNIX sockets

    This just generates uneeded syslog messages.
    carlgsmith authored and blairsteven committed Jan 24, 2024
    Copy the full SHA
    2ddb56c View commit details

Commits on Feb 7, 2024

  1. Copy the full SHA
    f5ed3e0 View commit details
  2. Add directory level refresher test

    Ensure a directory level refresh is called when a get tree is done on
    that directory.
    blairsteven authored and carlgsmith committed Feb 7, 2024
    Copy the full SHA
    f6b1e0e View commit details
  3. Add refresher path matching tests

    Ensure refreshers are sent a path that matches the refreshed path.
    Some refreshers will used the passed in path to match against local
    copies, in this case the path must be terminated with a "/" if we don't
    otherwise have a key.
    blairsteven authored and carlgsmith committed Feb 7, 2024
    Copy the full SHA
    2760fc6 View commit details
  4. Call directory level matches for refreshers

    When processing a traverse we need to search for both the exact key and
    values further down the tree. Usually a direct single value will be
    fetched with apteryx_get, but it is legal (and done by some users) to
    call apteryx_get_tree for a single value.
    blairsteven authored and carlgsmith committed Feb 7, 2024
    Copy the full SHA
    2762b8a View commit details
  5. Send / to refreshers who require it

    When sending refresher callback message send a path that has a trailing
    '/' if the refresher is either a wildcard or directory level refresher,
    and this call was not for a specific value.
    blairsteven authored and carlgsmith committed Feb 7, 2024
    Copy the full SHA
    b285665 View commit details
  6. Small test fixes

    blairsteven authored and carlgsmith committed Feb 7, 2024
    Copy the full SHA
    ab898f8 View commit details

Commits on Feb 8, 2024

  1. Shutdown apteryx client library on lua_close

    The apteryx client library is reference counted
    and so needs to be shutdown when the lua instance
    is closed.
    carlgsmith committed Feb 8, 2024
    Copy the full SHA
    a05d08a View commit details

Commits on Feb 9, 2024

  1. Copy the full SHA
    2c9b215 View commit details

Commits on Feb 18, 2024

  1. Prepare more suitable paths to be passed to the refresher

    We combine info from the refreshed path and the requested path.
    
    We now match both the current node and then node/ when
    looking for refreshers when doing a get tree.
    We no longer need the direct_request parameter to call_refreshers.
    
    Add more comprehensive unit tests for refresher paths.
    carlgsmith authored and blairsteven committed Feb 18, 2024
    Copy the full SHA
    78bbcd1 View commit details
  2. Copy the full SHA
    170a375 View commit details
  3. Copy the full SHA
    b482c5f View commit details

Commits on Feb 19, 2024

  1. Fix refreshing paths for wildcards

    Do not call refresher if we have unresolved wildcards.
    Pass an actual wildcard node when recursing _refresh_paths
    so that strcmp matches properly.
    Fixup test asssertions for cases that should not have
    called a refresher and cases that were missing the final /.
    Add a bunch of test cases for root path queries and refreshers.
    carlgsmith authored and blairsteven committed Feb 19, 2024
    Copy the full SHA
    b4a45cb View commit details
  2. Call trunk wildcard refresher for first wildcard in query

    This restores the previous behaviour and does not break
    the rule of a refresher not being passed a matching path.
    A refresher will be passed the longest path in a query
    that does not have a wildcard in it yet matches the refresher.
    carlgsmith authored and blairsteven committed Feb 19, 2024
    Copy the full SHA
    a6c8b1f View commit details

Commits on Feb 20, 2024

  1. Copy the full SHA
    faf9de1 View commit details
  2. Tune lua garbage collector in alfred

    The default values for the garbage collector in alfred can result in an
    ever-growing pile of garbage when repeated provide calls are made.
    
    Tune the garbage collector by reducing the pause value from the default
    200 to 150 - the GC runs more frequently and prevents the pile from
    building up nearly as high.
    
    The lua_gc API differs between lua 5.3 and 5.4.
    GregATL authored and carlgsmith committed Feb 20, 2024
    Copy the full SHA
    aec0a19 View commit details

Commits on Mar 5, 2024

  1. Fix local refresher for statistics

    We should record the timestamp and last path on any
    local refreshers.
    
    We dont need to specify the CAS timestamp when adding stats to the DB,
    but using the wrong timestamp fn is even worse.
    
    Currently the only local refresher is for statistics and this fix
    avoids the stats refresher being thrashed.
    carlgsmith committed Mar 5, 2024
    Copy the full SHA
    4353517 View commit details

Commits on Mar 11, 2024

  1. Use MONOTONIC time for socket recv timeout

    Get rid of the duplication of get_time_us functions.
    carlgsmith committed Mar 11, 2024
    Copy the full SHA
    614dd9a View commit details
  2. Warnings as errors

    carlgsmith committed Mar 11, 2024
    Copy the full SHA
    5198dea View commit details

Commits on Mar 13, 2024

  1. Ensure workers have correct sigmask

    The slow work thread should have all signals blocked.
    But should call callbacks with the worker_sigmask.
    Tidy up variable naming so this is more obvious if
    this code is changed later.
    carlgsmith committed Mar 13, 2024
    Copy the full SHA
    13ecc9f View commit details

Commits on Apr 3, 2024

  1. A worker pool is only needed for rpc instances that serve call backs

    Since the glib-2.0 patch
    4d2e77a55 GThreadPool: Always use the thread-spawning thread for the global shared thread pool
    GNOME/glib@4d2e77a
    creating a threadpool spawns a new thread. Previously, this was only the
    case for non-Linux platforms.
    This can cause issues for daemons that fork and depend on libraries that
    load apteryx on LT_INIT, as the glib threadpool spawned thread will not
    be copied on the fork.
    Additionally, now libraries that only use get calls will be running an
    extra thread from the threadpool.
    
    Move the threadpool creation into request_cb() to only spawn the pool
    managing thread for applications that require callbacks using workers.
    coledishington authored and carlgsmith committed Apr 3, 2024
    Copy the full SHA
    21bffd3 View commit details

Commits on Apr 15, 2024

  1. Implement apteryx_watch_tree_masked

    Allows users to create a watch callback that masks
    sets made by itself as defined by namespace and pid.
    
    Flags are now passed to apteryxd via the GUID.
    RPC messages contain the sender ns/pid.
    Use macros to alow users to activate the required
    functionality without them calling the _full fn.
    carlgsmith committed Apr 15, 2024
    Copy the full SHA
    44de645 View commit details

Commits on Apr 16, 2024

  1. Dont print error if apteryx_path_node passed NULL tree

    It is commonly used to check if a tree has a path and that
    tree may be completely empty.
    carlgsmith committed Apr 16, 2024
    Copy the full SHA
    8230c81 View commit details

Commits on May 3, 2024

  1. tests: don't try to sudo and set a value that doesn't exist

    tcp_tw_recycle hasn't existed since 4.12, also it's a bit unfriendly
    to try to sudo
    sparlane authored and carlgsmith committed May 3, 2024
    Copy the full SHA
    1460d3d View commit details

Commits on Sep 17, 2024

  1. Copy the full SHA
    309449d View commit details

Commits on Sep 20, 2024

  1. Large set tree + watch performance

    Add a new larger set tree with a watch. This is the target for upcoming
    tree callback matching.
    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    9d6e442 View commit details
  2. Add tree based callback matching

    Add cb_match_tree. This function returns a GList of struct cb_tree_info
    with the usual cb_info_t structure populated, with a newly allocated
    GNode tree of the data that matches the callback.
    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    4a49013 View commit details
  3. Use tree matching for watchers

    The new config_match_tree function allows us to match the whole change
    set in a set tree or prune against all watchers and validators. These
    callbacks can then be called with the matching tree as a single RPC -
    this can save a lot of processing for large changesets.
    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    e7c8e2b View commit details
  4. Fix memory leak in get_tree

    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    5d26b38 View commit details
  5. Copy the full SHA
    1d9cde4 View commit details
  6. Cleanup after watch tests

    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    a253464 View commit details
  7. Handle error in parsing tree during handle_watch

    Handle the unlikely case that the rpc_msg_decode_tree fails to build a
    tree.
    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    012c202 View commit details
  8. Ensure tree passed to watch tree callback are valid to be used in apt…

    …eryx_set_tree
    
    apteryx_set_tree and apteryx_query both check that the root key in the
    tree is a valid apteryx path. It handle this ensure that the GNode that
    is created when parsing the tree has a "/" if it is not a longer path.
    blairsteven authored and carlgsmith committed Sep 20, 2024
    Copy the full SHA
    e974270 View commit details

Commits on Sep 30, 2024

  1. Add tests and assert for invalid tree structures

    When Apteryxd is handling a tree it requires the non-root nodes to be
    single key values.
    
    Add tests where the client sends compound keys and an assert to stop the
    process.
    blairsteven authored and carlgsmith committed Sep 30, 2024
    Copy the full SHA
    4693f00 View commit details
  2. Break up compound non-root keys

    Code in apteryxd is designed to handle GNode keys as single key values,
    so encode the tree in this way.
    blairsteven authored and carlgsmith committed Sep 30, 2024
    Copy the full SHA
    ac01dc0 View commit details

Commits on Oct 8, 2024

  1. Return DB timestamp for refreshed paths

    Previously we alway returned "now" if there was a chance
    of a path being refreshed. That was because refreshed paths
    always had their timestamps updated to "now" even if the
    refresher decided not to update anything so that we did not
    call the refresher again for stale child nodes. Now that we
    do not use the DB timestamps to decide whether to call the
    refreshers anymore we can fix this odd behaviour.
    
    The change in behaviour is;
    1. A call to a refresher does not result in all children of
    the path having their timestamps set to "now" even if they
    were not modified.
    2. A call to get a timestamp for a path will call refreshers
    to make sure the timestamp is up to date.
    carlgsmith committed Oct 8, 2024
    Copy the full SHA
    63aea2b View commit details

Commits on Oct 14, 2024

  1. Add test for cb_match_tree locking

    blairsteven authored and carlgsmith committed Oct 14, 2024
    Copy the full SHA
    3401d25 View commit details
  2. Lock tree during cb_match_tree

    The cb tree can be changed while iterating, so it needs to be locked.
    blairsteven authored and carlgsmith committed Oct 14, 2024
    Copy the full SHA
    4cd230b View commit details

Commits on Oct 23, 2024

  1. Add apteryx_uniqify_tree

    Add a function to remove duplicate values from a tree - as a side effect
    this will sort each level of the tree in alphabetic order.
    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    f7ca50c View commit details
  2. apteryx_query result should not have duplicates

    apteryx_query has an unusual behaviour in that some advanced queries can
    generate a tree with duplicate nodes. Remove these with
    apteryx_uniqify_tree.
    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    8d80098 View commit details
  3. Encode tree in reverse order

    This allows the g_node_prepend done in  _rpc_msg_decode_tree to
    reassemble the tree in the same order as it was originally without being
    O(n*n).
    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    690113b View commit details
  4. Add apteryx_uniqify_tree tests

    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    405a23f View commit details
  5. Fix a couple of tests

    Instated a check that now passes, made another test do what was
    intended.
    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    5e2c5e1 View commit details
  6. Fix memory leak in test

    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    2d0a9c3 View commit details
  7. Check apteryx_set_tree with multiple values

    Ensure a client setting up multiple values for the same key in a tree
    ends up with the last value actually being used. There are ways of doing
    this setup which will end up with the wrong value being set (requiring a
    mix of methods to create the tree), but this will work when
    APTERYX_VALUE / APTERYX_NODE is used the same way multiple times to
    create a tree with duplicate nodes.
    blairsteven authored and carlgsmith committed Oct 23, 2024
    Copy the full SHA
    4aec22a View commit details

Commits on Nov 20, 2024

  1. Copy the full SHA
    0808047 View commit details

Commits on Nov 28, 2024

  1. Store all strings in a cache

    Apteryxd can end up storing a lot of duplicated strings. This commit
    adds a cache to remove this duplication - it is called the same way
    strdup / free would be and will take care of allocating, reference
    counting and releasing strings.
    
    This cache has no locking, so needs to be called under an external lock.
    At the moment this used solely in code inside the db_lock in database.c
    blairsteven authored and carlgsmith committed Nov 28, 2024
    Copy the full SHA
    7597a6e View commit details
  2. Update apteryx query assertions

    When showing an incomplete nat rule router would crash, due to an
    invalid memory access. This was caused by having a validity check on an
    entity that does not exist resulting in an apteryx node with null data.
    This has been remedied by updating the assertion in the apteryx query func
    to return NULL when the node data is NULL. Preventing an invalid memory
    access when destroying the node.
    Ben Ireland authored and carlgsmith committed Nov 28, 2024
    Copy the full SHA
    6294d3d View commit details

Commits on Nov 29, 2024

  1. Update memuse for use of string-cache

    Also use malloc_usable_size + malloc header of 8 bytes
    where we can.
    carlgsmith committed Nov 29, 2024
    Copy the full SHA
    2441d3b View commit details

Commits on Dec 10, 2024

  1. Fix thread contention in string-cache

    Both database.c and callback.c use the hashtree code, so the cache
    needs to be protected with a lock.
    blairsteven authored and carlgsmith committed Dec 10, 2024
    Copy the full SHA
    86ffbe2 View commit details
Showing with 2,612 additions and 646 deletions.
  1. +3 −3 Makefile
  2. +210 −84 apteryx.c
  3. +28 −19 apteryx.h
  4. +10 −3 apteryxc.c
  5. +268 −277 apteryxd.c
  6. +494 −13 callbacks.c
  7. +30 −16 config.c
  8. +19 −31 database.c
  9. +12 −9 hashtree.c
  10. +41 −7 internal.h
  11. +21 −3 lua.c
  12. +115 −49 rpc.c
  13. +8 −4 rpc_socket.c
  14. +5 −3 rpc_transport.c
  15. +153 −0 string-cache.c
  16. +36 −0 string-cache.h
  17. +1,159 −125 test.c
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ PKG_CONFIG ?= pkg-config

ABI_VERSION=4
CFLAGS := $(CFLAGS) -g -O2
EXTRA_CFLAGS += -Wall -Wno-comment -std=c99 -D_GNU_SOURCE -fPIC
EXTRA_CFLAGS += -Wall -Werror -Wno-comment -std=c99 -D_GNU_SOURCE -fPIC
EXTRA_CFLAGS += -I. $(shell $(PKG_CONFIG) --cflags glib-2.0)
EXTRA_LDFLAGS := -L$(BUILDDIR) $(shell $(PKG_CONFIG) --libs glib-2.0) -lpthread
ifneq ($(HAVE_LUA),no)
@@ -69,11 +69,11 @@ $(BUILDDIR)/%.o: %.c | $(BUILDDIR)
@echo "Compiling "$<""
$(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@

$(BUILDDIR)/apteryxd: apteryxd.c hashtree.c database.c $(BUILDDIR)/rpc_transport.o $(BUILDDIR)/rpc_socket.o $(BUILDDIR)/config.o $(BUILDDIR)/callbacks.o $(BUILDDIR)/libapteryx.so
$(BUILDDIR)/apteryxd: apteryxd.c hashtree.c database.c string-cache.c $(BUILDDIR)/rpc_transport.o $(BUILDDIR)/rpc_socket.o $(BUILDDIR)/config.o $(BUILDDIR)/callbacks.o $(BUILDDIR)/libapteryx.so
@echo "Building $@"
$(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $^ $(EXTRA_LDFLAGS)

$(BUILDDIR)/apteryx: apteryxc.c hashtree.c database.c callbacks.c $(BUILDDIR)/libapteryx.so $(EXTRA_CSRC)
$(BUILDDIR)/apteryx: apteryxc.c hashtree.c database.c string-cache.c callbacks.c $(BUILDDIR)/libapteryx.so $(EXTRA_CSRC)
@echo "Building $@"
$(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(apteryx_CFLAGS) -o $@ $^ -lapteryx $(EXTRA_LDFLAGS) $(apteryx_LDFLAGS)

Loading