Acceptor Dynamic Session Templates (2nd version) #650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enables
"*"wildcards in Acceptor's session configuration (forSenderCompID,SenderSubID,SenderLocationID,TargetCompID,TargetSubID, andTargetLocationID).Such session templates can be defined either at start-up or as an ad-hoc operation, just like "normal" sessions.
When processing a new incoming connection, if the incoming
SessionIDis not equal to any of the created sessions, it is then matched vs. templates with wildcards. Upon the first match, the newSessionis created with the same settings as the template ones, just changing wildcards to the actual values from the incomingSessionID.This PR is an alternative for #607 to address architectural concerns.
Here, instead of changing the
Sessionclass, I added the newSessionProviderclass, implementing in it most of the logic for creatingSessions on-the-fly. Change inSocketReaderis to callSessionProvider.GetSessioninstead ofSession.LookupSession.In
ThreadedSocketAcceptor, the main change is inCreateSession, to check for wildcards in session settings and do not create such aSessionimmediately, but record it as a template while still creatingAcceptorSocketDescriptorfor it. I separated the block of code to do the actual session creation into internalCreateAcceptorSession, soSessionProvidercan call it when it needs to create a newSessionon-the-fly. PlacingSetSessionSettingsalso intoThreadedSocketAcceptormaybe not the best option; still, it seems to fit OK there to change settings for the entire Acceptor.I tried replacing
staticSession.LookupSessionwith alsostaticSessionProvider.GetSession, but that seems to be logically incorrect, asThreadedSocketAcceptoris notstatic, so theoretically, several of its instances may be created, and then they all will share the sameSessionTemplate, which does not look correct. SoThreadedSocketAcceptorhas to create aSessionProviderobject, and pass it throughAcceptorSocketDescriptor->ThreadedSocketReactor->ClientHandlerThreadtoSocketReader, causing minor changes in all those classes. If you think those changes are not necessary, and there can be only oneThreadedSocketAcceptor, thenSessionProvidercan be madestatic. In this case,ThreadedSocketAcceptorwill need to clean up theSessionProvideron itsStop(as staticSessionProviderwill keep templates between acceptor stop/start, causing duplication of the templates).Your remarks would be highly appreciated!