summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-05-15 16:14:13 +0200
committerSander Vrijders <[email protected]>2016-05-15 16:14:13 +0200
commit061758159ebfd38fe03682bd3aa44cf9f8ac915f (patch)
tree0a26ce8198ab305846da06570d336355791e2c30 /src/lib/dev.c
parent37a0ce98538c69b264898b7994fbac1d6e465a2f (diff)
parent5fe9706b823cd441703239ece020e517d722d88c (diff)
downloadouroboros-061758159ebfd38fe03682bd3aa44cf9f8ac915f.tar.gz
ouroboros-061758159ebfd38fe03682bd3aa44cf9f8ac915f.zip
Merged in dstaesse/ouroboros/release-fd (pull request #89)
lib: cleanup file descriptors for shared memory
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 4b5e56be..55e4dc17 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -249,6 +249,9 @@ int flow_accept(int fd,
irm_msg_t * recv_msg = NULL;
int cfd = -1;
+ if (ap_name == NULL)
+ return -1;
+
msg.code = IRM_MSG_CODE__IRM_FLOW_ACCEPT;
msg.has_pid = true;
@@ -466,11 +469,13 @@ int flow_dealloc(int fd)
msg.code = IRM_MSG_CODE__IRM_FLOW_DEALLOC;
msg.has_port_id = true;
- rw_lock_rdlock(&_ap_instance->flows_lock);
+ rw_lock_wrlock(&_ap_instance->flows_lock);
msg.port_id = _ap_instance->flows[fd].port_id;
- rw_lock_unlock(&_ap_instance->flows_lock);
+ _ap_instance->flows[fd].port_id = -1;
+ shm_ap_rbuff_close(_ap_instance->flows[fd].rb);
+ _ap_instance->flows[fd].rb = NULL;
rw_lock_wrlock(&_ap_instance->data_lock);
@@ -478,6 +483,8 @@ int flow_dealloc(int fd)
rw_lock_unlock(&_ap_instance->data_lock);
+ rw_lock_unlock(&_ap_instance->flows_lock);
+
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
return -1;