[coap] make CoAP start and stop reentrant (#5539)

This commit is contained in:
Simon Lin
2020-09-16 22:17:27 -07:00
committed by GitHub
parent d8cda7e610
commit 0c0e1dfe67
5 changed files with 11 additions and 8 deletions
+2 -1
View File
@@ -835,7 +835,8 @@ static inline otError otCoapSendRequest(otInstance * aInstance,
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The local UDP port to bind to.
*
* @retval OT_ERROR_NONE Successfully started the CoAP server.
* @retval OT_ERROR_NONE Successfully started the CoAP server.
* @retval OT_ERROR_FAILED Failed to start the CoAP server.
*
*/
otError otCoapStart(otInstance *aInstance, uint16_t aPort);
+2 -2
View File
@@ -64,10 +64,10 @@ public:
}
/**
* This method starts the TMF agent.
* This method starts the Backbone TMF agent.
*
* @retval OT_ERROR_NONE Successfully started the CoAP service.
* @retval OT_ERROR_ALREADY Already started.
* @retval OT_ERROR_FAILED Failed to start the Backbone TMF agent.
*
*/
otError Start(void);
+5 -3
View File
@@ -1017,10 +1017,10 @@ Coap::Coap(Instance &aInstance)
otError Coap::Start(uint16_t aPort, otNetifIdentifier aNetifIdentifier)
{
otError error;
otError error = OT_ERROR_NONE;
bool socketOpened = false;
VerifyOrExit(!mSocket.IsBound(), error = OT_ERROR_ALREADY);
VerifyOrExit(!mSocket.IsBound(), OT_NOOP);
SuccessOrExit(error = mSocket.Open(&Coap::HandleUdpReceive, this));
socketOpened = true;
@@ -1039,7 +1039,9 @@ exit:
otError Coap::Stop(void)
{
otError error;
otError error = OT_ERROR_NONE;
VerifyOrExit(mSocket.IsBound(), OT_NOOP);
SuccessOrExit(error = mSocket.Close());
ClearRequestsAndResponses();
+1 -1
View File
@@ -610,7 +610,7 @@ public:
* @param[in] aNetifIdentifier The network interface identifier to bind.
*
* @retval OT_ERROR_NONE Successfully started the CoAP service.
* @retval OT_ERROR_ALREADY Already started.
* @retval OT_ERROR_FAILED Failed to start CoAP agent.
*
*/
otError Start(uint16_t aPort, otNetifIdentifier aNetifIdentifier = OT_NETIF_UNSPECIFIED);
+1 -1
View File
@@ -67,7 +67,7 @@ public:
* This method starts the TMF agent.
*
* @retval OT_ERROR_NONE Successfully started the CoAP service.
* @retval OT_ERROR_ALREADY Already started.
* @retval OT_ERROR_FAILED Failed to start the TMF agent.
*
*/
otError Start(void);