Commit f45a930e by Marcus Winter

mtapi_c: fixed minor bugs

parent 7a2f4425
...@@ -412,6 +412,7 @@ void mtapi_action_enable( ...@@ -412,6 +412,7 @@ void mtapi_action_enable(
embb_mtapi_action_pool_get_storage_for_handle( embb_mtapi_action_pool_get_storage_for_handle(
node->action_pool, action); node->action_pool, action);
local_action->enabled = MTAPI_TRUE; local_action->enabled = MTAPI_TRUE;
local_status = MTAPI_SUCCESS;
} else { } else {
local_status = MTAPI_ERR_ACTION_INVALID; local_status = MTAPI_ERR_ACTION_INVALID;
} }
......
...@@ -37,12 +37,12 @@ void embb_mtapi_id_pool_initialize( ...@@ -37,12 +37,12 @@ void embb_mtapi_id_pool_initialize(
that->capacity = capacity; that->capacity = capacity;
that->id_buffer = (mtapi_uint_t*) that->id_buffer = (mtapi_uint_t*)
embb_mtapi_alloc_allocate(sizeof(mtapi_uint_t)*(capacity)); embb_mtapi_alloc_allocate(sizeof(mtapi_uint_t)*(capacity + 1));
that->id_buffer[0] = EMBB_MTAPI_IDPOOL_INVALID_ID; that->id_buffer[0] = EMBB_MTAPI_IDPOOL_INVALID_ID;
for (ii = 1; ii < capacity; ii++) { for (ii = 1; ii <= capacity; ii++) {
that->id_buffer[ii] = ii; that->id_buffer[ii] = ii;
} }
that->ids_available = capacity - 1; that->ids_available = capacity;
that->put_id_position = 0; that->put_id_position = 0;
that->get_id_position = 1; that->get_id_position = 1;
embb_mtapi_spinlock_initialize(&that->lock); embb_mtapi_spinlock_initialize(&that->lock);
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
mtapi_boolean_t embb_mtapi_job_initialize_list(embb_mtapi_node_t * node) { mtapi_boolean_t embb_mtapi_job_initialize_list(embb_mtapi_node_t * node) {
node->job_list = (embb_mtapi_job_t*)embb_mtapi_alloc_allocate( node->job_list = (embb_mtapi_job_t*)embb_mtapi_alloc_allocate(
sizeof(embb_mtapi_job_t)*node->attributes.max_jobs); sizeof(embb_mtapi_job_t)*(node->attributes.max_jobs + 1));
mtapi_uint_t ii; mtapi_uint_t ii;
for (ii = 0; ii < node->attributes.max_jobs; ii++) { for (ii = 0; ii <= node->attributes.max_jobs; ii++) {
embb_mtapi_job_initialize( embb_mtapi_job_initialize(
&node->job_list[ii], node->attributes.max_actions_per_job); &node->job_list[ii], node->attributes.max_actions_per_job);
node->job_list[ii].handle.id = ii; node->job_list[ii].handle.id = ii;
...@@ -53,7 +53,7 @@ mtapi_boolean_t embb_mtapi_job_initialize_list(embb_mtapi_node_t * node) { ...@@ -53,7 +53,7 @@ mtapi_boolean_t embb_mtapi_job_initialize_list(embb_mtapi_node_t * node) {
void embb_mtapi_job_finalize_list(embb_mtapi_node_t * node) { void embb_mtapi_job_finalize_list(embb_mtapi_node_t * node) {
mtapi_uint_t ii; mtapi_uint_t ii;
for (ii = 0; ii < node->attributes.max_jobs; ii++) { for (ii = 0; ii <= node->attributes.max_jobs; ii++) {
embb_mtapi_job_finalize(&node->job_list[ii]); embb_mtapi_job_finalize(&node->job_list[ii]);
node->job_list[ii].handle.id = 0; node->job_list[ii].handle.id = 0;
} }
...@@ -69,7 +69,7 @@ mtapi_boolean_t embb_mtapi_job_is_handle_valid( ...@@ -69,7 +69,7 @@ mtapi_boolean_t embb_mtapi_job_is_handle_valid(
mtapi_job_hndl_t handle) { mtapi_job_hndl_t handle) {
assert(MTAPI_NULL != node); assert(MTAPI_NULL != node);
return ((0 < handle.id) && return ((0 < handle.id) &&
(handle.id < node->attributes.max_jobs) && (handle.id <= node->attributes.max_jobs) &&
(node->job_list[handle.id].handle.tag == handle.tag)) ? (node->job_list[handle.id].handle.tag == handle.tag)) ?
MTAPI_TRUE : MTAPI_FALSE; MTAPI_TRUE : MTAPI_FALSE;
} }
...@@ -87,7 +87,7 @@ mtapi_boolean_t embb_mtapi_job_is_id_valid( ...@@ -87,7 +87,7 @@ mtapi_boolean_t embb_mtapi_job_is_id_valid(
embb_mtapi_node_t * node, embb_mtapi_node_t * node,
mtapi_job_id_t id) { mtapi_job_id_t id) {
assert(MTAPI_NULL != node); assert(MTAPI_NULL != node);
return ((0 < id) && (id < node->attributes.max_jobs)) ? return ((0 < id) && (id <= node->attributes.max_jobs)) ?
MTAPI_TRUE : MTAPI_FALSE; MTAPI_TRUE : MTAPI_FALSE;
} }
......
...@@ -60,8 +60,8 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \ ...@@ -60,8 +60,8 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \
assert(MTAPI_NULL != that); \ assert(MTAPI_NULL != that); \
embb_mtapi_id_pool_initialize(&that->id_pool, capacity); \ embb_mtapi_id_pool_initialize(&that->id_pool, capacity); \
that->storage = (embb_mtapi_##TYPE##_t*)embb_mtapi_alloc_allocate( \ that->storage = (embb_mtapi_##TYPE##_t*)embb_mtapi_alloc_allocate( \
sizeof(embb_mtapi_##TYPE##_t)*capacity); \ sizeof(embb_mtapi_##TYPE##_t)*(capacity + 1)); \
for (ii = 0; ii < capacity; ii++) { \ for (ii = 0; ii <= capacity; ii++) { \
that->storage[ii].handle.id = EMBB_MTAPI_IDPOOL_INVALID_ID; \ that->storage[ii].handle.id = EMBB_MTAPI_IDPOOL_INVALID_ID; \
that->storage[ii].handle.tag = 0; \ that->storage[ii].handle.tag = 0; \
} \ } \
...@@ -102,7 +102,7 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_is_handle_valid( \ ...@@ -102,7 +102,7 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_is_handle_valid( \
mtapi_##TYPE##_hndl_t handle) { \ mtapi_##TYPE##_hndl_t handle) { \
assert(MTAPI_NULL != that); \ assert(MTAPI_NULL != that); \
return ((0 < handle.id) && \ return ((0 < handle.id) && \
(handle.id < that->id_pool.capacity) && \ (handle.id <= that->id_pool.capacity) && \
(that->storage[handle.id].handle.tag == handle.tag)) ? \ (that->storage[handle.id].handle.tag == handle.tag)) ? \
MTAPI_TRUE : MTAPI_FALSE; \ MTAPI_TRUE : MTAPI_FALSE; \
} \ } \
......
...@@ -200,6 +200,7 @@ mtapi_queue_hndl_t mtapi_queue_create( ...@@ -200,6 +200,7 @@ mtapi_queue_hndl_t mtapi_queue_create(
queue->queue_id = queue_id; queue->queue_id = queue_id;
queue_hndl = queue->handle; queue_hndl = queue->handle;
} else { } else {
embb_mtapi_queue_pool_deallocate(node->queue_pool, queue);
local_status = MTAPI_ERR_JOB_INVALID; local_status = MTAPI_ERR_JOB_INVALID;
} }
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment