summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-05-22 10:31:08 +0200
committerSander Vrijders <[email protected]>2016-05-22 10:31:08 +0200
commit5da36185bde40772eb46592fcda9a4636f1c5cd4 (patch)
treefd83242e72c0a8c2d33e0eec4aef344ff6b2f2c7 /src/lib/dev.c
parentd53fd8ef0228f287568cc51b87733780591308fc (diff)
parenta81e1dfb377ef3e53c2a158ea438f27773ceb25d (diff)
downloadouroboros-5da36185bde40772eb46592fcda9a4636f1c5cd4.tar.gz
ouroboros-5da36185bde40772eb46592fcda9a4636f1c5cd4.zip
Merged in dstaesse/ouroboros/be-dealloc (pull request #103)
lib, irmd, ipcpd: Flow deallocation over shim UDP
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 63cf92f7..d332a27f 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -202,6 +202,7 @@ int ap_reg(char ** difs,
rw_lock_wrlock(&_ap_instance->flows_lock);
fd = bmp_allocate(_ap_instance->fds);
+ _ap_instance->flows[fd].port_id = -1;
rw_lock_unlock(&_ap_instance->flows_lock);
rw_lock_unlock(&_ap_instance->data_lock);
@@ -299,8 +300,12 @@ int flow_accept(int fd,
rw_lock_rdlock(&_ap_instance->data_lock);
rw_lock_wrlock(&_ap_instance->flows_lock);
-
cfd = bmp_allocate(_ap_instance->fds);
+ if (!bmp_is_id_valid(_ap_instance->fds, cfd)) {
+ rw_lock_unlock(&_ap_instance->flows_lock);
+ rw_lock_unlock(&_ap_instance->data_lock);
+ return -1;
+ }
_ap_instance->flows[cfd].rb = shm_ap_rbuff_open(recv_msg->pid);
if (_ap_instance->flows[cfd].rb == NULL) {
@@ -405,7 +410,11 @@ int flow_alloc(char * dst_name,
rw_lock_wrlock(&_ap_instance->flows_lock);
fd = bmp_allocate(_ap_instance->fds);
-
+ if (!bmp_is_id_valid(_ap_instance->fds, fd)) {
+ rw_lock_unlock(&_ap_instance->flows_lock);
+ rw_lock_unlock(&_ap_instance->data_lock);
+ return -1;
+ }
_ap_instance->flows[fd].rb = shm_ap_rbuff_open(recv_msg->pid);
if (_ap_instance->flows[fd].rb == NULL) {
bmp_release(_ap_instance->fds, fd);