diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-07-05 18:43:19 +0200 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-07-08 11:02:25 +0200 |
| commit | 42d3c0735624f692257f570fd986c86beb3e637f (patch) | |
| tree | 6409915ae78f3a8866b0ecdf1efd54079c6ea6dd | |
| parent | 1268d6124a5cbc2cd451e5a1ae16d3a4b7cdc423 (diff) | |
| download | ouroboros-42d3c0735624f692257f570fd986c86beb3e637f.tar.gz ouroboros-42d3c0735624f692257f570fd986c86beb3e637f.zip | |
ipcpd: Store local names before DHT peeringbe
A name registered before the DHT had a peer stayed unpublished until
it neared its expiry deadline. Make a never-stored local value (t_repl
== 0) eligible for replication immediately, and flush replication once
when the worker starts so such names are published as soon as the DHT
is enrolled.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
| -rw-r--r-- | src/ipcpd/unicast/dir/dht.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c index d1d68e49..753d9a73 100644 --- a/src/ipcpd/unicast/dir/dht.c +++ b/src/ipcpd/unicast/dir/dht.c @@ -3471,6 +3471,8 @@ static void value_list_destroy(struct list_head * vl) #define MUST_REPLICATE(v, now) ((now)->tv_sec > (v)->t_repl + dht.t_repl) #define MUST_REPUBLISH(v, now) /* Close to expiry deadline */ \ (((v)->t_exp - (now)->tv_sec) < (DHT_N_REPUB * dht.t_repl)) +/* A local value must be (re)stored if near expiry or never stored. */ +#define MUST_STORE_LVAL(v, now) (MUST_REPUBLISH(v, now) || (v)->t_repl == 0) static void dht_entry_get_repl_lists(const struct dht_entry * e, struct list_head * repl, struct list_head * rebl, @@ -3492,7 +3494,7 @@ static void dht_entry_get_repl_lists(const struct dht_entry * e, llist_for_each(p, &e->lvals) { struct val_entry * v = list_entry(p, struct val_entry, next); - if (MUST_REPLICATE(v, now) && MUST_REPUBLISH(v, now)) { + if (MUST_REPLICATE(v, now) && MUST_STORE_LVAL(v, now)) { /* Add expire time here, to allow creating val_entry */ n = val_entry_create(v->val, now->tv_sec + dht.t_exp); if (n == NULL) @@ -3782,6 +3784,9 @@ static void * work(void * o) log_dbg("DHT worker starting %ld seconds interval.", intv * n); + /* Flush names registered before we had peers to store them. */ + dht_kv_replicate(); + while (true) { int i = 0; while (tasks[i] != NULL) { |
