diff options
author | Sander Vrijders <[email protected]> | 2017-03-27 11:53:20 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-03-28 10:25:46 +0200 |
commit | 9e3dffb25570fc12dd43f8fad721be40374ea35b (patch) | |
tree | 9865b01cd1d946e4657ce3d459440ea15bcc3bc8 /src/ipcpd/normal/pff.c | |
parent | 8fd39fd9e1cc65147a6f1a3fa5027c9ab2cb4a68 (diff) | |
download | ouroboros-9e3dffb25570fc12dd43f8fad721be40374ea35b.tar.gz ouroboros-9e3dffb25570fc12dd43f8fad721be40374ea35b.zip |
ipcpd: normal: Fix locking of PFF
This adds fixes the locking of the PFF which was externalized, but not
yet correctly updated within the PFF component itself and within the
flow manager.
Diffstat (limited to 'src/ipcpd/normal/pff.c')
-rw-r--r-- | src/ipcpd/normal/pff.c | 20 |
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; } |