mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-06 04:40:35 +08:00
px4_task_spawn_cmd: handle case properly when running out of unused taskmap items
This commit is contained in:
@@ -233,6 +233,13 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= PX4_MAX_TASKS) {
|
||||
pthread_attr_destroy(&attr);
|
||||
pthread_mutex_unlock(&task_mutex);
|
||||
free(taskdata);
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
rv = pthread_create(&taskmap[taskid].pid, &attr, &entry_adapter, (void *) taskdata);
|
||||
|
||||
if (rv != 0) {
|
||||
@@ -261,10 +268,6 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
pthread_attr_destroy(&attr);
|
||||
pthread_mutex_unlock(&task_mutex);
|
||||
|
||||
if (i >= PX4_MAX_TASKS) {
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user