Patrik Schnellmann <[EMAIL PROTECTED]> writes:
> I've reported a bug for the Debian package libapache2-mod-shib which
> depends on liblog4cpp. The problem apparently are threading issues
> which are solved with the patch below. Please also make sure the package
> is compiled with pthread support.
Which is ideally don'e with configure changes. I think there's another
threading fix besides this one as well. I analyzed the complete diff
between the current Debian package and the log4cpp package distributed by
the Shibboleth folks, and I think the following patch would do it.
I haven't tested a compile yet, though.
Fathi, I'm happy to help with an upload or anything else that's needed.
Could you let me know if you need any help in updating this package? I
can try to test the patched version as well.
--- log4cpp-0.3.5-rc3/configure.in 2005-07-29 03:50:28.000000000 -0700
+++ log4cpp-0.3.5rc1/configure.in 2004-10-20 15:05:59.000000000 -0700
@@ -29,14 +29,31 @@
# ----------------------------------------------------------------------------
AC_CANONICAL_HOST
+AC_ARG_ENABLE(debug,
+ AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default =
no)]),
+ enable_debug=$enableval, enable_debug=no)
+
+if test "$enable_debug" = "yes" ; then
+ GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
+ GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
+else
+ GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
+ GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
+fi
+
AM_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_CXX([g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC QCC])
+if test "$GCC" = "yes" ; then
+ CFLAGS="$GCC_CFLAGS"
+ CXXFLAGS="$GCC_CXXFLAGS"
+fi
+
AC_PROG_CXXCPP
-AC_LANG(C++)
+AC_LANG(C)
# Checks header files
# ----------------------------------------------------------------------------
@@ -46,13 +63,8 @@
# Checks local idioms
# ----------------------------------------------------------------------------
AC_C_INT64_T
-AC_CXX_HAVE_SSTREAM
AC_FUNC_SNPRINTF
-
-# syslog_test
-AC_CHECK_FUNCS([syslog])
-AC_CHECK_FUNCS([gettimeofday])
-AC_CHECK_FUNCS([ftime])
+AC_CHECK_FUNCS([syslog gettimeofday ftime localtime_r gmtime_r])
# Checks for libraries
# ----------------------------------------------------------------------------
@@ -61,6 +73,23 @@
AC_CHECK_LIB(socket,socket, LIBS="-lsocket $LIBS",,)
AC_CHECK_LIB(nsl,gethostbyname, LIBS="-lnsl $LIBS",,)
+# checks for pthreads
+ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
+if test $enable_threads != "pthread"; then
+ AC_MSG_ERROR([unable to find pthreads, currently this is required])
+else
+ AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and
header files.])
+ AC_DEFINE(HAVE_THREADING,1,[define if threading is enabled])
+ AC_DEFINE(USE_PTHREADS,1,[define if pthread library is available])
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
+ CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
+fi
+
+AC_LANG(C++)
+
+AC_CXX_HAVE_SSTREAM
+
# idsa_test
if test "x$with_idsa" = xyes; then
AC_CHECK_LIB([idsa], [idsa_open])
@@ -74,8 +103,8 @@
BB_ENABLE_DOXYGEN
# check for omnithreads
-BB_CHECK_OMNITHREADS
-BB_CHECK_PTHREADS
+#BB_CHECK_OMNITHREADS
+#BB_CHECK_PTHREADS
LOG4CPP_CFLAGS="$CXXFLAGS"
LOG4CPP_LIBS="-llog4cpp"
--- log4cpp-0.3.5-rc3/src/Appender.cpp 2002-10-26 18:48:52.000000000 -0700
+++ log4cpp-0.3.5rc1/src/Appender.cpp 2004-10-26 13:08:28.000000000 -0700
@@ -11,14 +11,11 @@
#include <log4cpp/Appender.hh>
namespace log4cpp {
- Appender::AppenderMap* Appender::_allAppenders;
threading::Mutex Appender::_appenderMapMutex;
/* assume _appenderMapMutex locked */
Appender::AppenderMap& Appender::_getAllAppenders() {
- if (!_allAppenders)
- _allAppenders = new Appender::AppenderMap();
-
+ static Appender::AppenderMap* _allAppenders = new
Appender::AppenderMap();
return *_allAppenders;
}
--- log4cpp-0.3.5-rc3/src/PatternLayout.cpp 2005-04-12 07:49:15.000000000
-0700
+++ log4cpp-0.3.5rc1/src/PatternLayout.cpp 2004-10-15 19:11:43.000000000
-0700
@@ -150,7 +150,12 @@
virtual void append(std::ostringstream& out, const LoggingEvent&
event) {
struct tm *currentTime;
time_t t = event.timeStamp.getSeconds();
+#ifdef LOG4CPP_HAVE_LOCALTIME_R
+ struct tm currentTime_var;
+ currentTime = ::localtime_r(&t, ¤tTime_var);
+#else
currentTime = std::localtime(&t);
+#endif
char formatted[100];
std::string timeFormat;
if (_printMillis) {
@@ -253,7 +258,7 @@
PatternLayout::PatternLayout() {
try {
setConversionPattern(DEFAULT_CONVERSION_PATTERN);
- } catch(ConfigureFailure&) {
+ } catch(ConfigureFailure& e) {
}
}
--
Russ Allbery ([EMAIL PROTECTED]) <http://www.eyrie.org/~eagle/>
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]