Defer actually spawning the thread to the call to Run(). The way the thread manager is currently written as a whole won't correctly enforce the thread limit (looking into that, though I think a different approach entirely is merited here anyways), but this at least prevents large numbers of threads from being spawned and sitting in the suspended state in the registrar forever. Fixes ticket #3172.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28774 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5b188b1c9f
commit
83868e649d
@ -35,17 +35,12 @@ RegistrarThread::RegistrarThread(const char *name, int32 priority, BMessenger ma
|
||||
, fIsFinished(false)
|
||||
, fStatus(B_NO_INIT)
|
||||
, fId(-1)
|
||||
, fPriority(priority)
|
||||
{
|
||||
fName[0] = 0;
|
||||
status_t err = name && fManagerMessenger.IsValid() ? B_OK : B_BAD_VALUE;
|
||||
if (!err) {
|
||||
fId = spawn_thread(&RegistrarThread::EntryFunction, name,
|
||||
priority, (void*)this);
|
||||
err = fId >= 0 ? B_OK : fId;
|
||||
}
|
||||
if (!err) {
|
||||
if (err == B_OK)
|
||||
strcpy(fName, name);
|
||||
}
|
||||
fStatus = err;
|
||||
}
|
||||
|
||||
@ -72,8 +67,13 @@ status_t
|
||||
RegistrarThread::Run()
|
||||
{
|
||||
status_t err = InitCheck();
|
||||
if (!err)
|
||||
err = resume_thread(fId);
|
||||
if (err == B_OK) {
|
||||
fId = spawn_thread(&RegistrarThread::EntryFunction, fName,
|
||||
fPriority, (void*)this);
|
||||
err = fId >= 0 ? B_OK : fId;
|
||||
if (err == B_OK)
|
||||
err = resume_thread(fId);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ private:
|
||||
status_t fStatus;
|
||||
thread_id fId;
|
||||
char fName[B_OS_NAME_LENGTH];
|
||||
int32 fPriority;
|
||||
};
|
||||
|
||||
#endif // REGISTRAR_THREAD_H
|
||||
|
Loading…
Reference in New Issue
Block a user