summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/pff.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-28 08:38:05 +0000
committerdimitri staessens <dimitri.staessens@ugent.be>2017-03-28 08:38:05 +0000
commitba13c05b8b61365ff9e969c15affd2e1d52b76ed (patch)
treebaa5d6178914dd12106845ca81c81b63e4249c6f /src/ipcpd/normal/pff.c
parent7ee6dadd39f3d4b5874d23bfcdcdd66eb195124e (diff)
parent6d080d9b9ee2e480717935e4ce94870fc87ea5f7 (diff)
downloadouroboros-ba13c05b8b61365ff9e969c15affd2e1d52b76ed.tar.gz
ouroboros-ba13c05b8b61365ff9e969c15affd2e1d52b76ed.zip
Merged in sandervrijders/ouroboros/be-upd-graph (pull request #426)
Be upd graph
Diffstat (limited to 'src/ipcpd/normal/pff.c')
-rw-r--r--src/ipcpd/normal/pff.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/ipcpd/normal/pff.c b/src/ipcpd/normal/pff.c
index 77c2c551..c26c2263 100644
--- a/src/ipcpd/normal/pff.c
+++ b/src/ipcpd/normal/pff.c
@@ -60,9 +60,7 @@ void pff_destroy(struct pff * instance)
{
assert(instance);
- pthread_mutex_lock(&instance->lock);
htable_destroy(instance->table);
- pthread_mutex_unlock(&instance->lock);
pthread_mutex_destroy(&instance->lock);
free(instance);
@@ -89,13 +87,10 @@ int pff_add(struct pff * instance, uint64_t addr, int fd)
return -ENOMEM;
*val = fd;
- pthread_mutex_lock(&instance->lock);
if (htable_insert(instance->table, addr, val)) {
- pthread_mutex_unlock(&instance->lock);
free(val);
return -1;
}
- pthread_mutex_unlock(&instance->lock);
return 0;
}
@@ -111,19 +106,15 @@ int pff_update(struct pff * instance, uint64_t addr, int fd)
return -ENOMEM;
*val = fd;
- pthread_mutex_lock(&instance->lock);
if (htable_delete(instance->table, addr)) {
- pthread_mutex_unlock(&instance->lock);
free(val);
return -1;
}
if (htable_insert(instance->table, addr, val)) {
- pthread_mutex_unlock(&instance->lock);
free(val);
return -1;
}
- pthread_mutex_unlock(&instance->lock);
return 0;
}
@@ -132,12 +123,8 @@ int pff_remove(struct pff * instance, uint64_t addr)
{
assert(instance);
- pthread_mutex_lock(&instance->lock);
- if (htable_delete(instance->table, addr)) {
- pthread_mutex_unlock(&instance->lock);
+ if (htable_delete(instance->table, addr))
return -1;
- }
- pthread_mutex_unlock(&instance->lock);
return 0;
}
@@ -146,9 +133,7 @@ void pff_flush(struct pff * instance)
{
assert(instance);
- pthread_mutex_lock(&instance->lock);
htable_flush(instance->table);
- pthread_mutex_unlock(&instance->lock);
}
int pff_nhop(struct pff * instance, uint64_t addr)
@@ -158,14 +143,11 @@ int pff_nhop(struct pff * instance, uint64_t addr)
assert(instance);
- pthread_mutex_lock(&instance->lock);
j = (int *) htable_lookup(instance->table, addr);
if (j == NULL) {
- pthread_mutex_unlock(&instance->lock);
return -1;
}
fd = *j;
- pthread_mutex_unlock(&instance->lock);
return fd;
}