Skip to content

Commit

Permalink
[#575] Protocol violation when sending FLOW
Browse files Browse the repository at this point in the history
  • Loading branch information
xinchen10 committed Nov 13, 2023
1 parent 58f4d15 commit 3e42f0c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ internal void SendFlow(Flow flow)
this.incomingWindow = defaultWindowSize;
flow.NextOutgoingId = this.nextOutgoingId;
flow.OutgoingWindow = this.outgoingWindow;
flow.NextIncomingId = this.nextIncomingId;
flow.IncomingWindow = this.incomingWindow;
if (this.state >= SessionState.BeginReceived)
{
flow.NextIncomingId = this.nextIncomingId;
}

this.SendCommand(flow);
}
Expand Down
39 changes: 39 additions & 0 deletions test/Common/ProtocolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,45 @@ public void RemoteSessionChannelTest()
Assert.IsTrue(connection.Error == null, "connection has error!" + connection.Error);
}

[TestMethod]
public void FlowNextIncomingIdTest()
{
string testName = "FlowNextIncomingIdTest";

List flow = null;
ManualResetEvent received = new ManualResetEvent(false);

this.testListener.RegisterTarget(TestPoint.Begin, (stream, channel, fields) =>
{
return TestOutcome.Stop;
});

this.testListener.RegisterTarget(TestPoint.Attach, (stream, channel, fields) =>
{
return TestOutcome.Stop;
});

this.testListener.RegisterTarget(TestPoint.Flow, (stream, channel, fields) =>
{
TestListener.FRM(stream, 0x11UL, 0, channel, channel, 0u, 100u, 100u, 8u);
TestListener.FRM(stream, 0x12UL, 0, channel, testName, 0u, false, null, null, new Source(), new Target());
flow = fields;
received.Set();
return TestOutcome.Stop;
});

Open open = new Open() { ContainerId = testName, HostName = "localhost", MaxFrameSize = 2048 };
Connection connection = new Connection(this.address, null, open, null);
Session session = new Session(connection);
ReceiverLink receiver = new ReceiverLink(session, testName, "foo");
receiver.SetCredit(100);
received.WaitOne(3000);
connection.Close();

Assert.IsTrue(flow != null, "flow is null");
Assert.IsTrue(flow[0] == null, "next-incoming-id is not null");
}

[TestMethod]
public void RemoteLinkHandleTest()
{
Expand Down

0 comments on commit 3e42f0c

Please sign in to comment.