diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-05-15 02:26:27 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-05-15 02:26:27 +0200 |
commit | cbd6ccb7fa372832715b0e143c816f569bd07ccd (patch) | |
tree | 0c56baf121efc4e603fe8abbfe0d5cf40d7e28ec /src | |
parent | a64d33fb44f30196711108311896cdbe711cc4d3 (diff) | |
download | ouroboros-cbd6ccb7fa372832715b0e143c816f569bd07ccd.tar.gz ouroboros-cbd6ccb7fa372832715b0e143c816f569bd07ccd.zip |
lib: irmd: fixed flow deallocation
Port_id's weren't correctly released. Also removes remaining debug
logs from the library.
Diffstat (limited to 'src')
-rw-r--r-- | src/irmd/main.c | 2 | ||||
-rw-r--r-- | src/lib/dev.c | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 65c173de..9c515d2a 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1059,6 +1059,8 @@ static int flow_dealloc(int port_id) list_del(&e->next); + bmp_release(instance->port_ids, port_id); + pthread_mutex_unlock(&instance->r_lock); free(e); diff --git a/src/lib/dev.c b/src/lib/dev.c index 440f40f9..4b5e56be 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -163,10 +163,8 @@ int ap_reg(char ** difs, return -EINVAL; } - if (_ap_instance == NULL) { - LOG_DBG("ap_init was not called."); - return -1; - } + if (_ap_instance == NULL) + return -1; /* -ENOTINIT */ msg.code = IRM_MSG_CODE__IRM_AP_REG; msg.has_pid = true; @@ -468,11 +466,16 @@ int flow_dealloc(int fd) msg.code = IRM_MSG_CODE__IRM_FLOW_DEALLOC; msg.has_port_id = true; - - rw_lock_rdlock(&_ap_instance->data_lock); + rw_lock_rdlock(&_ap_instance->flows_lock); msg.port_id = _ap_instance->flows[fd].port_id; + rw_lock_unlock(&_ap_instance->flows_lock); + + rw_lock_wrlock(&_ap_instance->data_lock); + + bmp_release(_ap_instance->fds, fd); + rw_lock_unlock(&_ap_instance->data_lock); recv_msg = send_recv_irm_msg(&msg); @@ -556,7 +559,7 @@ ssize_t flow_write(int fd, void * buf, size_t count) return 0; } else { while (shm_ap_rbuff_write(_ap_instance->flows[fd].rb, &e) < 0) - LOG_DBGF("Couldn't write to rbuff."); + ; } rw_lock_unlock(&_ap_instance->data_lock); |