Skip to content

Commit

Permalink
Update Agent to treat MQTTNeedMoreBytes correctly (#103)
Browse files Browse the repository at this point in the history
* Update MQTT Agent to treat MQTTNeedMoreBytes correctly
  • Loading branch information
AniruddhaKanhere authored Aug 28, 2023
1 parent a991b39 commit d3668a6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
config: .github/memory_statistics_config.json
check_against: docs/doxygen/include/size_table.md
proof_ci:
runs-on: cbmc_ubuntu-latest_16-core
runs-on: cbmc_ubuntu-latest_64-core
steps:
- name: Set up CBMC runner
uses: FreeRTOS/CI-CD-Github-Actions/set_up_cbmc_runner@main
Expand Down
1 change: 1 addition & 0 deletions lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ mqtteventcallback
mqttfixedbuffer
mqttgetcurrenttimefunc
mqttkeepalivetimeout
mqttneedmorebytes
mqttnomemory
mqttnotconnected
mqttpublishinfo
Expand Down
6 changes: 6 additions & 0 deletions source/core_mqtt_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,12 @@ static MQTTStatus_t processCommand( MQTTAgentContext_t * pMqttAgentContext,
} while( pMqttAgentContext->packetReceivedInLoop );
}

if( operationStatus == MQTTNeedMoreBytes )
{
/* Reset the operation status as MQTTNeedMoreBytes is not an error condition. */
operationStatus = MQTTSuccess;
}

/* Set the flag to break from the command loop. */
*pEndLoop = ( commandOutParams.endLoop || ( operationStatus != MQTTSuccess ) );

Expand Down
4 changes: 4 additions & 0 deletions test/cbmc/proofs/MQTTAgent_CommandLoop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ MAX_BOUND_FOR_COMMAND_LOOP=3
# the loop 2 times will be enough for proving memory safety.
MAX_BOUND_FOR_PROCESS_COMMAND_LOOP=2

# Force CBMC to only use the AgentMessageRecvStub function as the pointee of
# the recv function.
RESTRICT_FUNCTION_POINTER += MQTTAgent_CommandLoop.function_pointer_call.1/AgentMessageRecvStub

DEFINES += -DMQTT_AGENT_MAX_OUTSTANDING_ACKS=$(MQTT_AGENT_MAX_OUTSTANDING_ACKS)

INCLUDES +=
Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/mqtt_agent_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ void test_MQTTAgent_CommandLoop_NoCommand_NoData( void )

mqttStatus = MQTTAgent_CommandLoop( &mqttAgentContext );

TEST_ASSERT_EQUAL( MQTTNeedMoreBytes, mqttStatus );
TEST_ASSERT_EQUAL( MQTTSuccess, mqttStatus );
}

/**
Expand Down

0 comments on commit d3668a6

Please sign in to comment.