better fixes for core from sig alarms
This commit is contained in:
14
Loop.cpp
14
Loop.cpp
@ -1193,6 +1193,8 @@ void sigvtalrmHandler ( int x , siginfo_t *info , void *y ) {
|
||||
|
||||
}
|
||||
|
||||
float g_cpuUsage = 0.0;
|
||||
|
||||
void sigalrmHandler ( int x , siginfo_t *info , void *y ) {
|
||||
|
||||
#ifdef PTHREADS
|
||||
@ -1206,6 +1208,17 @@ void sigalrmHandler ( int x , siginfo_t *info , void *y ) {
|
||||
|
||||
// stats
|
||||
g_numAlarms++;
|
||||
|
||||
if ( ! g_inWaitState )
|
||||
g_cpuUsage = .99 * g_cpuUsage + .01 * 100;
|
||||
else
|
||||
g_cpuUsage = .99 * g_cpuUsage + .01 * 000;
|
||||
|
||||
if ( g_profiler.m_realTimeProfilerRunning )
|
||||
g_profiler.getStackFrame(0);
|
||||
|
||||
return;
|
||||
/*
|
||||
// . see where we are in the code
|
||||
// . for computing cpu usage
|
||||
// . if idling we will be in sigtimedwait() at the lowest level
|
||||
@ -1224,6 +1237,7 @@ void sigalrmHandler ( int x , siginfo_t *info , void *y ) {
|
||||
|
||||
if ( g_profiler.m_realTimeProfilerRunning )
|
||||
g_profiler.getStackFrame(0);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -282,6 +282,9 @@ void PingServer::sendPingsToAll ( ) {
|
||||
|
||||
// };
|
||||
|
||||
// from Loop.cpp
|
||||
extern float g_cpuUsage;
|
||||
|
||||
// ping host #i
|
||||
void PingServer::pingHost ( Host *h , uint32_t ip , uint16_t port ) {
|
||||
// don't ping on interface machines
|
||||
@ -513,6 +516,9 @@ void PingServer::pingHost ( Host *h , uint32_t ip , uint16_t port ) {
|
||||
|
||||
pi->m_tcpSocketsInUse = g_httpServer.m_tcp.m_numUsed;
|
||||
|
||||
// from Loop.cpp
|
||||
pi->m_cpuUsage = g_cpuUsage;
|
||||
|
||||
// store hd temps
|
||||
// gbmemcpy ( p , me->m_hdtemps , 4 * 2 );
|
||||
// p += 4 * 2;
|
||||
|
4
main.cpp
4
main.cpp
@ -3103,7 +3103,7 @@ int main2 ( int argc , char *argv[] ) {
|
||||
if ( pid < 0 ) exit(EXIT_FAILURE);
|
||||
// seems like we core unless parent sets this to NULL.
|
||||
// it does not affect the child.
|
||||
if ( pid > 0 ) g_hostdb.m_myHost = NULL;
|
||||
//if ( pid > 0 ) g_hostdb.m_myHost = NULL;
|
||||
// child gets a 0, parent gets the child's pid, so exit
|
||||
if ( pid > 0 ) exit(EXIT_SUCCESS);
|
||||
// change file mode mask
|
||||
@ -4118,7 +4118,7 @@ bool doCmd ( const char *cmd , int32_t hostId , char *filename ,
|
||||
s_r.set ( s_buffer , gbstrlen ( s_buffer ) , &sock );
|
||||
// do not do sig alarms! for now just set this to null so
|
||||
// the sigalarmhandler doesn't core
|
||||
g_hostdb.m_myHost = NULL;
|
||||
//g_hostdb.m_myHost = NULL;
|
||||
// run the loop
|
||||
if ( ! g_loop.runLoop() )
|
||||
return log("INJECT: loop run failed.");
|
||||
|
Reference in New Issue
Block a user