summaryrefslogtreecommitdiffstats
path: root/ffd/update.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-10-21 05:32:43 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-10-21 05:32:43 +0200
commit758611ccd2a8ce105258cf766fc5aa7b0719ae95 (patch)
treefc5260a8fa2c2489e0b7234535e617e0554cf784 /ffd/update.c
parentaa15b96d39dd0242c33b7a11c7c02ebdba50f150 (diff)
downloadffd-758611ccd2a8ce105258cf766fc5aa7b0719ae95.tar
ffd-758611ccd2a8ce105258cf766fc5aa7b0719ae95.zip
Use acked updates for seqno request replies
Diffstat (limited to 'ffd/update.c')
-rw-r--r--ffd/update.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/ffd/update.c b/ffd/update.c
index d273fec..77319bd 100644
--- a/ffd/update.c
+++ b/ffd/update.c
@@ -75,6 +75,27 @@ static inline void update_unref(update_arg_t *arg) {
}
}
+static void update_request_ack(uint16_t nonce, void *argp) {
+ update_arg_t *arg = argp;
+
+ fprintf(stderr, "debug: sending acked update with nonce %u.\n", nonce);
+
+ ffd_update_t *update = ffd_send_update_new(NULL, arg->neigh, &nonce);
+
+ ffd_announce_t *announce = ffd_announce_find(&arg->node, arg->type, arg->key);
+
+ if (announce)
+ ffd_send_update_add(update, announce);
+ else
+ ffd_send_update_retract(update, arg->node, arg->type, arg->key);
+
+ ffd_send_update_finish(update);
+}
+
+static void update_request_ack_free(uint16_t nonce, void *arg) {
+ update_unref(arg);
+}
+
void ffd_update_enqueue(const ffd_node_id_t *node, uint16_t type, uint16_t key, ffd_neigh_t *neigh, bool urgent) {
if (neigh)
ffd_neigh_ref(neigh);
@@ -82,11 +103,16 @@ void ffd_update_enqueue(const ffd_node_id_t *node, uint16_t type, uint16_t key,
update_arg_t *arg = update_new(node, type, key, neigh);
if (urgent) {
- ffd_queue_put_delayed(&pending_updates, NULL, &now, FFD_URGENT_DELAY, update_ref(arg));
- ffd_queue_put_delayed(&pending_updates, NULL, &now, 2*FFD_URGENT_DELAY, update_ref(arg));
- ffd_queue_put_delayed(&pending_updates, NULL, &now, 3*FFD_URGENT_DELAY, update_ref(arg));
- ffd_queue_put_delayed(&pending_updates, NULL, &now, 4*FFD_URGENT_DELAY, update_ref(arg));
- ffd_queue_put_delayed(&pending_updates, NULL, &now, 5*FFD_URGENT_DELAY, update_ref(arg));
+ if (neigh) {
+ ffd_ack_request(update_request_ack, update_request_ack_free, FFD_ACK_INTERVAL, 10, update_ref(arg));
+ }
+ else {
+ ffd_queue_put_delayed(&pending_updates, NULL, &now, FFD_URGENT_DELAY, update_ref(arg));
+ ffd_queue_put_delayed(&pending_updates, NULL, &now, 2*FFD_URGENT_DELAY, update_ref(arg));
+ ffd_queue_put_delayed(&pending_updates, NULL, &now, 3*FFD_URGENT_DELAY, update_ref(arg));
+ ffd_queue_put_delayed(&pending_updates, NULL, &now, 4*FFD_URGENT_DELAY, update_ref(arg));
+ ffd_queue_put_delayed(&pending_updates, NULL, &now, 5*FFD_URGENT_DELAY, update_ref(arg));
+ }
}
else {
ffd_queue_put_delayed(&pending_updates, NULL, &now, FFD_DELAY, update_ref(arg));
@@ -101,7 +127,7 @@ void ffd_update_run(void) {
while (!ffd_update_timeout()) {
ffd_neigh_t *neigh = ((update_arg_t*)pending_updates->arg)->neigh;
- ffd_update_t *update = ffd_send_update_new(NULL, neigh);
+ ffd_update_t *update = ffd_send_update_new(NULL, neigh, NULL);
fprintf(stderr, "debug: sending scheduled updates.\n");