From 34e3101edd46de13a76b9295dd2180d2be43c6b0 Mon Sep 17 00:00:00 2001 From: Jeff Kaufman Date: Fri, 13 Sep 2013 10:07:41 -0400 Subject: [PATCH 1/2] reloading: backport reloading fix Issue #364 was fixed upstream in r3492. Backport the fix to master. "We only need to shut down the caches in child processes because they are not started in the master process. This wasn't a problem before, but shutting down the caches can start a thread which isn't safe to do in the master process of a forking server like Nginx." Also backport the change from r3497 where we use a DCHECK for may_start_threads_. It's bad to start threads in the root process, but it's not worth crashing a production server over. --- src/ngx_rewrite_driver_factory.cc | 3 +++ src/ngx_thread_system.cc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ngx_rewrite_driver_factory.cc b/src/ngx_rewrite_driver_factory.cc index e8235607b..73d1b6e0f 100644 --- a/src/ngx_rewrite_driver_factory.cc +++ b/src/ngx_rewrite_driver_factory.cc @@ -249,6 +249,9 @@ bool NgxRewriteDriverFactory::CheckResolver() { } void NgxRewriteDriverFactory::StopCacheActivity() { + if (is_root_process_) { + return; // No caches used in root process. + } RewriteDriverFactory::StopCacheActivity(); caches_->StopCacheActivity(); } diff --git a/src/ngx_thread_system.cc b/src/ngx_thread_system.cc index 81cac51f8..a5f3ca50e 100644 --- a/src/ngx_thread_system.cc +++ b/src/ngx_thread_system.cc @@ -29,7 +29,7 @@ NgxThreadSystem::NgxThreadSystem() : may_start_threads_(false) {} NgxThreadSystem::~NgxThreadSystem() {} void NgxThreadSystem::PermitThreadStarting() { - CHECK(!may_start_threads_); + DCHECK(!may_start_threads_); may_start_threads_ = true; } @@ -40,7 +40,7 @@ void NgxThreadSystem::BeforeThreadRunHook() { // If this fails you can get a backtrace from gdb by setting a breakpoint on // "pthread_create". - CHECK(may_start_threads_); + DCHECK(may_start_threads_); } } // namespace net_instaweb From f70eb5df40f5b0fc4481e69f4ef1477655f9890b Mon Sep 17 00:00:00 2001 From: Jud Porter Date: Tue, 24 Sep 2013 15:59:56 -0400 Subject: [PATCH 2/2] Add -Wno-unused-local-typedefs and -Wno-error to CFLAGS to fix build issues on GCC 4.8. --- config | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config b/config index c523aaaab..184397fbd 100644 --- a/config +++ b/config @@ -93,6 +93,24 @@ fi # linker errors, so disable it here. CFLAGS="$CFLAGS -DSERF_HTTPS_FETCHING=0 $FLAG_MARCH" +case "$NGX_GCC_VER" in + 4.8*) + # On GCC 4.8 and above, -Wall enables -Wunused-local-typedefs. This breaks + # on VerifySizesAreEqual in bit_cast in chromium/src/base/basictypes.h which + # has a typedef that is intentionally unused. + CFLAGS="$CFLAGS -Wno-unused-local-typedefs" + + # On GCC 4.8 and above, we get the following compiler warning: + # chromium/src/base/memory/scoped_ptr.h:133:7: warning: declaration of ‘class scoped_ptr’ [enabled by default] + # Based on discussion at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54055, + # this is invalid code, but hasn't been fixed yet in chromium. + # Unfortunately, there also does not appear to be a flag for just disabling + # that warning, so we add Wno-error to override nginx's default -Werror + # option. + CFLAGS="$CFLAGS -Wno-error" + ;; +esac + pagespeed_include="\ $mod_pagespeed_dir \ $mod_pagespeed_dir/third_party/chromium/src \