diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-12-19 12:55:07 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-12-19 12:55:07 +0000 |
commit | 2a77e3d16dd3abdab49b7b178a31d34ac8d1c444 (patch) | |
tree | d9bcde359bae1aa87696ab8bc7107a0041349d8a /vespamalloc | |
parent | 6b079a1349eb8bdb3768de25cd7ae163642d7035 (diff) |
Abort on out of threads.
Diffstat (limited to 'vespamalloc')
-rw-r--r-- | vespamalloc/src/vespamalloc/malloc/malloc.h | 2 | ||||
-rw-r--r-- | vespamalloc/src/vespamalloc/malloc/threadproxy.cpp | 27 |
2 files changed, 19 insertions, 10 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/malloc.h b/vespamalloc/src/vespamalloc/malloc/malloc.h index 9ce62e4f00d..b3131ac5cbb 100644 --- a/vespamalloc/src/vespamalloc/malloc/malloc.h +++ b/vespamalloc/src/vespamalloc/malloc/malloc.h @@ -23,7 +23,7 @@ public: void setReturnAddressStop(const void * returnAddressStop) override { MemBlockPtrT::Stack::setStopAddress(returnAddressStop); } - virtual size_t getMaxNumThreads() const override { return _threadList.getMaxNumThreads(); } + size_t getMaxNumThreads() const override { return _threadList.getMaxNumThreads(); } void *malloc(size_t sz); void *realloc(void *oldPtr, size_t sz); diff --git a/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp b/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp index c1b8f05ee98..fd3a1748b92 100644 --- a/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp +++ b/vespamalloc/src/vespamalloc/malloc/threadproxy.cpp @@ -68,15 +68,17 @@ void * mallocThreadProxy (void * arg) } -extern "C" VESPA_DLL_EXPORT int local_pthread_create (pthread_t *thread, - const pthread_attr_t *attrOrg, - void * (*start_routine) (void *), - void * arg) __asm__("pthread_create"); - -VESPA_DLL_EXPORT int local_pthread_create (pthread_t *thread, - const pthread_attr_t *attrOrg, - void * (*start_routine) (void *), - void * arg) +extern "C" VESPA_DLL_EXPORT int +local_pthread_create (pthread_t *thread, + const pthread_attr_t *attrOrg, + void * (*start_routine) (void *), + void * arg) __asm__("pthread_create"); + +VESPA_DLL_EXPORT int +local_pthread_create (pthread_t *thread, + const pthread_attr_t *attrOrg, + void * (*start_routine) (void *), + void * arg) { size_t numThreads = _G_threadCount; while ((numThreads < vespamalloc::_G_myMemP->getMaxNumThreads()) @@ -84,7 +86,14 @@ VESPA_DLL_EXPORT int local_pthread_create (pthread_t *thread, { } if (numThreads >= vespamalloc::_G_myMemP->getMaxNumThreads()) { +#if 1 + // Just abort when max threads are reached. + // Future option is to make the behaviour optional. + fprintf (stderr, "All %ld threads are active! Aborting so you can start again.\n", numThreads); + abort(); +#else return EAGAIN; +#endif } // A pointer to the library version of pthread_create. static pthread_create_function real_pthread_create = NULL; |