logging fixes

This commit is contained in:
Matt Wells 2014-04-10 23:04:00 -07:00
parent f293045ace
commit 36e26436b5
6 changed files with 27 additions and 14 deletions

View File

@ -31,6 +31,10 @@ long g_dbufSize = 0;
// main process id
static pid_t s_pid = -1;
void Log::setPid ( ) {
s_pid = getpidtid();
}
Log::Log () {
m_fd = -1;
m_filename = NULL;
@ -55,7 +59,8 @@ void Log::reset ( ) {
bool Log::init ( char *filename ) {
// set the main process id
s_pid = getpidtid();
//s_pid = getpidtid();
setPid();
// init these
m_numErrors = 0;
m_bufPtr = 0;

2
Log.h
View File

@ -124,6 +124,8 @@ class Log {
void reset ( );
void setPid();
// save before exiting
void close () { dumpLog(); };

View File

@ -178,17 +178,7 @@ Threads::Threads ( ) {
m_initialized = false;
}
bool Threads::init ( ) {
if ( m_initialized ) return true;
m_initialized = true;
m_needsCleanup = false;
//m_needBottom = false;
// sanity check
if ( sizeof(pthread_t) > sizeof(pid_t) ) { char *xx=NULL;*xx=0; }
void Threads::setPid ( ) {
// set s_pid to the main process id
#ifdef PTHREADS
s_pid = pthread_self();
@ -207,7 +197,20 @@ bool Threads::init ( ) {
#else
s_pid = getpid();
#endif
}
bool Threads::init ( ) {
if ( m_initialized ) return true;
m_initialized = true;
m_needsCleanup = false;
//m_needBottom = false;
// sanity check
if ( sizeof(pthread_t) > sizeof(pid_t) ) { char *xx=NULL;*xx=0; }
setPid();
#ifdef _STACK_GROWS_UP
return log("thread: Stack growing up not supported.");

View File

@ -172,6 +172,7 @@ class Threads {
long getStack ( ) ;
void returnStack ( long si );
void setPid();
void reset ( ) ;
// . we restrict the # of threads based on their type

View File

@ -63,7 +63,7 @@ A work-in-progress <a href=/compare.html>comparison to SOLR</a>.
<br><br><a name=quickstart></a>
<h1>Quick Start</h1>
Until I get the binary packages ready, <a href=#src>build from the source code</a>, it's easy.
Until I get the binary packages ready, <a href=#src>build from the source code</a>, it should only take about 30 seconds to type the three commands.
<!--
Requirements: You will need an Intel or AMD system running Linux and at least 4GB of RAM.<br><br>
@ -100,7 +100,7 @@ You will need the following packages installed<br>
<b>1.</b> Do <b>apt-get install make g++ gcc-multilib lib32stdc++6</b>
<br>
<b>2.</b> Download the <a href=https://github.com/gigablast/open-source-search-engine/archive/master.zip>Gigablast source code</a>, unzip it and cd into it. Alternatively, clone it from <a href=https://github.com/gigablast/open-source-search-engine>Gigablast on Github</a>.
<b>2.</b> Download the <a href=https://github.com/gigablast/open-source-search-engine>Gigablast source code</a> using <b>wget --no-check-certificate "https://github.com/gigablast/open-source-search-engine/archive/master.zip"</b>, unzip it and cd into it.
<br>
<b>3.</b> Run <b>make</b> to compile. (e.g. use 'make -j 4' to compile on four cores)
<br>

View File

@ -2766,6 +2766,8 @@ int main2 ( int argc , char *argv[] ) {
//fprintf(stderr,"done\n");
// set our new pid
g_mem.setPid();
g_threads.setPid();
g_log.setPid();
}
// initialize threads down here now so it logs to the logfile and