Verified Commit 33ed8d2d authored by Vincent Coubard's avatar Vincent Coubard
Browse files

Log mutex release errors


Signed-off-by: Vincent Coubard's avatarVincent Coubard <vincent.coubard@arm.com>
parent 9254e295
......@@ -234,7 +234,7 @@ CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle,
size_t xLabelLength )
{
CK_RV xResult = CKR_OK;
BaseType_t xGotSemaphore;
osStatus_t xGotSemaphore;
CK_BBOOL xObjectFound = CK_FALSE;
int lInsertIndex = -1;
......@@ -282,7 +282,10 @@ CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle,
}
}
osMutexRelease( xP11Context.xObjectList.xMutex );
xGotSemaphore = osMutexRelease( xP11Context.xObjectList.xMutex );
if ( xGotSemaphore != osOK ) {
PKCS11_WARNING_PRINT( ( "WARNING: Failed to release mutex in prvAddObjectToList.\r\n" ) );
}
}
else
{
......@@ -1754,7 +1757,10 @@ CK_RV prvDeleteObjectFromList( CK_OBJECT_HANDLE xAppHandle )
xResult = CKR_OBJECT_HANDLE_INVALID;
}
osMutexRelease( xP11Context.xObjectList.xMutex );
xGotSemaphore = osMutexRelease( xP11Context.xObjectList.xMutex );
if ( xGotSemaphore != osOK ) {
PKCS11_WARNING_PRINT( ( "WARNING: Failed to release mutex in prvDeleteObjectFromList.\r\n" ) );
}
}
else
{
......@@ -2766,7 +2772,9 @@ CK_DEFINE_FUNCTION( CK_RV, C_SignInit )( CK_SESSION_HANDLE xSession,
pxSession->uxSignKey = 0;
xResult = CKR_KEY_HANDLE_INVALID;
}
osMutexRelease( pxSession->xSignMutex );
if ( osMutexRelease( pxSession->xSignMutex ) != osOK ) {
PKCS11_WARNING_PRINT( ( "WARNING: Failed to release mutex in C_SignInit.\r\n" ) );
}
}
else
{
......@@ -2934,7 +2942,9 @@ CK_DEFINE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE xSession,
}
}
osMutexRelease( pxSessionObj->xSignMutex );
if ( osMutexRelease( pxSessionObj->xSignMutex ) != osOK ) {
PKCS11_WARNING_PRINT( ( "WARNING: Failed to release mutex in C_Sign.\r\n" ) );
}
}
else
{
......@@ -3042,7 +3052,9 @@ CK_DEFINE_FUNCTION( CK_RV, C_VerifyInit )( CK_SESSION_HANDLE xSession,
xResult = CKR_KEY_HANDLE_INVALID;
}
osMutexRelease( pxSession->xVerifyMutex );
if ( osMutexRelease( pxSession->xVerifyMutex ) != osOK ) {
PKCS11_WARNING_PRINT( ( "WARNING: Failed to release mutex in C_VerifyInit.\r\n" ) );
}
}
else
{
......@@ -3201,7 +3213,10 @@ CK_DEFINE_FUNCTION( CK_RV, C_Verify )( CK_SESSION_HANDLE xSession,
xResult = CKR_FUNCTION_FAILED;
}
}
osMutexRelease( pxSessionObj->xVerifyMutex );
if ( osMutexRelease( pxSessionObj->xVerifyMutex ) != osOK ) {
PKCS11_WARNING_PRINT( ( "WARNING: Failed to release mutex in C_Verify.\r\n" ) );
}
}
else
{
......
......@@ -215,7 +215,10 @@ static void _networkReceiveTask( void * pArgument )
else
{
/* Set the flag to indicate that the receive task has exited. */
( void ) osEventFlagsSet( pNetworkConnection->connectionFlags, _FLAG_RECEIVE_TASK_EXITED );
uint32_t flags = osEventFlagsSet( pNetworkConnection->connectionFlags, _FLAG_RECEIVE_TASK_EXITED );
if ( flags & osFlagsError ) {
IotLogError( "Failed to notify exit of network reception task" );
}
}
osThreadExit();
......@@ -533,7 +536,9 @@ size_t IotNetworkAfr_Send( void * pConnection,
}
}
osMutexRelease( pNetworkConnection->socketMutex );
if ( osMutexRelease( pNetworkConnection->socketMutex ) != osOK ) {
IotLogError( "Failed to release socketMutex in IotNetworkAfr_Send" );
}
}
return bytesSent;
......@@ -665,7 +670,10 @@ IotNetworkError_t IotNetworkAfr_Close( void * pConnection )
_networkConnection_t * pNetworkConnection = ( _networkConnection_t * ) pConnection;
/* Set the shutdown flag so that the network receive task can stop polling. */
( void ) osEventFlagsSet( pNetworkConnection->connectionFlags, _FLAG_SHUTDOWN );
uint32_t flags = osEventFlagsSet( pNetworkConnection->connectionFlags, _FLAG_SHUTDOWN );
if ( flags & osFlagsError ) {
return IOT_NETWORK_SYSTEM_ERROR;
}
/* If this function is not called from the receive task, wait for the receive task to exit. */
if( ( pNetworkConnection->receiveTask != NULL ) && ( osThreadGetId() != pNetworkConnection->receiveTask ) )
......@@ -673,10 +681,13 @@ IotNetworkError_t IotNetworkAfr_Close( void * pConnection )
/* Wait for the network receive task to exit so that the socket can be shutdown safely
* without causing the socket to block forever if there are pending reads or writes
* from other tasks. Do not clear the flag as IotNetworkAfr_Destroy checks it. */
( void ) osEventFlagsWait( pNetworkConnection->connectionFlags,
flags = osEventFlagsWait( pNetworkConnection->connectionFlags,
_FLAG_RECEIVE_TASK_EXITED,
osFlagsNoClear | osFlagsWaitAll,
osWaitForever );
if ( flags & osFlagsError ) {
return IOT_NETWORK_SYSTEM_ERROR;
}
}
/* Call Secure Sockets shutdown function to close connection. */
......@@ -702,7 +713,10 @@ IotNetworkError_t IotNetworkAfr_Destroy( void * pConnection )
if( osThreadGetId() == pNetworkConnection->receiveTask )
{
/* Set the flag specifying that the connection is destroyed. */
( void ) osEventFlagsSet( pNetworkConnection->connectionFlags, _FLAG_RECEIVE_TASK_CONNECTION_DESTROYED );
uint32_t flags = osEventFlagsSet( pNetworkConnection->connectionFlags, _FLAG_RECEIVE_TASK_CONNECTION_DESTROYED );
if ( flags & osFlagsError ) {
return IOT_NETWORK_SYSTEM_ERROR;
}
}
else
{
......
......@@ -189,7 +189,7 @@ bool prIotMutexTimedLock( IotMutex_t * pMutex,
TickType_t timeout )
{
_IotSystemMutex_t * internalMutex = ( _IotSystemMutex_t * ) pMutex;
BaseType_t lockResult;
osStatus_t lockResult;
configASSERT( internalMutex != NULL );
......@@ -197,7 +197,7 @@ bool prIotMutexTimedLock( IotMutex_t * pMutex,
lockResult = osMutexAcquire( * pMutex, timeout );
return ( lockResult == true );
return ( lockResult == osOK );
}
/*-----------------------------------------------------------*/
......@@ -224,7 +224,10 @@ void IotMutex_Unlock( IotMutex_t * pMutex )
IotLogDebug( "Unlocking mutex %p.", internalMutex );
osMutexRelease( * pMutex );
osStatus_t lockResult = osMutexRelease( * pMutex );
if ( lockResult != osOK ) {
IotLogError( "Failed to unlock mutex %p.", internalMutex );
}
}
/*-----------------------------------------------------------*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment