From a82ab4b7296e4e21711871b4da89500216a89ca6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 20 Jun 2017 11:23:31 -0600 Subject: [PATCH] mac802154_req_data() can return without releasing the exclsem --- configs/clicker2-stm32/README.txt | 8 ++++---- wireless/ieee802154/mac802154.c | 2 -- wireless/ieee802154/mac802154_data.c | 25 ++++++++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index 4789921809..c016313636 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -447,7 +447,7 @@ Configurations The ifconfig command will show the IP address of the server. Then on the client node use this IP address to start the client: - nsh> udpserver & + nsh> udpclient & Where is the IP address of the server that you got above. NOTE: There is no way to stop the UDP test once it has been started @@ -455,13 +455,13 @@ Configurations STATUS: 2017-06-19: The Telnet Daemon does not start. This is simply because - the daemon is started too early in the sequence... befor the network + the daemon is started too early in the sequence... before the network has been brought up: telnetd_daemon: ERROR: socket failure: 106 - Basic network bring-up sequence works. At least no errors are - reported. + 2017-06-20: I am get EINTR errors from the MAC layer when trying the + udpclient tries to send messages. Still under investigation. nsh: diff --git a/wireless/ieee802154/mac802154.c b/wireless/ieee802154/mac802154.c index 44068a6705..b7b4b3ca3e 100644 --- a/wireless/ieee802154/mac802154.c +++ b/wireless/ieee802154/mac802154.c @@ -169,7 +169,6 @@ int mac802154_txdesc_alloc(FAR struct ieee802154_privmac_s *priv, */ ret = sem_trywait(&priv->txdesc_sem); - if (ret == OK) { *txdesc = (FAR struct ieee802154_txdesc_s *)sq_remfirst(&priv->txdesc_queue); @@ -228,7 +227,6 @@ int mac802154_txdesc_alloc(FAR struct ieee802154_privmac_s *priv, } (*txdesc)->conf = ¬if->u.dataconf; - return OK; } diff --git a/wireless/ieee802154/mac802154_data.c b/wireless/ieee802154/mac802154_data.c index c97d55eddb..b51d31880f 100644 --- a/wireless/ieee802154/mac802154_data.c +++ b/wireless/ieee802154/mac802154_data.c @@ -147,7 +147,10 @@ int mac802154_req_data(MACHANDLE mac, ret = mac802154_takesem(&priv->exclsem, true); if (ret < 0) { - return ret; + /* Should only fail it interrupted by a signal */ + + wlwarn("WARNING: mac802154_takesem failed: %d", ret); + goto errout_with_sem; } /* If both destination and source addressing information is present, the MAC @@ -201,7 +204,8 @@ int mac802154_req_data(MACHANDLE mac, if (priv->devmode != IEEE802154_DEVMODE_PANCOORD) { - return -EINVAL; + ret = -EINVAL; + goto errout_with_sem; } } @@ -231,7 +235,8 @@ int mac802154_req_data(MACHANDLE mac, ret = mac802154_txdesc_alloc(priv, &txdesc, true); if (ret < 0) { - return ret; + wlwarn("WARNING: mac802154_txdesc_alloc failed: %d", ret); + goto errout_with_sem; } txdesc->conf->handle = meta->msdu_handle; @@ -259,11 +264,8 @@ int mac802154_req_data(MACHANDLE mac, * don't have to try and kick-off any transmission here. */ - /* We no longer need to have the MAC layer locked. */ - - mac802154_givesem(&priv->exclsem); - - return -ENOTSUP; + ret = -ENOTSUP; + goto errout_with_sem; } else { @@ -300,7 +302,8 @@ int mac802154_req_data(MACHANDLE mac, else { mac802154_givesem(&priv->exclsem); - return -EINVAL; + ret = -EINVAL; + goto errout_with_sem; } } else @@ -320,6 +323,10 @@ int mac802154_req_data(MACHANDLE mac, } return OK; + +errout_with_sem: + mac802154_givesem(&priv->exclsem); + return ret; } /****************************************************************************