mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-06-09 21:22:41 +00:00
Unix: honor configured pthread stack size
This commit is contained in:
@@ -64,7 +64,7 @@ namespace VeraCrypt
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const size_t MinThreadStackSize = 1024 * 1024;
|
||||
static const size_t MinThreadStackSize = 8 * 1024 * 1024;
|
||||
|
||||
ThreadSystemHandle SystemHandle;
|
||||
|
||||
|
||||
@@ -18,6 +18,26 @@
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
namespace
|
||||
{
|
||||
struct PthreadAttr
|
||||
{
|
||||
PthreadAttr ()
|
||||
{
|
||||
int status = pthread_attr_init (&Attr);
|
||||
if (status != 0)
|
||||
throw SystemException (SRC_POS, status);
|
||||
}
|
||||
|
||||
~PthreadAttr ()
|
||||
{
|
||||
pthread_attr_destroy (&Attr);
|
||||
}
|
||||
|
||||
pthread_attr_t Attr;
|
||||
};
|
||||
}
|
||||
|
||||
void Thread::Join () const
|
||||
{
|
||||
int status = pthread_join (SystemHandle, nullptr);
|
||||
@@ -27,26 +47,22 @@ namespace VeraCrypt
|
||||
|
||||
void Thread::Start (ThreadProcPtr threadProc, void *parameter)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
PthreadAttr attr;
|
||||
size_t stackSize = 0;
|
||||
int status;
|
||||
|
||||
status = pthread_attr_init (&attr);
|
||||
if (status != 0)
|
||||
throw SystemException (SRC_POS, status);
|
||||
|
||||
status = pthread_attr_getstacksize (&attr, &stackSize);
|
||||
status = pthread_attr_getstacksize (&attr.Attr, &stackSize);
|
||||
if (status != 0)
|
||||
throw SystemException (SRC_POS, status);
|
||||
|
||||
if (stackSize < MinThreadStackSize)
|
||||
{
|
||||
status = pthread_attr_setstacksize (&attr, MinThreadStackSize);
|
||||
status = pthread_attr_setstacksize (&attr.Attr, MinThreadStackSize);
|
||||
if (status != 0)
|
||||
throw SystemException (SRC_POS, status);
|
||||
}
|
||||
|
||||
status = pthread_create (&SystemHandle, nullptr, threadProc, parameter);
|
||||
status = pthread_create (&SystemHandle, &attr.Attr, threadProc, parameter);
|
||||
if (status != 0)
|
||||
throw SystemException (SRC_POS, status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user