summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/dht.c39
-rw-r--r--src/ipcpd/normal/flow_alloc.proto4
-rw-r--r--src/ipcpd/normal/kademlia.proto4
-rw-r--r--src/ipcpd/normal/pol/fso.proto4
-rw-r--r--src/ipcpd/normal/sdu_sched.c18
5 files changed, 38 insertions, 31 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index b5bac913..a1d21ad7 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -837,6 +837,24 @@ static void lookup_new_addrs(struct lookup * lu,
pthread_mutex_unlock(&lu->lock);
}
+static void lookup_set_state(struct lookup * lu,
+ enum lookup_state state)
+{
+ pthread_mutex_lock(&lu->lock);
+
+ lu->state = state;
+ pthread_cond_signal(&lu->cond);
+
+ pthread_mutex_unlock(&lu->lock);
+}
+
+static void cleanup_wait(void * o)
+{
+ struct lookup * lu = (struct lookup *) o;
+ lookup_set_state(lu, LU_NULL);
+ lookup_destroy(lu);
+}
+
static enum lookup_state lookup_wait(struct lookup * lu)
{
struct timespec timeo = {KAD_T_RESP, 0};
@@ -853,7 +871,7 @@ static enum lookup_state lookup_wait(struct lookup * lu)
lu->state = LU_PENDING;
pthread_cond_signal(&lu->cond);
- pthread_cleanup_push((void (*)(void *)) lookup_destroy, (void *) lu);
+ pthread_cleanup_push(cleanup_wait, lu);
while (lu->state == LU_PENDING && ret != -ETIMEDOUT)
ret = -pthread_cond_timedwait(&lu->cond, &lu->lock, &abs);
@@ -861,9 +879,9 @@ static enum lookup_state lookup_wait(struct lookup * lu)
pthread_cleanup_pop(false);
if (ret == -ETIMEDOUT)
- state = LU_COMPLETE;
- else
- state = lu->state;
+ lu->state = LU_COMPLETE;
+
+ state = lu->state;
pthread_mutex_unlock(&lu->lock);
@@ -1501,17 +1519,6 @@ static ssize_t kad_find(struct dht * dht,
return sent;
}
-static void lookup_set_state(struct lookup * lu,
- enum lookup_state state)
-{
- pthread_mutex_lock(&lu->lock);
-
- lu->state = state;
- pthread_cond_signal(&lu->cond);
-
- pthread_mutex_unlock(&lu->lock);
-}
-
static struct lookup * kad_lookup(struct dht * dht,
const uint8_t * id,
enum kad_code code)
@@ -1540,7 +1547,6 @@ static struct lookup * kad_lookup(struct dht * dht,
pthread_rwlock_wrlock(&dht->lock);
list_del(&lu->next);
pthread_rwlock_unlock(&dht->lock);
- lu->state = LU_COMPLETE;
return lu;
}
@@ -1554,6 +1560,7 @@ static struct lookup * kad_lookup(struct dht * dht,
pthread_rwlock_wrlock(&dht->lock);
list_del(&lu->next);
pthread_rwlock_unlock(&dht->lock);
+ lookup_set_state(lu, LU_COMPLETE);
return lu;
}
diff --git a/src/ipcpd/normal/flow_alloc.proto b/src/ipcpd/normal/flow_alloc.proto
index eb078674..03a69fe0 100644
--- a/src/ipcpd/normal/flow_alloc.proto
+++ b/src/ipcpd/normal/flow_alloc.proto
@@ -3,8 +3,8 @@
*
* Flow allocation message
*
- * Dimitri Staessens <[email protected]>
- * Sander Vrijders <[email protected]>
+ * Dimitri Staessens <[email protected]>
+ * Sander Vrijders <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
diff --git a/src/ipcpd/normal/kademlia.proto b/src/ipcpd/normal/kademlia.proto
index 2e2aec93..70f906a8 100644
--- a/src/ipcpd/normal/kademlia.proto
+++ b/src/ipcpd/normal/kademlia.proto
@@ -3,8 +3,8 @@
*
* KAD protocol
*
- * Dimitri Staessens <[email protected]>
- * Sander Vrijders <[email protected]>
+ * Dimitri Staessens <[email protected]>
+ * Sander Vrijders <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/src/ipcpd/normal/pol/fso.proto b/src/ipcpd/normal/pol/fso.proto
index 761d1f23..27a78efd 100644
--- a/src/ipcpd/normal/pol/fso.proto
+++ b/src/ipcpd/normal/pol/fso.proto
@@ -3,8 +3,8 @@
*
* Flow State Object message
*
- * Dimitri Staessens <[email protected]>
- * Sander Vrijders <[email protected]>
+ * Dimitri Staessens <[email protected]>
+ * Sander Vrijders <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
diff --git a/src/ipcpd/normal/sdu_sched.c b/src/ipcpd/normal/sdu_sched.c
index 10b0f02f..c7e799e2 100644
--- a/src/ipcpd/normal/sdu_sched.c
+++ b/src/ipcpd/normal/sdu_sched.c
@@ -38,9 +38,9 @@
#define FD_UPDATE_TIMEOUT 10000 /* nanoseconds */
struct sdu_sched {
- flow_set_t * set[QOS_CUBE_MAX];
- next_sdu_t callback;
- pthread_t sdu_readers[IPCP_SCHED_THREADS];
+ fset_t * set[QOS_CUBE_MAX];
+ next_sdu_t callback;
+ pthread_t sdu_readers[IPCP_SCHED_THREADS];
};
static void cleanup_reader(void * o)
@@ -80,7 +80,7 @@ static void * sdu_reader(void * o)
/* FIXME: replace with scheduling policy call */
i = (i + 1) % QOS_CUBE_MAX;
- ret = flow_event_wait(sched->set[i], fqs[i], &timeout);
+ ret = fevent(sched->set[i], fqs[i], &timeout);
if (ret == -ETIMEDOUT)
continue;
@@ -122,10 +122,10 @@ struct sdu_sched * sdu_sched_create(next_sdu_t callback)
sdu_sched->callback = callback;
for (i = 0; i < QOS_CUBE_MAX; ++i) {
- sdu_sched->set[i] = flow_set_create();
+ sdu_sched->set[i] = fset_create();
if (sdu_sched->set[i] == NULL) {
for (j = 0; j < i; ++j)
- flow_set_destroy(sdu_sched->set[j]);
+ fset_destroy(sdu_sched->set[j]);
goto fail_flow_set;
}
}
@@ -162,7 +162,7 @@ void sdu_sched_destroy(struct sdu_sched * sdu_sched)
}
for (i = 0; i < QOS_CUBE_MAX; ++i)
- flow_set_destroy(sdu_sched->set[i]);
+ fset_destroy(sdu_sched->set[i]);
free(sdu_sched);
}
@@ -175,7 +175,7 @@ void sdu_sched_add(struct sdu_sched * sdu_sched,
assert(sdu_sched);
ipcp_flow_get_qoscube(fd, &qc);
- flow_set_add(sdu_sched->set[qc], fd);
+ fset_add(sdu_sched->set[qc], fd);
}
void sdu_sched_del(struct sdu_sched * sdu_sched,
@@ -186,5 +186,5 @@ void sdu_sched_del(struct sdu_sched * sdu_sched,
assert(sdu_sched);
ipcp_flow_get_qoscube(fd, &qc);
- flow_set_del(sdu_sched->set[qc], fd);
+ fset_del(sdu_sched->set[qc], fd);
}