Major Update:

- FunctionCore
  - Replace Channel->Ready with Channel->State (off/waiting/ready)
  - Add Function reference to Handle
- SelectableBare/Core:
  - Implement async address resolve with event handling
    - Create ResolveHandler() signal handler (friend) function
  - Change Create/Remove/DestroyHandle() methods to virtual methods
    - Move socket specific code to SelectableCore
  - Rename ChangeState() to virtual HandleState()
  - Move ClearHandle() from SelectableBare -> SelectableCore
  - Implement new/delete from THandle
  - Set max TCP SYN count on connect
This commit is contained in:
Charl Wentzel
2019-06-09 22:05:27 +02:00
parent 08fce64629
commit bde14a13da
8 changed files with 360 additions and 166 deletions

View File

@@ -100,7 +100,7 @@ bool CFunctionCore::Init( CDataMember * FunctionConfig )
// Load Channels
ChannelConfig = FunctionConfig->GetChFirstChild( "Channels", true );
while (ChannelConfig) {
AddChannel( ChannelConfig->GetName(), false );
AddChannel( ChannelConfig->GetName(), CH_off );
ChannelConfig = ChannelConfig->GetNextPeer();
}
@@ -166,7 +166,7 @@ bool CFunctionCore::SetLogLevel( EDebugLevel pDebugLevel )
}
//---------------------------------------------------------------------------
TChannel * CFunctionCore::AddChannel( const char * ChannelName, bool Ready )
TChannel * CFunctionCore::AddChannel( const char * ChannelName, const EChannelState State )
{
TChannel ** Channel = NULL;
@@ -190,17 +190,17 @@ TChannel * CFunctionCore::AddChannel( const char * ChannelName, bool Ready )
(*Channel)->Name = strdup( ChannelName );
(*Channel)->Ref = (char*)malloc( strlen(Name)+strlen(ChannelName)+2 );
sprintf( (*Channel)->Ref, "%s/%s", Name, ChannelName );
(*Channel)->Ready = Ready;
(*Channel)->State = State;
// Log Event
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Channel '%s' - Created, Ref:'%s', Ready:%s",
ProcessName, Name, ChannelName, (*Channel)->Ref, (((*Channel)->Ready)? "Yes" : "No") );
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Channel '%s' - Created, Ref:'%s', State:%s",
ProcessName, Name, ChannelName, (*Channel)->Ref, ChannelStateName[(*Channel)->State] );
}
return *Channel;
}
//---------------------------------------------------------------------------
bool CFunctionCore::SetChannelState( TChannel * Channel, const bool Ready )
bool CFunctionCore::SetChannelState( TChannel * Channel, const EChannelState State )
{
TChannelLink * LinkChannel;
@@ -209,14 +209,14 @@ bool CFunctionCore::SetChannelState( TChannel * Channel, const bool Ready )
return false;
// Update state
Channel->Ready = Ready;
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Channel '%s' - Ready:%s",
ProcessName, Name, Channel->Name, ((Ready)? "Yes" : "No") );
Channel->State = State;
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Channel '%s' - State:%s",
ProcessName, Name, Channel->Name, ChannelStateName[State] );
// Update linked channels
LinkChannel = Channel->FirstLink;
while (LinkChannel) {
LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, Ready );
LinkChannel->Function->ChannelStateEvent( LinkChannel->Channel, Channel->Ref, State );
LinkChannel = LinkChannel->Next;
}
@@ -224,7 +224,7 @@ bool CFunctionCore::SetChannelState( TChannel * Channel, const bool Ready )
}
//---------------------------------------------------------------------------
bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRef, const bool Ready )
bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRef, const EChannelState State )
{
TChannelLink * LinkChannel;
@@ -233,8 +233,8 @@ bool CFunctionCore::ChannelStateEvent( TChannel * Channel, const char * SourceRe
if (!(LinkChannel = GetLinkChannel( Channel, SourceRef )))
return false;
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Link Channel '%s'-->'%s' - Ready:%s",
ProcessName, Name, Channel->Name, LinkChannel->Channel->Ref, ((Ready)? "Yes" : "No") );
if (Log) Log->Message( LogLevel, dlLow, "%s/%s: Update Link Channel '%s'-->'%s' - State:%s",
ProcessName, Name, Channel->Name, LinkChannel->Channel->Ref, ChannelStateName[State] );
return true;
}
@@ -308,9 +308,9 @@ int CFunctionCore::Input( const char * ChannelName, const char * SourceRef, cons
ProcessName, Name, ((SourceRef && *SourceRef)? SourceRef : "(Any)"), ChannelName );
return 0;
}
else if (!Channel->Ready) {
if (Log) Log->Message( LogLevel, dlHigh, "%s/%s: Channel '%s'->'%s' - Input rejected, Channel not Ready",
ProcessName, Name, ((SourceRef && *SourceRef)? SourceRef : "(Any)"), ChannelName );
else if (!Channel->State) {
if (Log) Log->Message( LogLevel, dlHigh, "%s/%s: Channel '%s'->'%s' - Input rejected, Channel %s",
ProcessName, Name, ((SourceRef && *SourceRef)? SourceRef : "(Any)"), ChannelName, ChannelStateName[Channel->State] );
return 0;
}