summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/dht.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-07-24 08:31:21 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-07-24 08:31:21 +0000
commit0a36839e75c933fbc260b430e159b525d2d7df19 (patch)
treeec969f73b615ef064e125b8311ba5447051aecdb /src/ipcpd/normal/dht.c
parentef67f3f4a808fc6e6484be9ddee06ee6756d8c93 (diff)
parent36343a9c19fca9494881a9529b5fbbb0d51c1900 (diff)
downloadouroboros-0a36839e75c933fbc260b430e159b525d2d7df19.tar.gz
ouroboros-0a36839e75c933fbc260b430e159b525d2d7df19.zip
Merged in dstaesse/ouroboros/be-dht-retry (pull request #535)
ipcpd: Retry sending DHT response messages
Diffstat (limited to 'src/ipcpd/normal/dht.c')
-rw-r--r--src/ipcpd/normal/dht.c20
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;