Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlt-user: fix potential non closed socket in init/free #435

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

alexmohr
Copy link
Contributor

wait until the house keeper is up and running
this makes sure dlt_init / dlt_free in close succession closes this thread properly.
Otherwise we might keep the dlt socket open
Check if the thread is running every 10ms

The program was tested solely for our own use cases, which might differ from yours.
Licensed under Mozilla Public License Version 2.0

Alexander Mohr, [email protected], Mercedes-Benz Tech Innovation GmbH, imprint

{
struct timespec ts;
bool in_loop = true;
bool *thread_running = (bool*)ptr;
*thread_running = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @alexmohr ,
in which platform have you faced this issue?
I guess the assignment to true needs to be shifted below pthread_sigmask (for Android) and calling pthread_cleanup_push(). Otherwise a race condition still exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue occurs on linux but only in unit tests when running them on a very fast machine. I moved the call and replaced the sleep with a condition variable

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you very much.

* Check if the thread is running every 10ms
* */
while (!housekeeper_thread_running) {
usleep(10000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a semaphore instead? looping and sleeping is not that nice.

@alexmohr alexmohr force-pushed the startup-dlt-housekeeper branch from 783d419 to 6286c57 Compare January 20, 2023 11:06
wait until the house keeper is up and running
this makes sure dlt_init / dlt_free in close succession
closes this thread properly.
Otherwise we might keep the dlt socket open
Check if the thread is running every 10ms

Signed-off-by: Alexander Mohr <[email protected]>
@alexmohr alexmohr force-pushed the startup-dlt-housekeeper branch from 6286c57 to cb44b68 Compare January 20, 2023 11:07
@michael-methner michael-methner merged commit 73e1275 into COVESA:master Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants