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

Remove Thread::kill() and related unittest #10317

Merged
merged 3 commits into from Sep 10, 2020
Merged

Remove Thread::kill() and related unittest #10317

merged 3 commits into from Sep 10, 2020

Conversation

semarie
Copy link
Contributor

@semarie semarie commented Aug 24, 2020

The Thread kill() method isn't used outside testThreadKill unit test
and Thread destructor. It could be make private.

The testThreadKill test should be removed: it tests the kill() feature
in a way minetest doesn't use it (kill and restart a thread), specially
because some pthreads implementations on BSD will not allow to lock
again the m_start_finished_mutex which is hold when the thread is
killed.

Closes: #6065

This PR is Ready for Review.

Eventually, the Thread::kill() method could be merged inside Thread::~Thread()

@sfan5 sfan5 added the Bugfix 🐛 PRs that fix a bug label Aug 24, 2020
src/threading/thread.h Outdated Show resolved Hide resolved
@nerzhul
Copy link
Member

nerzhul commented Aug 31, 2020

if we use only kill on our test, it's just a useless method. Drop it, less maintenance to do on dead called code :)

@pyrollo
Copy link
Contributor

pyrollo commented Aug 31, 2020

It is still called by Thread destructor. I guess the code could be moved there then.

@nerzhul
Copy link
Member

nerzhul commented Sep 1, 2020

i agree with you @pyrollo

@semarie
Copy link
Contributor Author

semarie commented Sep 2, 2020 via email

The Thread kill() method isn't used outside testThreadKill unit test
and Thread destructor. It could be make private.

The testThreadKill test should be removed: it tests the kill() feature
in a way minetest doesn't use it (kill and restart a thread), specially
because some pthreads implementations on BSD will not allow to lock
again the m_start_finished_mutex which is hold when the thread is
killed.

Closes: #6065
@pyrollo
Copy link
Contributor

pyrollo commented Sep 6, 2020

Looks good to me but I have no BSD setup to test on.

@semarie
Copy link
Contributor Author

semarie commented Sep 6, 2020 via email

@semarie semarie changed the title make Thread::kill() private remove Thread::kill() Sep 7, 2020
src/threading/thread.cpp Show resolved Hide resolved
@semarie
Copy link
Contributor Author

semarie commented Sep 8, 2020 via email

@sfan5 sfan5 changed the title remove Thread::kill() Remove Thread::kill() and related unittest Sep 8, 2020
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

Looks fine.

Comment on lines 96 to 98
m_retval = nullptr;
m_joinable = false;
m_request_stop = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as Nerzhul told above, these assignments are useless now.

@pyrollo
Copy link
Contributor

pyrollo commented Sep 9, 2020

Ok for me once superfluous assignments removed.

@semarie
Copy link
Contributor Author

semarie commented Sep 9, 2020 via email

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

Works on Linux.

@pyrollo
Copy link
Contributor

pyrollo commented Sep 10, 2020

Performing a test on (virtual) Windows before merging.

@pyrollo pyrollo merged commit 3fb1f45 into minetest:master Sep 10, 2020
@semarie semarie deleted the thread-kill-private branch September 10, 2020 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mutex unlock issue
5 participants