diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-08-23 08:47:17 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-08-23 08:47:17 +0200 |
commit | cbe2d992e9cd1ea66af9fa91df006106775d3073 (patch) | |
tree | fca8e11a8ab7f063ae26802016068f9c814f6176 /util | |
parent | 64b33ee522375a8dc15be2875dfb7db4502259b0 (diff) | |
download | mongodb-cbe2d992e9cd1ea66af9fa91df006106775d3073.tar.gz |
Imported Upstream version 1.8.3
Diffstat (limited to 'util')
-rw-r--r-- | util/message_server_port.cpp | 33 | ||||
-rw-r--r-- | util/version.cpp | 2 |
2 files changed, 34 insertions, 1 deletions
diff --git a/util/message_server_port.cpp b/util/message_server_port.cpp index 76bd78d..409b0c7 100644 --- a/util/message_server_port.cpp +++ b/util/message_server_port.cpp @@ -26,6 +26,10 @@ #include "../db/lasterror.h" #include "../db/stats/counters.h" +#ifdef __linux__ +# include <sys/resource.h> +#endif + namespace mongo { namespace pms { @@ -105,7 +109,36 @@ namespace mongo { } try { +#ifndef __linux__ // TODO: consider making this ifdef _WIN32 boost::thread thr( boost::bind( &pms::threadRun , p ) ); +#else + pthread_attr_t attrs; + pthread_attr_init(&attrs); + pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED); + + static const size_t STACK_SIZE = 4*1024*1024; + + struct rlimit limits; + assert(getrlimit(RLIMIT_STACK, &limits) == 0); + if (limits.rlim_cur > STACK_SIZE) { + pthread_attr_setstacksize(&attrs, (DEBUG_BUILD + ? (STACK_SIZE / 2) + : STACK_SIZE)); + } + else if (limits.rlim_cur < 1024*1024) { + warning() << "Stack size set to " << (limits.rlim_cur/1024) << "KB. We suggest at least 1MB" << endl; + } + + pthread_t thread; + int failed = pthread_create(&thread, &attrs, (void*(*)(void*)) &pms::threadRun, p); + + pthread_attr_destroy(&attrs); + + if (failed) { + log() << "pthread_create failed: " << errnoWithDescription(failed) << endl; + throw boost::thread_resource_error(); // for consistency with boost::thread + } +#endif } catch ( boost::thread_resource_error& ) { connTicketHolder.release(); diff --git a/util/version.cpp b/util/version.cpp index 78a31be..4045cb5 100644 --- a/util/version.cpp +++ b/util/version.cpp @@ -27,7 +27,7 @@ namespace mongo { - const char versionString[] = "1.8.2"; + const char versionString[] = "1.8.3"; string mongodVersion() { stringstream ss; |