Major update:
- Logging
- Created LogCore Class
- Updated LogCore to use file descriptors instead of stdout
- Add Log object reference to constructors for:
FunctionCore, SelectCore
- Use extern Log() object in SignalCore
- SelectableCore
- Added new connection type: ForkedPipe
Create pipe, fork process, connect pipe out to child stdin, exec
This commit is contained in:
@@ -23,7 +23,7 @@ extern char ProcessName[];
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Create Select
|
||||
CSelect::CSelect( long SelectTimeout, EDebugLevel pDebugLevel )
|
||||
CSelect::CSelect( long SelectTimeout, CLogCore * pLog, EDebugLevel pDebugLevel )
|
||||
{
|
||||
// Clear List
|
||||
FirstHandle = NULL;
|
||||
@@ -39,10 +39,11 @@ CSelect::CSelect( long SelectTimeout, EDebugLevel pDebugLevel )
|
||||
SetInterval( &Timeout, SelectTimeout );
|
||||
|
||||
// Output
|
||||
Log = pLog;
|
||||
DebugLevel = pDebugLevel;
|
||||
|
||||
// Show status
|
||||
LogMessage( DebugLevel, dlLow, "%s: Select - Created", ProcessName );
|
||||
if (Log) Log->Message( DebugLevel, dlLow, "%s: Select - Created", ProcessName );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -60,7 +61,7 @@ CSelect::~CSelect()
|
||||
}
|
||||
|
||||
// Show status
|
||||
LogMessage( DebugLevel, dlLow, "%s: Select - Destroyed", ProcessName );
|
||||
if (Log) Log->Message( DebugLevel, dlLow, "%s: Select - Destroyed", ProcessName );
|
||||
return;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -105,7 +106,7 @@ void CSelect::Add( int FD, bool Read, bool Write, CSelectableCore * Function )
|
||||
FD_SET( FD, &ReadTestFDS );
|
||||
|
||||
// Log event
|
||||
LogMessage( DebugLevel, dlHigh, "Select: FD [%d] - Add Read", FD );
|
||||
if (Log) Log->Message( DebugLevel, dlHigh, "Select: FD [%d] - Add Read", FD );
|
||||
}
|
||||
|
||||
// Add Write Select
|
||||
@@ -114,7 +115,7 @@ void CSelect::Add( int FD, bool Read, bool Write, CSelectableCore * Function )
|
||||
FD_SET( FD, &WriteTestFDS );
|
||||
|
||||
// Log event
|
||||
LogMessage( DebugLevel, dlHigh, "Select: FD [%d] - Add Write", FD );
|
||||
if (Log) Log->Message( DebugLevel, dlHigh, "Select: FD [%d] - Add Write", FD );
|
||||
}
|
||||
|
||||
// Check Maximum File Handle
|
||||
@@ -142,7 +143,7 @@ void CSelect::Remove( int FD, bool Read, bool Write )
|
||||
FD_CLR( FD, &ReadTestFDS);
|
||||
|
||||
// Log event
|
||||
LogMessage( DebugLevel, dlHigh, "Select: FD [%d] - Remove Read", FD );
|
||||
if (Log) Log->Message( DebugLevel, dlHigh, "Select: FD [%d] - Remove Read", FD );
|
||||
}
|
||||
|
||||
// Remove from set for select write check
|
||||
@@ -151,7 +152,7 @@ void CSelect::Remove( int FD, bool Read, bool Write )
|
||||
FD_CLR( FD, &WriteTestFDS);
|
||||
|
||||
// Log event
|
||||
LogMessage( DebugLevel, dlHigh, "Select: FD [%d] - Remove Write", FD );
|
||||
if (Log) Log->Message( DebugLevel, dlHigh, "Select: FD [%d] - Remove Write", FD );
|
||||
}
|
||||
// Handle will be removed in Test() if both Read & Write flags are false
|
||||
}
|
||||
@@ -173,7 +174,7 @@ bool CSelect::Test()
|
||||
Events = select( MaxFD, &ReadFDS, &WriteFDS, (fd_set*)NULL, &STimeout );
|
||||
if (Events < 0)
|
||||
{
|
||||
LogMessage( DebugLevel, dlHigh, "Select: Select operation failed" );
|
||||
if (Log) Log->Message( DebugLevel, dlHigh, "Select: Select operation failed" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user