summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-eth-llc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/shim-eth-llc')
-rw-r--r--src/ipcpd/shim-eth-llc/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 5a80aa91..142ca680 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -347,19 +347,23 @@ static int eth_llc_ipcp_sap_req(uint8_t r_sap,
{
int fd;
- pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
+ pthread_mutex_lock(&ipcpi.alloc_lock);
/* reply to IRM, called under lock to prevent race */
fd = ipcp_flow_req_arr(getpid(), dst_name, cube);
if (fd < 0) {
+ pthread_mutex_unlock(&ipcpi.alloc_lock);
log_err("Could not get new flow from IRMd.");
return -1;
}
+ pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
+
eth_llc_data.fd_to_ef[fd].r_sap = r_sap;
memcpy(eth_llc_data.fd_to_ef[fd].r_addr, r_addr, MAC_SIZE);
pthread_rwlock_unlock(&eth_llc_data.flows_lock);
+ pthread_mutex_unlock(&ipcpi.alloc_lock);
log_dbg("New flow request, fd %d, remote SAP %d.", fd, r_sap);
@@ -536,14 +540,14 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
memset(br_addr, 0xff, MAC_SIZE * sizeof(uint8_t));
while (true) {
+ if (ipcp_get_state() != IPCP_OPERATIONAL)
+ return (void *) 0;
+
frame_len = recv(eth_llc_data.s_fd, buf,
SHIM_ETH_LLC_MAX_SDU_SIZE, 0);
if (frame_len < 0)
continue;
- if (ipcp_get_state() != IPCP_OPERATIONAL)
- return (void *) 0;
-
llc_frame = (struct eth_llc_frame *) buf;
#ifdef __FreeBSD__