Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #173 - Message.IsAdmin/IsApp wrong check #174

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion QuickFIXn/AbstractInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, Se
{ }

public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
: this(new SessionFactory(app, storeFactory, logFactory, messageFactory), settings)
{ }

public AbstractInitiator(SessionFactory factory, SessionSettings settings)
{
settings_ = settings;

HashSet<SessionID> definedSessions = settings.GetSessions();
if (0 == definedSessions.Count)
throw new ConfigError("No sessions defined");

SessionFactory factory = new SessionFactory(app, storeFactory, logFactory, messageFactory);
foreach (SessionID sessionID in definedSessions)
{
Dictionary dict = settings.Get(sessionID);
Expand Down
5 changes: 3 additions & 2 deletions QuickFIXn/Message/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ protected int SetGroup(
{
// We were already building an entry, so the delimiter means it's done.
fieldMap.AddGroup(grp, false);
grp = null;
}

// Create a new group!
Expand Down Expand Up @@ -693,15 +694,15 @@ public int CheckSum()

public bool IsAdmin()
{
if(!IsSetField(Tags.MsgType))
if (!this.Header.IsSetField(Tags.MsgType))
return false;
string msgType = this.Header.GetField(Tags.MsgType); /// FIXME
return IsAdminMsgType(msgType);
}

public bool IsApp()
{
if (!IsSetField(Tags.MsgType))
if (!this.Header.IsSetField(Tags.MsgType))
return false;
string msgType = this.Header.GetField(Tags.MsgType); /// FIXME
return !IsAdminMsgType(msgType);
Expand Down
7 changes: 7 additions & 0 deletions QuickFIXn/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,13 @@ protected void NextLogon(Message logon)
logon.GetField(resetSeqNumFlag);
state_.ReceivedReset = resetSeqNumFlag.Obj;

if (state_.ReceivedReset)
{
this.Log.OnEvent("Logon contains ResetSeqNumFlag=Y, reseting sequence numbers to 1");
if (!state_.SentReset)
state_.Reset("Reseting because reset was requested by counterparty.");
}

if (!state_.IsInitiator && this.ResetOnLogon)
state_.Reset("ResetOnLogon");

Expand Down
40 changes: 22 additions & 18 deletions QuickFIXn/Transport/SocketInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public bool Connected

#region Private Members

private IApplication app_;
private SessionSettings settings_;
private IMessageStoreFactory storeFactory_;
private ILogFactory logFactory_;
private Socket socket_ = null;
private byte[] _readBuffer = new byte[512];
private volatile bool shutdownRequested_ = false;
Expand All @@ -54,24 +50,30 @@ public bool Connected

public SocketInitiator(IApplication application, IMessageStoreFactory storeFactory, SessionSettings settings)
: this(application, storeFactory, settings, null)
{ }
{
}

public SocketInitiator(IApplication application, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory)
: base(application, storeFactory, settings, logFactory)
: this(application, storeFactory, settings, logFactory, null)
{
app_ = application;
storeFactory_ = storeFactory;
settings_ = settings;
logFactory_ = logFactory;
}

public SocketInitiator(IApplication application, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
: base(application, storeFactory, settings, logFactory, messageFactory)
: this(new SessionFactory(application, storeFactory, logFactory, messageFactory), settings)
{
app_ = application;
storeFactory_ = storeFactory;
settings_ = settings;
logFactory_ = logFactory;
}

public SocketInitiator(SessionFactory sessionFactory, SessionSettings settings)
: base(sessionFactory, settings)
{
}

/// <summary>
/// Resets last reconenct try time so that engine tries to connect immediatelly
/// </summary>
public void ResetReconnectTime()
{
lastConnectTimeDT = DateTime.MinValue;
}

public static void SocketInitiatorThreadStart(object socketInitiatorThread)
Expand All @@ -84,7 +86,8 @@ public static void SocketInitiatorThreadStart(object socketInitiatorThread)
t.Session.Log.OnEvent("Connection succeeded");
t.Session.Next();
while (t.Read())
{ }
{
}
if (t.Initiator.IsStopped)
t.Initiator.RemoveThread(t);
t.Initiator.SetDisconnected(t.Session.SessionID);
Expand Down Expand Up @@ -155,7 +158,8 @@ protected override void OnConfigure(SessionSettings settings)
reconnectInterval_ = Convert.ToInt32(settings.Get().GetLong(SessionSettings.RECONNECT_INTERVAL));
}
catch (System.Exception)
{ }
{
}
if (settings.Get().Has(SessionSettings.SOCKET_NODELAY))
{
socketSettings_.SocketNodelay = settings.Get().GetBool(SessionSettings.SOCKET_NODELAY);
Expand All @@ -166,7 +170,7 @@ protected override void OnStart()
{
shutdownRequested_ = false;

while(!shutdownRequested_)
while (!shutdownRequested_)
{
double reconnectIntervalAsMilliseconds = 1000 * reconnectInterval_;
DateTime nowDT = DateTime.UtcNow;
Expand Down