summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-09 13:03:18 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-09 13:03:18 +0200
commit58bf8390779bfa61c03e9c4db0355f04c4d99f08 (patch)
treeecd24b0473e05ce9ebcc4ac086f78c85b8447ccd
parent1dde324905796df4d7e468d7f0de027bb8dcedae (diff)
downloadouroboros-58bf8390779bfa61c03e9c4db0355f04c4d99f08.tar.gz
ouroboros-58bf8390779bfa61c03e9c4db0355f04c4d99f08.zip
ipcpd: Fix locking of shim-eth-llc
This changes the amount of time the shim-eth-llc will hold the IPCP state lock when sending and receiving frames. Before it was holding the lock for too long.
-rw-r--r--src/ipcpd/shim-eth-llc/main.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index e2799c19..7471e319 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -746,7 +746,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
ntohs(size),
llc_frame->src_hwaddr);
} else {
- pthread_rwlock_rdlock(&_ipcp->state_lock);
pthread_rwlock_rdlock(&shim_data(_ipcp)->flows_lock);
i = addr_and_saps_to_index(llc_frame->src_hwaddr,
@@ -755,7 +754,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
if (i < 0) {
pthread_rwlock_unlock(&shim_data(_ipcp)->
flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
offset = (offset + 1)
& (SHM_BUFFER_SIZE - 1);
@@ -781,7 +779,6 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
;
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
}
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
offset = (offset + 1) & (SHM_BUFFER_SIZE -1);
@@ -803,9 +800,8 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
uint8_t dsap;
e = shm_ap_rbuff_read(shim_data(_ipcp)->rb);
- if (e == NULL) {
+ if (e == NULL)
continue;
- }
pthread_rwlock_rdlock(&_ipcp->state_lock);
@@ -813,12 +809,12 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
pthread_rwlock_unlock(&_ipcp->state_lock);
return (void *) 1; /* -ENOTENROLLED */
}
+ pthread_rwlock_unlock(&_ipcp->state_lock);
len = shm_du_map_read((uint8_t **) &buf,
shim_data(_ipcp)->dum,
e->index);
if (len <= 0) {
- pthread_rwlock_unlock(&_ipcp->state_lock);
free(e);
LOG_ERR("Length of du map read was %d.", len);
continue;
@@ -830,7 +826,6 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
if (i < 0) {
free(e);
pthread_rwlock_unlock(&shim_data(_ipcp)->flows_lock);
- pthread_rwlock_unlock(&_ipcp->state_lock);
continue;
}
@@ -846,8 +841,6 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
if (shim_data(_ipcp)->dum != NULL)
shm_du_map_remove(shim_data(_ipcp)->dum, e->index);
- pthread_rwlock_unlock(&_ipcp->state_lock);
-
free(e);
}