diff options
Diffstat (limited to 'libs/pbd/pthread_utils.cc')
-rw-r--r-- | libs/pbd/pthread_utils.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index db242cea7b..3408f2c0b7 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -43,6 +43,16 @@ pthread_create_and_store (string name, pthread_t *thread, pthread_attr_t *attr, { int ret; + pthread_attr_t default_attr; + bool use_default_attr = (attr == NULL); + + if (use_default_attr) { + // set default stack size to sensible default for memlocking + pthread_attr_init(&default_attr); + pthread_attr_setstacksize(&default_attr, 500000); + attr = &default_attr; + } + if ((ret = pthread_create (thread, attr, start_routine, arg)) == 0) { std::pair<string,pthread_t> newpair; newpair.first = name; @@ -53,6 +63,10 @@ pthread_create_and_store (string name, pthread_t *thread, pthread_attr_t *attr, pthread_mutex_unlock (&thread_map_lock); } + + if (use_default_attr) { + pthread_attr_destroy(&default_attr); + } return ret; } |