mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
posix: improve error out for mlockall() and pthread_create
- add strerror - mlockall skipped in lockstep builds (ENABLE_LOCKSTEP_SCHEDULER)
This commit is contained in:
@@ -178,13 +178,13 @@ int main(int argc, char **argv)
|
|||||||
return client.process_args(argc, (const char **)argv);
|
return client.process_args(argc, (const char **)argv);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#if (_POSIX_MEMLOCK > 0)
|
#if (_POSIX_MEMLOCK > 0) && !defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
|
|
||||||
// try to lock address space into RAM, to avoid page swap delay
|
// try to lock address space into RAM, to avoid page swap delay
|
||||||
// TODO: Check CAP_IPC_LOCK instead of euid
|
// TODO: Check CAP_IPC_LOCK instead of euid
|
||||||
if (geteuid() == 0) { // root user
|
if (geteuid() == 0) { // root user
|
||||||
if (mlockall(MCL_CURRENT) + mlockall(MCL_FUTURE)) { // check if both works
|
if (mlockall(MCL_CURRENT | MCL_FUTURE)) { // check if both works
|
||||||
PX4_ERR("mlockall() failed! errno: %d", errno);
|
PX4_ERR("mlockall() failed! errno: %d (%s)", errno, strerror(errno));
|
||||||
munlockall(); // avoid mlock limitation caused alloc failure in future
|
munlockall(); // avoid mlock limitation caused alloc failure in future
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -192,7 +192,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // (_POSIX_MEMLOCK > 0) && !ENABLE_LOCKSTEP_SCHEDULER
|
||||||
|
|
||||||
/* Server/daemon apps need to parse the command line arguments. */
|
/* Server/daemon apps need to parse the command line arguments. */
|
||||||
|
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
|||||||
rv = pthread_create(&taskmap[taskid].pid, nullptr, &entry_adapter, (void *) taskdata);
|
rv = pthread_create(&taskmap[taskid].pid, nullptr, &entry_adapter, (void *) taskdata);
|
||||||
|
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
PX4_ERR("px4_task_spawn_cmd: failed to create thread %d %d\n", rv, errno);
|
PX4_ERR("px4_task_spawn_cmd: failed to create thread for %s (%i): %s", name, rv, strerror(rv));
|
||||||
taskmap[taskid].isused = false;
|
taskmap[taskid].isused = false;
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
pthread_mutex_unlock(&task_mutex);
|
pthread_mutex_unlock(&task_mutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user