Browse files

Add 4MB stack size code to mongod SERVER-2707

  • Loading branch information...
1 parent 2a3b5f7 commit 3d590b6dd6fc1d7135bf41fb954158db59e5ae30 @RedBeard0531 RedBeard0531 committed Aug 12, 2011
Showing with 21 additions and 0 deletions.
  1. +21 −0 db/db.cpp
View
21 db/db.cpp
@@ -108,7 +108,28 @@ namespace mongo {
}
try {
+#ifndef __linux__ // TODO: consider making this ifdef _WIN32
boost::thread thr(boost::bind(&connThread,mp));
+#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;
+ pthread_attr_setstacksize(&attrs, (DEBUG_BUILD
+ ? (STACK_SIZE / 2)
+ : STACK_SIZE));
+
+ pthread_t thread;
+ int failed = pthread_create(&thread, &attrs, (void*(*)(void*)) &connThread, mp);
+
+ 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& ) {
log() << "can't create new thread, closing connection" << endl;

0 comments on commit 3d590b6

Please sign in to comment.