From feed7d5b3c5a737fa8bde3f90cc8a8be7bab40e1 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 10 Dec 2014 13:15:26 -0800 Subject: [PATCH] pthread_t pid_t compatibility fixes --- HttpRequest.cpp | 3 ++- Images.cpp | 11 +++++++---- Log.cpp | 8 ++++---- Profiler.cpp | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/HttpRequest.cpp b/HttpRequest.cpp index 8749b514..9674525d 100644 --- a/HttpRequest.cpp +++ b/HttpRequest.cpp @@ -607,7 +607,8 @@ bool HttpRequest::set ( char *origReq , int32_t origReqLen , TcpSocket *sock ) { bool multipart = false; if ( m_requestType == 2 ) { // is POST? - char *cd =strcasestr(req,"Content-Type: multipart/form-data"); + char *cd ; + cd = gb_strcasestr(req,"Content-Type: multipart/form-data"); if ( cd ) multipart = true; } diff --git a/Images.cpp b/Images.cpp index 0c6f7c78..fce3ab5e 100644 --- a/Images.cpp +++ b/Images.cpp @@ -979,14 +979,16 @@ void Images::thumbStart_r ( bool amThread ) { makeTrashDir(); - // get thread id - int32_t id = getpidtid(); + // get thread id. pthread_t is 64 bit and pid_t is 32 bit on + // 64 bit oses + pthread_t id = getpidtid(); // pass the input to the program through this file // rather than a pipe, since popen() seems broken. // m_dir ends in / so this should work. char in[364]; - snprintf ( in , 363,"%strash/in.%"INT32"", g_hostdb.m_dir, id ); + snprintf ( in , 363,"%strash/in.%"INT64"" + , g_hostdb.m_dir, (int64_t)id ); unlink ( in ); log( LOG_DEBUG, "image: thumbStart_r create in file." ); @@ -994,7 +996,8 @@ void Images::thumbStart_r ( bool amThread ) { // collect the output from the filter from this file // m_dir ends in / so this should work. char out[364]; - snprintf ( out , 363,"%strash/out.%"INT32"", g_hostdb.m_dir, id ); + snprintf ( out , 363,"%strash/out.%"INT64"" + , g_hostdb.m_dir, (int64_t)id ); unlink ( out ); log( LOG_DEBUG, "image: thumbStart_r create out file." ); diff --git a/Log.cpp b/Log.cpp index ac18b693..c3cb127d 100644 --- a/Log.cpp +++ b/Log.cpp @@ -28,8 +28,8 @@ static pthread_mutex_t s_lock = PTHREAD_MUTEX_INITIALIZER; char *g_dbuf = NULL; int32_t g_dbufSize = 0; -// main process id -static pid_t s_pid = -1; +// main process id. pthread_t is 64 bit and pid_t is 32 bit on 64 bit oses +static pthread_t s_pid = (pthread_t)-1; void Log::setPid ( ) { s_pid = getpidtid(); @@ -246,7 +246,7 @@ bool Log::logR ( int64_t now , int32_t type , char *msg , bool asterisk , // chop off any spaces at the end of the msg. while ( is_wspace_a ( msg [ msgLen - 1 ] ) && msgLen > 0 ) msgLen--; // get this pid - pid_t pid = getpidtid(); + pthread_t pid = getpidtid(); // a tmp buffer char tt [ MAX_LINE_LEN ]; char *p = tt; @@ -291,7 +291,7 @@ bool Log::logR ( int64_t now , int32_t type , char *msg , bool asterisk , // MDW... no i like it //while ( p < pend && *x && is_alnum_a(*x) ) { x++; cc--; } // thread id if in "thread" - if ( pid != s_pid && s_pid != -1 ) { + if ( pid != s_pid && s_pid != (pthread_t)-1 ) { //sprintf ( p , "[%"INT32"] " , (int32_t)getpid() ); sprintf ( p , "[%"UINT32"] " , (uint32_t)pid ); p += gbstrlen ( p ); diff --git a/Profiler.cpp b/Profiler.cpp index f3bfff0a..14147097 100644 --- a/Profiler.cpp +++ b/Profiler.cpp @@ -5,7 +5,7 @@ Profiler::Profiler(){return;} Profiler::~Profiler(){return;} bool Profiler::reset(){return true;} bool Profiler::init(){return true;} -char *Profiler::getFnName(uint32_t address,int32_t *nameLen){return NULL;} +char *Profiler::getFnName(PTRTYPE address,int32_t *nameLen){return NULL;} void Profiler::stopRealTimeProfiler(const bool keepData){return;} void Profiler::cleanup(){return;} bool Profiler:: readSymbolTable(){return true;}