Author: carnold
Date: Tue Jul 1 08:13:58 2008
New Revision: 673097
URL: http://svn.apache.org/viewvc?rev=673097&view=rev
Log:
LOGCXX-282: Thread::sleep not affected by Thread::interrupt, requires version
bump
Modified:
logging/log4cxx/trunk/build.xml
logging/log4cxx/trunk/pom.xml
logging/log4cxx/trunk/src/changes/changes.xml
logging/log4cxx/trunk/src/main/cpp/socketappenderskeleton.cpp
logging/log4cxx/trunk/src/main/cpp/synchronized.cpp
logging/log4cxx/trunk/src/main/cpp/threadcxx.cpp
logging/log4cxx/trunk/src/main/include/log4cxx/helpers/synchronized.h
logging/log4cxx/trunk/src/main/include/log4cxx/helpers/thread.h
logging/log4cxx/trunk/src/main/include/log4cxx/net/socketappenderskeleton.h
logging/log4cxx/trunk/src/test/cpp/Makefile.am
Modified: logging/log4cxx/trunk/build.xml
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/build.xml?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/build.xml (original)
+++ logging/log4cxx/trunk/build.xml Tue Jul 1 08:13:58 2008
@@ -90,7 +90,7 @@
<property name="lib.name" value="log4cxx"/>
<property name="lib.prefix" value=""/>
-<property name="version" value="0.10.1"/>
+<property name="version" value="0.11.0"/>
<property name="enable-char" value="1"/>
<property name="enable-wchar_t" value="1"/>
<property name="enable-unichar" value="0"/>
Modified: logging/log4cxx/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/pom.xml?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/pom.xml (original)
+++ logging/log4cxx/trunk/pom.xml Tue Jul 1 08:13:58 2008
@@ -3,7 +3,7 @@
<groupId>log4cxx</groupId>
<artifactId>apache-log4cxx</artifactId>
<packaging>pom</packaging>
- <version>0.10.1-SNAPSHOT</version>
+ <version>0.11.0-SNAPSHOT</version>
<name>Apache log4cxx</name>
<description>Logging framework for C++.</description>
<url>http://logging.apache.org:80/log4cxx</url>
Modified: logging/log4cxx/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/changes/changes.xml?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/changes/changes.xml (original)
+++ logging/log4cxx/trunk/src/changes/changes.xml Tue Jul 1 08:13:58 2008
@@ -22,7 +22,7 @@
<title>Apache log4cxx</title>
</properties>
<body>
-<release version="0.10.1" date="2008-XX-XX" description="Maintenance release">
+<release version="0.11.0" date="2008-XX-XX" description="Maintenance release">
<action issue="LOGCXX-249">Console appender crashes if layout is not
set</action>
<action issue="LOGCXX-262">socketappendertestcase and
xmlsocketappendertestcase not run</action>
<action issue="LOGCXX-263">Bad link to log4cxx-dev archive</action>
@@ -31,13 +31,14 @@
<action issue="LOGCXX-267">Local variables hide member variables</action>
<action issue="LOGCXX-270">Add ability to compile out logging by logging
level.</action>
<action issue="LOGCXX-271">MDC::put will not overwrite existing key value
pair</action>
-<action issue="LOGCXX-272">Apache log4cxx 0.10.1 release</action>
+<action issue="LOGCXX-272">Apache log4cxx 0.11.0 release</action>
<action issue="LOGCXX-275">Headers cannot be included with very strict warning
settings</action>
<action issue="LOGCXX-276">AndFilter and others defined but not
implemented</action>
<action issue="LOGCXX-277">Reconnection not working for sockets</action>
<action issue="LOGCXX-278">Threads for reconnecting sockets do not end cleanly
when program exits</action>
<action issue="LOGCXX-280">tests and sample code unnecessarily compiled during
default make target</action>
<action issue="LOGCXX-281">Sun Studio 11 reports function hides base virtual
function warning</action>
+<action issue="LOGCXX-282">Thread::sleep not affected by
Thread::interrupt.</action>
<action issue="LOGCXX-283">Suspicious, but harmless, reuse of LOCAL1 in
SyslogAppender</action>
<action issue="LOGCXX-284">Unit tests fail to compile with xlc_r on
AIX</action>
<action issue="LOGCXX-285">LevelRangeFilter has default value for
acceptOnMatch that is different from log4j</action>
Modified: logging/log4cxx/trunk/src/main/cpp/socketappenderskeleton.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/socketappenderskeleton.cpp?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/socketappenderskeleton.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/socketappenderskeleton.cpp Tue Jul 1
08:13:58 2008
@@ -159,6 +159,10 @@
}
return NULL;
}
+ catch(InterruptedException&) {
+ LogLog::debug(LOG4CXX_STR("Connector interrupted. Leaving
loop."));
+ return NULL;
+ }
catch(ConnectException&)
{
LogLog::debug(LOG4CXX_STR("Remote host ")
Modified: logging/log4cxx/trunk/src/main/cpp/synchronized.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/synchronized.cpp?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/synchronized.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/synchronized.cpp Tue Jul 1 08:13:58 2008
@@ -37,6 +37,18 @@
#endif
}
+synchronized::synchronized(apr_thread_mutex_t* mutex1)
+: mutex(mutex1)
+{
+#if APR_HAS_THREADS
+ apr_status_t stat = apr_thread_mutex_lock(
+ (apr_thread_mutex_t*) this->mutex);
+ if (stat != APR_SUCCESS) {
+ throw MutexException(stat);
+ }
+#endif
+}
+
synchronized::~synchronized()
{
#if APR_HAS_THREADS
Modified: logging/log4cxx/trunk/src/main/cpp/threadcxx.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/threadcxx.cpp?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/threadcxx.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/threadcxx.cpp Tue Jul 1 08:13:58 2008
@@ -22,6 +22,8 @@
#include <apr_atomic.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/threadlocal.h>
+#include <log4cxx/helpers/synchronized.h>
+#include <apr_thread_cond.h>
using namespace log4cxx::helpers;
using namespace log4cxx;
@@ -135,7 +137,8 @@
-Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0) {
+Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0),
+ interruptedMutex(NULL), interruptedCondition(NULL) {
}
Thread::~Thread() {
@@ -159,6 +162,16 @@
throw ThreadException(stat);
}
+ stat = apr_thread_cond_create(&interruptedCondition, p.getAPRPool());
+ if (stat != APR_SUCCESS) {
+ throw ThreadException(stat);
+ }
+ stat = apr_thread_mutex_create(&interruptedMutex,
APR_THREAD_MUTEX_NESTED,
+ p.getAPRPool());
+ if (stat != APR_SUCCESS) {
+ throw ThreadException(stat);
+ }
+
// create LaunchPackage on the thread's memory pool
LaunchPackage* package = new(p) LaunchPackage(this, start, data);
stat = apr_thread_create(&thread, attrs,
@@ -199,6 +212,13 @@
void Thread::interrupt() {
apr_atomic_set32(&interruptedStatus, 0xFFFFFFFF);
+#if APR_HAS_THREADS
+ if (interruptedMutex != NULL) {
+ synchronized sync(interruptedMutex);
+ apr_status_t stat = apr_thread_cond_signal(interruptedCondition);
+ if (stat != APR_SUCCESS) throw ThreadException(stat);
+ }
+#endif
}
bool Thread::interrupted() {
@@ -234,8 +254,25 @@
if(interrupted()) {
throw InterruptedException();
}
-#endif
+ if (duration > 0) {
+ Thread* pThis = (Thread*) getThreadLocal().get();
+ if (pThis == NULL) {
+ apr_sleep(duration*1000);
+ } else {
+ synchronized sync(pThis->interruptedMutex);
+ apr_status_t stat =
apr_thread_cond_timedwait(pThis->interruptedCondition,
+ pThis->interruptedMutex, duration*1000);
+ if (stat != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(stat)) {
+ throw ThreadException(stat);
+ }
+ if (interrupted()) {
+ throw InterruptedException();
+ }
+ }
+ }
+#else
if (duration > 0) {
apr_sleep(duration*1000);
}
+#endif
}
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/helpers/synchronized.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/helpers/synchronized.h?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/helpers/synchronized.h
(original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/helpers/synchronized.h Tue
Jul 1 08:13:58 2008
@@ -19,6 +19,10 @@
#define _LOG4CXX_HELPERS_SYNCHRONIZED_H
#include <log4cxx/log4cxx.h>
+extern "C" {
+ typedef struct apr_thread_mutex_t apr_thread_mutex_t;
+}
+
namespace log4cxx
{
namespace helpers {
@@ -29,6 +33,7 @@
{
public:
synchronized(const Mutex& mutex);
+ synchronized(apr_thread_mutex_t* mutex);
~synchronized();
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/helpers/thread.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/helpers/thread.h?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/helpers/thread.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/helpers/thread.h Tue Jul 1
08:13:58 2008
@@ -31,6 +31,8 @@
extern "C" {
typedef struct apr_thread_t apr_thread_t;
+ typedef struct apr_thread_cond_t apr_thread_cond_t;
+ typedef struct apr_thread_mutex_t apr_thread_mutex_t;
}
@@ -100,6 +102,8 @@
apr_thread_t* thread;
volatile unsigned int alive;
volatile unsigned int interruptedStatus;
+ apr_thread_mutex_t* interruptedMutex;
+ apr_thread_cond_t* interruptedCondition;
Thread(const Thread&);
Thread& operator=(const Thread&);
friend void* LOG4CXX_THREAD_FUNC
ThreadLaunch::launcher(apr_thread_t* thread, void* data);
Modified:
logging/log4cxx/trunk/src/main/include/log4cxx/net/socketappenderskeleton.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/net/socketappenderskeleton.h?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/net/socketappenderskeleton.h
(original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/net/socketappenderskeleton.h
Tue Jul 1 08:13:58 2008
@@ -162,7 +162,7 @@
<code>reconnectionDelay</code> milliseconds.
<p>It stops trying whenever a connection is
established. It will
- restart to try reconnect to the server when
previpously open
+ restart to try reconnect to the server when previously
open
connection is droppped.
*/
Modified: logging/log4cxx/trunk/src/test/cpp/Makefile.am
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/Makefile.am?rev=673097&r1=673096&r2=673097&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/Makefile.am (original)
+++ logging/log4cxx/trunk/src/test/cpp/Makefile.am Tue Jul 1 08:13:58 2008
@@ -51,6 +51,7 @@
helpers/charsetencodertestcase.cpp \
helpers/cyclicbuffertestcase.cpp\
helpers/datetimedateformattestcase.cpp \
+ helpers/filewatchdogtest.cpp \
helpers/inetaddresstestcase.cpp \
helpers/iso8601dateformattestcase.cpp \
helpers/localechanger.cpp\
@@ -61,6 +62,7 @@
helpers/stringtokenizertestcase.cpp \
helpers/stringhelpertestcase.cpp \
helpers/syslogwritertest.cpp \
+ helpers/threadtestcase.cpp \
helpers/timezonetestcase.cpp \
helpers/transcodertestcase.cpp