susumu.yata
null+****@clear*****
Fri Mar 1 14:42:46 JST 2013
susumu.yata 2013-03-01 14:42:46 +0900 (Fri, 01 Mar 2013) New Revision: aac8b5d2477f0fda7a51cee1dc7a39e838c5d29f https://github.com/groonga/grnxx/commit/aac8b5d2477f0fda7a51cee1dc7a39e838c5d29f Log: Use pthread_atfork() iff available. Modified files: configure.ac lib/internal_clock.cpp Modified: configure.ac (+4 -7) =================================================================== --- configure.ac 2013-03-01 13:50:24 +0900 (16aacdd) +++ configure.ac 2013-03-01 14:42:46 +0900 (d1e7ebf) @@ -34,15 +34,12 @@ if test "x$enable_backtrace" != "xno"; then AC_CHECK_LIB([bfd], [bfd_openr]) fi -# Checks for header files. - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. #AC_CHECK_LIB([rt], [clock_gettime]) +AC_CHECK_LIB([pthread], [pthread_create]) AC_CHECK_LIB([pthread], [pthread_create], - [AM_CXXFLAGS="${AM_CXXFLAGS} -pthread" - LIBS="${LIBS} -lpthread"]) + [AM_CXXFLAGS="${AM_CXXFLAGS} -pthread"]) + +AC_CHECK_FUNCS([pthread_atfork]) AC_CONFIG_FILES([Makefile lib/Makefile Modified: lib/internal_clock.cpp (+8 -3) =================================================================== --- lib/internal_clock.cpp 2013-03-01 13:50:24 +0900 (37bddae) +++ lib/internal_clock.cpp 2013-03-01 14:42:46 +0900 (930769b) @@ -17,7 +17,11 @@ */ #include "internal_clock.hpp" -#include <pthread.h> +#include "../config.h" + +#ifdef HAVE_PTHREAD_ATFORK +# include <pthread.h> +#endif // HAVE_PTHREAD_ATFORK #include <thread> @@ -56,14 +60,15 @@ void start_internal_clock() { return; } +#ifdef HAVE_PTHREAD_ATFORK // Start a new thread, if fork() is invoked, on the child process. int error = ::pthread_atfork(nullptr, nullptr, start_internal_clock); if (error != 0) { - // TODO: Error handling. + // The current process works well even if this failed. GRNXX_WARNING() << "failed to set a fork handler: '::pthread_atfork' " << Error(error); - // The current process works well even if this failed. } +#endif // HAVE_PTHREAD_ATFORK *internal_time = SystemClock::now(); } -------------- next part -------------- HTML����������������������������... 다운로드