Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
84015e5c
Commit
84015e5c
authored
8 years ago
by
Beat Küng
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
logger: proper error handling if writer thread creation fails
parent
72263eaa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/modules/logger/log_writer.cpp
+3
-8
3 additions, 8 deletions
src/modules/logger/log_writer.cpp
src/modules/logger/log_writer.h
+6
-1
6 additions, 1 deletion
src/modules/logger/log_writer.h
src/modules/logger/logger.cpp
+7
-2
7 additions, 2 deletions
src/modules/logger/logger.cpp
with
16 additions
and
11 deletions
src/modules/logger/log_writer.cpp
+
3
−
8
View file @
84015e5c
...
...
@@ -48,7 +48,7 @@ void LogWriter::stop_log()
notify
();
}
pthread_
t
LogWriter
::
thread_start
()
in
t
LogWriter
::
thread_start
(
pthread_t
&
thread
)
{
pthread_attr_t
thr_attr
;
pthread_attr_init
(
&
thr_attr
);
...
...
@@ -60,15 +60,10 @@ pthread_t LogWriter::thread_start()
pthread_attr_setstacksize
(
&
thr_attr
,
1024
);
pthread_t
thr
;
if
(
0
!=
pthread_create
(
&
thr
,
&
thr_attr
,
&
LogWriter
::
run_helper
,
this
))
{
PX4_WARN
(
"error creating logwriter thread"
);
}
int
ret
=
pthread_create
(
&
thread
,
&
thr_attr
,
&
LogWriter
::
run_helper
,
this
);
pthread_attr_destroy
(
&
thr_attr
);
return
thr
;
return
ret
;
}
void
LogWriter
::
thread_stop
()
...
...
This diff is collapsed.
Click to expand it.
src/modules/logger/log_writer.h
+
6
−
1
View file @
84015e5c
...
...
@@ -17,7 +17,12 @@ class LogWriter
public:
LogWriter
(
uint8_t
*
buffer
,
size_t
buffer_size
);
pthread_t
thread_start
();
/**
* start the thread
* @param thread will be set to the created thread on success
* @return 0 on success, error number otherwise (@see pthread_create)
*/
int
thread_start
(
pthread_t
&
thread
);
void
thread_stop
();
...
...
This diff is collapsed.
Click to expand it.
src/modules/logger/logger.cpp
+
7
−
2
View file @
84015e5c
...
...
@@ -402,7 +402,12 @@ void Logger::run()
// add_topic("estimator_status");
add_topic
(
"vehicle_status"
,
100
);
_writer_thread
=
_writer
.
thread_start
();
int
ret
=
_writer
.
thread_start
(
_writer_thread
);
if
(
ret
)
{
PX4_ERR
(
"logger: failed to create writer thread (%i)"
,
ret
);
return
;
}
_task_should_exit
=
false
;
...
...
@@ -584,7 +589,7 @@ void Logger::run()
_writer
.
notify
();
// wait for thread to complete
int
ret
=
pthread_join
(
_writer_thread
,
NULL
);
ret
=
pthread_join
(
_writer_thread
,
NULL
);
if
(
ret
)
{
PX4_WARN
(
"join failed: %d"
,
ret
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment