From fa1590539e66c17902bb4f09221e6447b3233bfb Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 5 Apr 2017 11:55:57 +0200 Subject: ipcpd: shim-eth-llc: Fix state check in reader The state check should be done first to avoid blocking on the recv call. --- src/ipcpd/shim-eth-llc/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index 5a80aa91..d42e6fff 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -536,14 +536,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__ -- cgit v1.2.3