PIThread more accurate end, PIEthernet tcpserver client no reinit

This commit is contained in:
2024-09-17 13:22:20 +03:00
parent b99c51181d
commit f105f616f6
3 changed files with 9 additions and 5 deletions

View File

@@ -919,6 +919,10 @@ void PIThread::_runThread() {
void PIThread::_endThread() {
PIScopeExitCall ec([this] {
terminating = running_ = false;
tid_ = -1;
});
// PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "...";
stopped();
// PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
@@ -927,8 +931,6 @@ void PIThread::_endThread() {
end();
// PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
if (lockRun) thread_mutex.unlock();
terminating = running_ = false;
tid_ = -1;
// PICout(PICoutManipulators::DefaultControls) << "thread" << this << "exit";
// cout << "thread " << t << " exiting ... " << endl;
// PICout(PICoutManipulators::DefaultControls) << "pthread_exit" << (__privateinitializer__.p)->thread;
@@ -943,7 +945,7 @@ void PIThread::_endThread() {
#elif defined(FREERTOS)
PRIVATE->thread = 0;
#else
pthread_detach(PRIVATE->thread);
// pthread_detach(PRIVATE->thread);
PRIVATE->thread = 0;
pthread_exit(0);
#endif