diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-07-24 10:18:40 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-07-24 10:26:14 +0200 |
commit | 36343a9c19fca9494881a9529b5fbbb0d51c1900 (patch) | |
tree | ec969f73b615ef064e125b8311ba5447051aecdb /src/ipcpd | |
parent | ef67f3f4a808fc6e6484be9ddee06ee6756d8c93 (diff) | |
download | ouroboros-36343a9c19fca9494881a9529b5fbbb0d51c1900.tar.gz ouroboros-36343a9c19fca9494881a9529b5fbbb0d51c1900.zip |
ipcpd: Retry sending DHT response messages
This will make the remote retry sending responses when the DT
component can't send the message. This is most useful at enrollment,
when the remote's routing table may need to wait a bit on the routing
component for a path to the new member,
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/normal/dht.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c index 1b382c1b..b79d9480 100644 --- a/src/ipcpd/normal/dht.c +++ b/src/ipcpd/normal/dht.c @@ -56,6 +56,7 @@ typedef KadContactMsg kad_contact_msg_t; #define KAD_R_PING 2 /* Ping retries before declaring peer dead. */ #define KAD_QUEER 15 /* Time to declare peer questionable. */ #define KAD_BETA 8 /* Bucket split factor, must be 1, 2, 4 or 8. */ +#define KAD_RESP_RETR 6 /* Number of retries on sending a response. */ enum dht_state { DHT_INIT = 0, @@ -1272,6 +1273,10 @@ static int send_msg(struct dht * dht, struct shm_du_buff * sdb; struct kad_req * req; size_t len; + int retr = 0; + + if (msg->code == KAD_RESPONSE) + retr = KAD_RESP_RETR; pthread_rwlock_wrlock(&dht->lock); @@ -1299,10 +1304,19 @@ static int send_msg(struct dht * dht, kad_msg__pack(msg, shm_du_buff_head(sdb)); #ifndef __DHT_TEST__ - if (dt_write_sdu(addr, QOS_CUBE_BE, dht->fd, sdb)) + while (retr >= 0) { + if (dt_write_sdu(addr, QOS_CUBE_BE, dht->fd, sdb)) + retr--; + else + break; + sleep(1); + } + + if (retr < 0) goto fail_write; #else (void) addr; + (void) retr; ipcp_sdb_release(sdb); #endif /* __DHT_TEST__ */ @@ -1598,9 +1612,7 @@ static int kad_join(struct dht * dht, pthread_rwlock_unlock(&dht->lock); lu = kad_lookup(dht, dht->id, KAD_FIND_NODE); - if (lu == NULL) - log_warn("Join response not yet added."); - else + if (lu != NULL) lookup_destroy(lu); return 0; |