libsynthesis server engine uses open/close flush method unconditionally for
global logs which causes race condition when incomming SyncML requests
are processed from different threads with resulting SIGSEGV
Included patch seems to workaround the problem. Mutex is ignored unless
flush method is open/close.
Andris
PS. I know that global logs are disabled by default and are not recommended
in multi-user environment. Anyway SIGSEGV is not a good behavior.
--- libsynthesis_3.4.0.24/src/sysync/debuglogger.cpp.dbglog 2011-01-27 10:13:10.000000000 +0200
+++ libsynthesis_3.4.0.24/src/sysync/debuglogger.cpp 2011-08-25 13:05:37.000000000 +0300
@@ -287,12 +287,14 @@ TStdFileDbgOut::TStdFileDbgOut()
// init
fFileName.erase();
fFile=NULL;
+ mutex=newMutex();
} // TStdFileDbgOut::TStdFileDbgOut
TStdFileDbgOut::~TStdFileDbgOut()
{
destruct();
+ freeMutex(mutex);
} // TStdFileDbgOut::~TStdFileDbgOut
@@ -364,6 +366,7 @@ void TStdFileDbgOut::putLine(cAppCharP a
if (fIsOpen) {
if (fFlushMode==dbgflush_openclose) {
// we need to open the file for append first
+ lockMutex(mutex);
fFile=fopen(fFileName.c_str(),"a");
}
if (fFile) {
@@ -376,6 +379,7 @@ void TStdFileDbgOut::putLine(cAppCharP a
// we need to close the file after every line of output
fclose(fFile);
fFile=NULL;
+ unlockMutex(mutex);
}
else if (aForceFlush || fFlushMode==dbgflush_flush) {
// simply flush
@@ -392,6 +396,7 @@ void TStdFileDbgOut::putRawData(cAppPoin
if (fIsOpen) {
if (fFlushMode==dbgflush_openclose) {
// we need to open the file for append first
+ lockMutex(mutex);
fFile=fopen(fFileName.c_str(),"a");
}
if (fFile) {
@@ -404,6 +409,7 @@ void TStdFileDbgOut::putRawData(cAppPoin
// we need to close the file after every line of output
fclose(fFile);
fFile=NULL;
+ unlockMutex(mutex);
}
else if (fFlushMode==dbgflush_flush) {
// simply flush
--- libsynthesis_3.4.0.24/src/sysync/debuglogger.h.dbglog 2011-01-27 10:13:10.000000000 +0200
+++ libsynthesis_3.4.0.24/src/sysync/debuglogger.h 2011-08-25 13:10:44.000000000 +0300
@@ -17,6 +17,7 @@
#ifdef SYDEBUG
#include "generic_types.h"
+#include "platform_mutex.h"
#include "sysync.h"
namespace sysync {
@@ -169,6 +170,7 @@ private:
TDbgFlushModes fFlushMode;
string fFileName;
FILE * fFile;
+ MutexPtr_t mutex;
}; // TStdFileDbgOut
#endif
_______________________________________________
os-libsynthesis mailing list
[email protected]
http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis