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