public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Aggressively report threading errors and associated system settings.
Hongli Lai (Phusion) (author)
Fri Apr 04 08:50:14 -0700 2008
commit  81a559e153dd27becbd874880edd7a4046a664e3
tree    b900ea8c3f274a5dd3f68bde5eb2acb4a1eadebc
parent  e4b22d11e5ae8dd121fef08fc8bc8d2c3c3054b8
...
528
529
530
 
 
531
532
533
...
544
545
546
547
 
 
 
 
 
 
548
549
550
...
528
529
530
531
532
533
534
535
...
546
547
548
 
549
550
551
552
553
554
555
556
557
0
@@ -528,6 +528,8 @@ public:
0
    * @throws SystemException An error occured while trying to setup the spawn server
0
    * or the server socket.
0
    * @throws IOException The specified log file could not be opened.
0
+ * @throws boost::thread_resource_error A threading resource could not be
0
+ * allocated or initialized.
0
    */
0
   ApplicationPoolServer(const string &spawnServerCommand,
0
    const string &logFile = "",
0
@@ -544,7 +546,12 @@ public:
0
     connectSocket = fds[1];
0
     done = false;
0
     detached = false;
0
- serverThread = new thread(bind(&ApplicationPoolServer::serverThreadMainLoop, this));
0
+ try {
0
+ serverThread = new thread(bind(&ApplicationPoolServer::serverThreadMainLoop, this));
0
+ } catch (const thread_resource_error &e) {
0
+ throw thread_resource_error("Could not create the ApplicationPoolServer "
0
+ "server main loop thread", e.native_error());
0
+ }
0
   }
0
   
0
   ~ApplicationPoolServer() {
...
27
28
29
 
 
30
31
32
...
540
541
542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
544
545
...
27
28
29
30
31
32
33
34
...
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
0
@@ -27,6 +27,8 @@
0
 #include <apr_strings.h>
0
 #include <apr_lib.h>
0
 
0
+#include <sys/time.h>
0
+#include <sys/resource.h>
0
 #include <exception>
0
 #include <unistd.h>
0
 
0
@@ -540,6 +542,43 @@ init_module(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *
0
         destroy_hooks,
0
         apr_pool_cleanup_null);
0
       return OK;
0
+ } catch (const thread_resource_error &e) {
0
+ struct rlimit lim;
0
+ string pthread_threads_max;
0
+
0
+ lim.rlim_cur = 0;
0
+ lim.rlim_max = 0;
0
+ getrlimit(RLIMIT_NPROC, &lim);
0
+ #ifdef PTHREAD_THREADS_MAX
0
+ pthread_threads_max = toString(PTHREAD_THREADS_MAX);
0
+ #else
0
+ pthread_threads_max = "unknown";
0
+ #endif
0
+
0
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
0
+ "*** Passenger could not be initialize because a "
0
+ "threading resource could not be allocated or initialized. "
0
+ "The error message is:");
0
+ fprintf(stderr,
0
+ " %s\n\n"
0
+ "System settings:\n"
0
+ " RLIMIT_NPROC: soft = %d, hard = %d\n"
0
+ " PTHREAD_THREADS_MAX: %s\n"
0
+ "\n",
0
+ e.what(),
0
+ (int) lim.rlim_cur, (int) lim.rlim_max,
0
+ pthread_threads_max.c_str());
0
+
0
+ fprintf(stderr, "Output of 'uname -a' follows:\n");
0
+ fflush(stderr);
0
+ system("uname -a >&2");
0
+
0
+ fprintf(stderr, "\nOutput of 'ulimit -a' follows:\n");
0
+ fflush(stderr);
0
+ system("ulimit -a >&2");
0
+
0
+ return DECLINED;
0
+
0
     } catch (const exception &e) {
0
       ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
0
         "*** Passenger could not be initialized because of this error: %s",

Comments

    No one has commented yet.