Skip to content

Commit

Permalink
Test change: misc resource accounting fixes. (#1123)
Browse files Browse the repository at this point in the history
A few further (non-critical) resource account fixes:

- the leak checking in the sockets tests was left using the old "ask the heap how much it has free" memory checking, which doesn't always work correctly (depending on how the underlying heap implementation re-coalesces blocks); it is now moved to use the more organised counting method that all of the other tests use,
- to make this work, the cellular socket clean-up function now removes the cellular sockets-related URCs (which would normally just be removed when the AT client is taken down),
- the test utility function uTestUtilGetDynamicResourceCount() wasn't allowing for perpetually-allocated resources correctly; it is now,
- the Linux I2C resource count wasn't being decremented correctly; it is now,
- the test sockUdpEchoNonPingPong() wasn't running the Wifi portion of the test due to a loop variable not being reset; it is now.
  • Loading branch information
RobMeades committed Mar 17, 2024
1 parent f62f008 commit 3ffd36f
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 331 deletions.
2 changes: 1 addition & 1 deletion cell/api/u_cell_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern "C" {

/** The maximum size of a datagram and the maximum size of a
* single TCP segment sent to the cellular module (defined by the
* cellular module AT interface). Note the if hex mode is
* cellular module AT interface). Note that if hex mode is
set (using uCellSockHexModeOn()) then the number is halved.
*/
#define U_CELL_SOCK_MAX_SEGMENT_SIZE_BYTES 1024
Expand Down
16 changes: 12 additions & 4 deletions cell/src/u_cell_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,7 @@ int32_t uCellSockInitInstance(uDeviceHandle_t cellHandle)
void uCellSockDeinit()
{
if (gInitialised) {
// Nothing to do, URCs will have been
// removed on close
// Nothing to do; URCs are removed by clean-up function
gInitialised = false;
}
}
Expand Down Expand Up @@ -938,8 +937,17 @@ int32_t uCellSockClose(uDeviceHandle_t cellHandle,
// Clean-up.
void uCellSockCleanup(uDeviceHandle_t cellHandle)
{
// Nothing to do
(void) cellHandle;
uCellPrivateInstance_t *pInstance;

pInstance = pUCellPrivateGetInstance(cellHandle);
if (pInstance != NULL) {
// Remove the URCs
for (size_t x = 0; x < sizeof(gUrcHandlers) /
sizeof(gUrcHandlers[0]); x++) {
uAtClientRemoveUrcHandler(pInstance->atHandle,
gUrcHandlers[x].pPrefix);
}
}
}

/* ----------------------------------------------------------------
Expand Down
Loading

0 comments on commit 3ffd36f

Please sign in to comment.