From 58bf8390779bfa61c03e9c4db0355f04c4d99f08 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 9 Aug 2016 13:03:18 +0200 Subject: 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. --- src/ipcpd/shim-eth-llc/main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3