Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1e487de2
authored
9 years ago
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_c: fixed bug causing mtapi_task_wait to hang when a task was cancelled before it was running
parent
2152437a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
mtapi_c/src/embb_mtapi_scheduler_t.c
+25
-1
mtapi_c/src/embb_mtapi_task_t.c
+6
-1
No files found.
mtapi_c/src/embb_mtapi_scheduler_t.c
View file @
1e487de2
...
...
@@ -40,6 +40,7 @@
#include <embb_mtapi_action_t.h>
#include <embb_mtapi_alloc.h>
#include <embb_mtapi_queue_t.h>
#include <embb_mtapi_group_t.h>
/* ---- CLASS MEMBERS ------------------------------------------------------ */
...
...
@@ -293,6 +294,8 @@ int embb_mtapi_scheduler_worker(void * arg) {
/* check if there was work */
if
(
MTAPI_NULL
!=
task
)
{
embb_mtapi_queue_t
*
local_queue
=
MTAPI_NULL
;
embb_mtapi_group_t
*
local_group
=
MTAPI_NULL
;
embb_mtapi_action_t
*
local_action
=
MTAPI_NULL
;
/* is task associated with a queue? */
if
(
embb_mtapi_queue_pool_is_handle_valid
(
...
...
@@ -302,6 +305,21 @@ int embb_mtapi_scheduler_worker(void * arg) {
node
->
queue_pool
,
task
->
queue
);
}
/* is task associated with a group? */
if
(
embb_mtapi_group_pool_is_handle_valid
(
node
->
group_pool
,
task
->
group
))
{
local_group
=
embb_mtapi_group_pool_get_storage_for_handle
(
node
->
group_pool
,
task
->
group
);
}
if
(
embb_mtapi_action_pool_is_handle_valid
(
node
->
action_pool
,
task
->
action
))
{
local_action
=
embb_mtapi_action_pool_get_storage_for_handle
(
node
->
action_pool
,
task
->
action
);
}
switch
(
embb_atomic_load_int
(
&
task
->
state
))
{
case
MTAPI_TASK_SCHEDULED
:
/* multi-instance task, another instance might be running */
...
...
@@ -328,7 +346,7 @@ int embb_mtapi_scheduler_worker(void * arg) {
break
;
case
MTAPI_TASK_CANCELLED
:
/* set return value to canceled */
/* set return value to cancel
l
ed */
task
->
error_code
=
MTAPI_ERR_ACTION_CANCELLED
;
if
(
embb_atomic_fetch_and_add_unsigned_int
(
&
task
->
instances_todo
,
(
unsigned
int
)
-
1
)
==
0
)
{
...
...
@@ -336,6 +354,12 @@ int embb_mtapi_scheduler_worker(void * arg) {
if
(
MTAPI_NULL
!=
local_queue
)
{
embb_mtapi_queue_task_finished
(
local_queue
);
}
if
(
MTAPI_NULL
!=
local_group
)
{
embb_mtapi_task_queue_push
(
&
local_group
->
queue
,
task
);
}
}
if
(
MTAPI_NULL
!=
local_action
)
{
embb_atomic_fetch_and_add_int
(
&
local_action
->
num_tasks
,
-
1
);
}
break
;
...
...
This diff is collapsed.
Click to expand it.
mtapi_c/src/embb_mtapi_task_t.c
View file @
1e487de2
...
...
@@ -501,7 +501,6 @@ void mtapi_task_cancel(
if
(
embb_mtapi_task_pool_is_handle_valid
(
node
->
task_pool
,
task
))
{
embb_mtapi_task_t
*
local_task
=
embb_mtapi_task_pool_get_storage_for_handle
(
node
->
task_pool
,
task
);
embb_mtapi_task_set_state
(
local_task
,
MTAPI_TASK_CANCELLED
);
/* call plugin action cancel function */
if
(
embb_mtapi_action_pool_is_handle_valid
(
...
...
@@ -511,8 +510,14 @@ void mtapi_task_cancel(
node
->
action_pool
,
local_task
->
action
);
if
(
local_action
->
is_plugin_action
)
{
local_action
->
plugin_task_cancel_function
(
task
,
&
local_status
);
}
else
{
embb_mtapi_task_set_state
(
local_task
,
MTAPI_TASK_CANCELLED
);
local_task
->
error_code
=
MTAPI_ERR_ACTION_CANCELLED
;
local_status
=
MTAPI_SUCCESS
;
}
}
else
{
embb_mtapi_task_set_state
(
local_task
,
MTAPI_TASK_CANCELLED
);
local_task
->
error_code
=
MTAPI_ERR_ACTION_CANCELLED
;
local_status
=
MTAPI_SUCCESS
;
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment