mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +02:00
- bugfixes, some related to things pointed out by valgrind, some from opengl research and some for more stable operation
This commit is contained in:
@@ -120,6 +120,7 @@ public:
|
||||
static int DEFAULT_HTTP_TIMEOUT;
|
||||
static bool VERBOSE_MODE_ENABLED;
|
||||
static bool ENABLE_THREADED_LOGGING;
|
||||
static bool SHUTDOWN_PROGRAM_MODE;
|
||||
|
||||
SystemFlags();
|
||||
~SystemFlags();
|
||||
|
@@ -790,17 +790,27 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
|
||||
//gen texture
|
||||
glGenTextures(1, &handle);
|
||||
glBindTexture(GL_TEXTURE_2D, handle);
|
||||
|
||||
//wrap params
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap);
|
||||
|
||||
//maxAnisotropy
|
||||
if(isGlExtensionSupported("GL_EXT_texture_filter_anisotropic")) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);
|
||||
}
|
||||
|
||||
if(mipmap) {
|
||||
GLuint glFilter= filter==fTrilinear? GL_LINEAR_MIPMAP_LINEAR: GL_LINEAR_MIPMAP_NEAREST;
|
||||
|
||||
//build mipmaps
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glFilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
/*
|
||||
* Replaced this call due to: http://www.opengl.org/wiki/Common_Mistakes#gluBuild2DMipmaps
|
||||
*
|
||||
int error= gluBuild2DMipmaps(
|
||||
GL_TEXTURE_2D, glCompressionFormat,
|
||||
pixmap.getW(), pixmap.getH(),
|
||||
glFormat, GL_UNSIGNED_BYTE, pixels);
|
||||
@@ -965,17 +975,30 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
//params
|
||||
const Pixmap2D *currentPixmap= pixmap.getFace(i);
|
||||
|
||||
GLint glFormat= toFormatGl(format, currentPixmap->getComponents());
|
||||
GLint glInternalFormat= toInternalFormatGl(format, currentPixmap->getComponents());
|
||||
GLint glCompressionFormat = toCompressionFormatGl(glInternalFormat);
|
||||
if(forceCompressionDisabled == true || (currentPixmap->getPixelByteCount() > 0 && currentPixmap->getPixelByteCount() <= MIN_BYTES_TO_COMPRESS)) {
|
||||
glCompressionFormat = glInternalFormat;
|
||||
}
|
||||
|
||||
//pixel init var
|
||||
const uint8* pixels= pixmapInit? currentPixmap->getPixels(): NULL;
|
||||
GLenum target= GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
|
||||
|
||||
if(mipmap) {
|
||||
|
||||
/*
|
||||
* Replaced this call due to: http://www.opengl.org/wiki/Common_Mistakes#gluBuild2DMipmaps
|
||||
*
|
||||
int error= gluBuild2DMipmaps(
|
||||
target, glCompressionFormat,
|
||||
currentPixmap->getW(), currentPixmap->getH(),
|
||||
glFormat, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
*/
|
||||
|
@@ -691,10 +691,20 @@ Pixmap2D::Pixmap2D() {
|
||||
}
|
||||
|
||||
Pixmap2D::Pixmap2D(int components) {
|
||||
h= -1;
|
||||
w= -1;
|
||||
this->components= -1;
|
||||
pixels= NULL;
|
||||
|
||||
init(components);
|
||||
}
|
||||
|
||||
Pixmap2D::Pixmap2D(int w, int h, int components) {
|
||||
this->h= 0;
|
||||
this->w= -1;
|
||||
this->components= -1;
|
||||
pixels= NULL;
|
||||
|
||||
init(w, h, components);
|
||||
}
|
||||
|
||||
@@ -702,6 +712,7 @@ void Pixmap2D::init(int components) {
|
||||
this->w= -1;
|
||||
this->h= -1;
|
||||
this->components= components;
|
||||
deletePixels();
|
||||
pixels= NULL;
|
||||
}
|
||||
|
||||
@@ -709,7 +720,16 @@ void Pixmap2D::init(int w, int h, int components) {
|
||||
this->w= w;
|
||||
this->h= h;
|
||||
this->components= components;
|
||||
deletePixels();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] w = %d, h = %d, components = %d, getPixelByteCount() = %llu\n",__FILE__,__FUNCTION__,__LINE__,w,h,components,(long long unsigned)getPixelByteCount());
|
||||
|
||||
if(getPixelByteCount() <= 0 || (h <= 0 || w <= 0 || components <= 0)) {
|
||||
char szBuf[1024];
|
||||
sprintf(szBuf,"Invalid pixmap dimensions for [%s], h = %d, w = %d, components = %d\n",path.c_str(),h,w,components);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
uint64 Pixmap2D::getPixelByteCount() const {
|
||||
@@ -717,8 +737,12 @@ uint64 Pixmap2D::getPixelByteCount() const {
|
||||
}
|
||||
|
||||
void Pixmap2D::deletePixels() {
|
||||
delete [] pixels;
|
||||
pixels = NULL;
|
||||
if(pixels) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
delete [] pixels;
|
||||
pixels = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
Pixmap2D::~Pixmap2D() {
|
||||
@@ -726,7 +750,7 @@ Pixmap2D::~Pixmap2D() {
|
||||
}
|
||||
|
||||
Pixmap2D* Pixmap2D::loadPath(const string& path) {
|
||||
printf("Loading Pixmap2D [%s]\n",path.c_str());
|
||||
//printf("Loading Pixmap2D [%s]\n",path.c_str());
|
||||
|
||||
Pixmap2D *pixmap = FileReader<Pixmap2D>::readPath(path);
|
||||
if(pixmap != NULL) {
|
||||
|
@@ -49,14 +49,16 @@ Mutex * BaseThread::getMutexThreadOwnerValid() {
|
||||
}
|
||||
|
||||
void BaseThread::setThreadOwnerValid(bool value) {
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
|
||||
threadOwnerValid = value;
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
bool BaseThread::getThreadOwnerValid() {
|
||||
bool ret = false;
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
|
||||
ret = threadOwnerValid;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -64,17 +66,18 @@ bool BaseThread::getThreadOwnerValid() {
|
||||
}
|
||||
|
||||
void BaseThread::signalQuit() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
setQuitStatus(true);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
}
|
||||
|
||||
void BaseThread::setQuitStatus(bool value) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
|
||||
quit = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -85,7 +88,8 @@ bool BaseThread::getQuitStatus() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
|
||||
retval = quit;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -96,7 +100,8 @@ bool BaseThread::getQuitStatus() {
|
||||
|
||||
bool BaseThread::getHasBeginExecution() {
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
|
||||
retval = hasBeginExecution;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -108,7 +113,8 @@ bool BaseThread::getHasBeginExecution() {
|
||||
void BaseThread::setHasBeginExecution(bool value) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
|
||||
hasBeginExecution = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -119,7 +125,9 @@ bool BaseThread::getRunningStatus() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
|
||||
retval = running;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -133,25 +141,30 @@ bool BaseThread::getRunningStatus() {
|
||||
}
|
||||
|
||||
void BaseThread::setRunningStatus(bool value) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] value = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),value);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] value = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),value);
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
|
||||
running = value;
|
||||
setHasBeginExecution(true);
|
||||
if(value == true) {
|
||||
setHasBeginExecution(true);
|
||||
}
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
}
|
||||
|
||||
void BaseThread::setExecutingTask(bool value) {
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
|
||||
executingTask = value;
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
bool BaseThread::getExecutingTask() {
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
|
||||
retval = executingTask;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -160,7 +173,8 @@ bool BaseThread::getExecutingTask() {
|
||||
|
||||
bool BaseThread::getDeleteSelfOnExecutionDone() {
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
retval = deleteSelfOnExecutionDone;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -168,7 +182,8 @@ bool BaseThread::getDeleteSelfOnExecutionDone() {
|
||||
}
|
||||
|
||||
void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
|
||||
deleteSelfOnExecutionDone = value;
|
||||
}
|
||||
|
||||
@@ -218,14 +233,11 @@ bool BaseThread::shutdownAndWait() {
|
||||
}
|
||||
|
||||
sleep(0);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
//sleep(0);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||
sleep(0);
|
||||
}
|
||||
}
|
||||
//sleep(0);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -87,13 +87,15 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
||||
this->needTaskSignal = needTaskSignal;
|
||||
setTaskSignalled(false);
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
lastExecuteTimestamp = time(NULL);
|
||||
}
|
||||
|
||||
bool SimpleTaskThread::isThreadExecutionLagging() {
|
||||
bool result = false;
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -111,6 +113,7 @@ bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
||||
}
|
||||
|
||||
void SimpleTaskThread::execute() {
|
||||
bool mustDeleteSelf = false;
|
||||
{
|
||||
{
|
||||
RunningStatusSafeWrapper runningStatus(this);
|
||||
@@ -141,7 +144,8 @@ void SimpleTaskThread::execute() {
|
||||
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
|
||||
this->simpleTaskInterface->simpleTask(this);
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
|
||||
lastExecuteTimestamp = time(NULL);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
@@ -174,14 +178,19 @@ void SimpleTaskThread::execute() {
|
||||
}
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||
mustDeleteSelf = getDeleteSelfOnExecutionDone();
|
||||
}
|
||||
|
||||
if(mustDeleteSelf == true) {
|
||||
delete this;
|
||||
}
|
||||
deleteSelfIfRequired();
|
||||
}
|
||||
|
||||
void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
|
||||
taskSignalled = value;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -192,7 +201,8 @@ bool SimpleTaskThread::getTaskSignalled() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool retval = false;
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
|
||||
retval = taskSignalled;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
@@ -209,7 +219,8 @@ LogFileThread::LogFileThread() : BaseThread() {
|
||||
}
|
||||
|
||||
void LogFileThread::addLogEntry(SystemFlags::DebugType type, string logEntry) {
|
||||
MutexSafeWrapper safeMutex(&mutexLogList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexLogList,mutexOwnerId);
|
||||
LogFileEntry entry;
|
||||
entry.type = type;
|
||||
entry.entry = logEntry;
|
||||
@@ -233,6 +244,7 @@ bool LogFileThread::checkSaveCurrentLogBufferToDisk() {
|
||||
}
|
||||
|
||||
void LogFileThread::execute() {
|
||||
bool mustDeleteSelf = false;
|
||||
{
|
||||
RunningStatusSafeWrapper runningStatus(this);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -270,19 +282,25 @@ void LogFileThread::execute() {
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
mustDeleteSelf = getDeleteSelfOnExecutionDone();
|
||||
}
|
||||
if(mustDeleteSelf == true) {
|
||||
delete this;
|
||||
}
|
||||
deleteSelfIfRequired();
|
||||
}
|
||||
|
||||
std::size_t LogFileThread::getLogEntryBufferCount() {
|
||||
MutexSafeWrapper safeMutex(&mutexLogList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexLogList,mutexOwnerId);
|
||||
std::size_t logCount = logList.size();
|
||||
safeMutex.ReleaseLock();
|
||||
return logCount;
|
||||
}
|
||||
|
||||
void LogFileThread::saveToDisk(bool forceSaveAll,bool logListAlreadyLocked) {
|
||||
MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(NULL,mutexOwnerId);
|
||||
if(logListAlreadyLocked == false) {
|
||||
safeMutex.setMutex(&mutexLogList);
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ int SystemFlags::DEFAULT_HTTP_TIMEOUT = 10;
|
||||
bool SystemFlags::VERBOSE_MODE_ENABLED = false;
|
||||
bool SystemFlags::ENABLE_THREADED_LOGGING = false;
|
||||
static LogFileThread *threadLogger = NULL;
|
||||
bool SystemFlags::SHUTDOWN_PROGRAM_MODE = false;
|
||||
//
|
||||
|
||||
static void *myrealloc(void *ptr, size_t size)
|
||||
@@ -197,10 +198,10 @@ void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
|
||||
(*SystemFlags::debugLogFileList)[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
||||
}
|
||||
|
||||
if(threadLogger == NULL) {
|
||||
if(threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == false) {
|
||||
threadLogger = new LogFileThread();
|
||||
threadLogger->start();
|
||||
sleep(5);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -261,6 +262,7 @@ SystemFlags::~SystemFlags() {
|
||||
void SystemFlags::Close() {
|
||||
if(threadLogger != NULL) {
|
||||
SystemFlags::ENABLE_THREADED_LOGGING = false;
|
||||
//SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||
threadLogger->signalQuit();
|
||||
threadLogger->shutdownAndWait();
|
||||
delete threadLogger;
|
||||
|
Reference in New Issue
Block a user