Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Fix irq contexts #31

Merged
merged 2 commits into from
Aug 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions source/m2mconnectionhandlerpimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@
#include "eventOS_scheduler.h"

#include "mbed-trace/mbed_trace.h"
#include "mbed.h"

#define TRACE_GROUP "mClt"

#ifdef MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE
#define MBED_CLIENT_EVENT_LOOP_SIZE MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE
#else
#define MBED_CLIENT_EVENT_LOOP_SIZE 1024
#endif

int8_t M2MConnectionHandlerPimpl::_tasklet_id = -1;

static MemoryPool<M2MConnectionHandlerPimpl::TaskIdentifier, MBED_CLIENT_EVENT_LOOP_SIZE/64> memory_pool;

extern "C" void connection_tasklet_event_handler(arm_event_s *event)
{
tr_debug("M2MConnectionHandlerPimpl::connection_tasklet_event_handler");
Expand Down Expand Up @@ -73,7 +82,7 @@ extern "C" void connection_tasklet_event_handler(arm_event_s *event)
break;
}
if (task_id) {
free(task_id);
memory_pool.free(task_id);
}
}

Expand Down Expand Up @@ -148,7 +157,7 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
_server_port = server_port;
_server_type = server_type;
_server_address = server_address;
TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
return false;
}
Expand Down Expand Up @@ -255,7 +264,7 @@ bool M2MConnectionHandlerPimpl::send_data(uint8_t *data,
return false;
}

TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
free(buffer);
return false;
Expand Down Expand Up @@ -317,9 +326,7 @@ int8_t M2MConnectionHandlerPimpl::connection_tasklet_handler()

void M2MConnectionHandlerPimpl::socket_event()
{
tr_debug("M2MConnectionHandlerPimpl::socket_event()");

TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
_observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR, true);
return;
Expand Down