summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-03-28 11:44:43 +0200
committerSander Vrijders <sander@ouroboros.rocks>2022-03-30 15:12:25 +0200
commitccc98e43268fbc0558290ab10c06511ddd4c0458 (patch)
tree5a368e2783ae394fa6f2d986cd4a583063018dc0
parent70b6509891d43f8beb081bb7d8c5b6f7e56576c6 (diff)
downloadouroboros-ccc98e43268fbc0558290ab10c06511ddd4c0458.tar.gz
ouroboros-ccc98e43268fbc0558290ab10c06511ddd4c0458.zip
lib: Remove flows list from fset
We don't need to iterate fsets anymore since the removal of fset_keepalive. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
-rw-r--r--src/lib/dev.c64
1 files changed, 2 insertions, 62 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index d950df03..135324ea 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -114,16 +114,8 @@ struct flow {
struct frcti * frcti;
};
-struct flow_set_entry {
- struct list_head next;
-
- int fd;
-};
-
struct flow_set {
size_t idx;
-
- struct list_head flows;
pthread_rwlock_t lock;
};
@@ -369,6 +361,7 @@ static void flow_fini(int fd)
pthread_cancel(ai.tx);
pthread_join(ai.tx, NULL);
}
+
frcti_destroy(ai.flows[fd].frcti);
}
@@ -1438,9 +1431,6 @@ struct flow_set * fset_create()
if (set == NULL)
goto fail_malloc;
- if (pthread_rwlock_init(&set->lock, NULL))
- goto fail_lock_init;
-
assert(ai.fqueues);
pthread_rwlock_wrlock(&ai.lock);
@@ -1451,14 +1441,10 @@ struct flow_set * fset_create()
pthread_rwlock_unlock(&ai.lock);
- list_head_init(&set->flows);
-
return set;
fail_bmp_alloc:
pthread_rwlock_unlock(&ai.lock);
- pthread_rwlock_destroy(&set->lock);
- fail_lock_init:
free(set);
fail_malloc:
return NULL;
@@ -1477,8 +1463,6 @@ void fset_destroy(struct flow_set * set)
pthread_rwlock_unlock(&ai.lock);
- pthread_rwlock_destroy(&set->lock);
-
free(set);
}
@@ -1502,23 +1486,9 @@ void fqueue_destroy(struct fqueue * fq)
void fset_zero(struct flow_set * set)
{
- struct list_head * p;
- struct list_head * h;
-
if (set == NULL)
return;
- pthread_rwlock_wrlock(&set->lock);
-
- list_for_each_safe(p, h, &set->flows) {
- struct flow_set_entry * e;
- e = list_entry(p, struct flow_set_entry, next);
- list_del(&e->next);
- free(e);
- }
-
- pthread_rwlock_unlock(&set->lock);
-
shm_flow_set_zero(ai.fqset, set->idx);
}
@@ -1526,7 +1496,6 @@ int fset_add(struct flow_set * set,
int fd)
{
struct flow * flow;
- struct flow_set_entry * fse;
int ret;
if (set == NULL || fd < 0 || fd >= SYS_MAX_FLOWS)
@@ -1534,12 +1503,6 @@ int fset_add(struct flow_set * set,
flow = &ai.flows[fd];
- fse = malloc(sizeof(*fse));
- if (fse == NULL)
- return -ENOMEM;
-
- fse->fd = fd;
-
pthread_rwlock_rdlock(&ai.lock);
if (flow->flow_id < 0) {
@@ -1551,12 +1514,6 @@ int fset_add(struct flow_set * set,
if (ret < 0)
goto fail;
- pthread_rwlock_wrlock(&set->lock);
-
- list_add_tail(&fse->next, &set->flows);
-
- pthread_rwlock_unlock(&set->lock);
-
if (shm_rbuff_queued(ai.flows[fd].rx_rb))
shm_flow_set_notify(ai.fqset, ai.flows[fd].flow_id, FLOW_PKT);
@@ -1566,16 +1523,13 @@ int fset_add(struct flow_set * set,
fail:
pthread_rwlock_unlock(&ai.lock);
- free(fse);
return ret;
}
void fset_del(struct flow_set * set,
int fd)
{
- struct list_head * p;
- struct list_head * h;
- struct flow * flow;
+ struct flow * flow;
if (set == NULL || fd < 0 || fd >= SYS_MAX_FLOWS)
return;
@@ -1587,20 +1541,6 @@ void fset_del(struct flow_set * set,
if (flow->flow_id >= 0)
shm_flow_set_del(ai.fqset, set->idx, flow->flow_id);
- pthread_rwlock_wrlock(&set->lock);
-
- list_for_each_safe(p, h, &set->flows) {
- struct flow_set_entry * e;
- e = list_entry(p, struct flow_set_entry, next);
- if (e->fd == fd) {
- list_del(&e->next);
- free(e);
- break;
- }
- }
-
- pthread_rwlock_unlock(&set->lock);
-
pthread_rwlock_unlock(&ai.lock);
}