Skip to content

Commit a0b2707

Browse files
yschimkelehecka
authored andcommitted
proper fix for sending the frame too early (#104)
1 parent b5522e0 commit a0b2707

File tree

5 files changed

+12
-31
lines changed

5 files changed

+12
-31
lines changed

src/ConnectionAutomaton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void ConnectionAutomaton::connect() {
4646
? keepaliveTimer_->keepaliveTime().count()
4747
: std::numeric_limits<uint32_t>::max();
4848

49-
// TODO set correct version
49+
// TODO set correct version and allow clients to configure
5050
Frame_SETUP frame(
5151
FrameFlags_EMPTY,
5252
0,
@@ -55,7 +55,7 @@ void ConnectionAutomaton::connect() {
5555
"",
5656
"",
5757
Payload());
58-
connectionOutput_.onNext(frame.serializeOut());
58+
onNextFrame(frame.serializeOut());
5959
}
6060
stats_.socketCreated();
6161

test/InlineConnection.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ InlineConnection::InlineConnection()
2121
InlineConnection::~InlineConnection() {}
2222

2323
void InlineConnection::connectTo(
24-
InlineConnection& other,
25-
bool expectSetupFrame) {
24+
InlineConnection& other) {
2625
ASSERT_FALSE(other_);
2726
ASSERT_FALSE(other.other_);
2827
other.other_ = this;
2928
other_ = &other;
30-
// this could just be true for the client, false for the server. However
31-
// InlineConnection is below the
32-
// ReactiveSocket layer so any tests that just use DuplexConnection may break
33-
// this
34-
expectSetupFrame_ = expectSetupFrame;
3529
}
3630

3731
void InlineConnection::setInput(
@@ -86,18 +80,6 @@ Subscriber<std::unique_ptr<folly::IOBuf>>& InlineConnection::getOutput() {
8680
inputSink->onSubscribe(*outputSubscription_);
8781
}
8882
}));
89-
// SETUP
90-
if (expectSetupFrame_) {
91-
EXPECT_CALL(outputSink, onNext_(_))
92-
.Times(1)
93-
.InSequence(s)
94-
.WillRepeatedly(Invoke([this](std::unique_ptr<folly::IOBuf>& frame) {
95-
ASSERT_TRUE(other_);
96-
ASSERT_FALSE(other_->outputSubscription_);
97-
auto inputSink = other_->inputSink_;
98-
ASSERT_FALSE(inputSink);
99-
}));
100-
}
10183
EXPECT_CALL(outputSink, onNext_(_))
10284
.Times(AnyNumber())
10385
.InSequence(s)

test/InlineConnection.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class InlineConnection : public DuplexConnection {
3535
/// This method may be invoked at most once per lifetime of the object and
3636
/// implicitly connects the `other` to this instance. Must be invoked before
3737
/// accessing input or output of the connection.
38-
void connectTo(InlineConnection& other, bool expectSetupFrame);
38+
void connectTo(InlineConnection& other);
3939

4040
void setInput(Subscriber<std::unique_ptr<folly::IOBuf>>& inputSink) override;
4141

@@ -52,6 +52,5 @@ class InlineConnection : public DuplexConnection {
5252
folly::exception_wrapper inputSinkError_;
5353
/// @}
5454
Subscription* outputSubscription_;
55-
bool expectSetupFrame_{false};
5655
};
5756
}

test/InlineConnectionTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TEST(InlineConnectionTest, PingPong) {
1818
// calls will be deterministic.
1919
Sequence s;
2020
std::array<InlineConnection, 2> end;
21-
end[0].connectTo(end[1], false);
21+
end[0].connectTo(end[1]);
2222

2323
std::array<UnmanagedMockSubscriber<std::unique_ptr<folly::IOBuf>>, 2> input;
2424
std::array<UnmanagedMockSubscription, 2> outputSub;

test/ReactiveSocketTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TEST(ReactiveSocketTest, RequestChannel) {
4040

4141
auto clientConn = folly::make_unique<InlineConnection>();
4242
auto serverConn = folly::make_unique<InlineConnection>();
43-
clientConn->connectTo(*serverConn, true);
43+
clientConn->connectTo(*serverConn);
4444

4545
StrictMock<UnmanagedMockSubscriber<Payload>> clientInput, serverInput;
4646
StrictMock<UnmanagedMockSubscription> clientOutputSub, serverOutputSub;
@@ -148,7 +148,7 @@ TEST(ReactiveSocketTest, RequestStreamComplete) {
148148

149149
auto clientConn = folly::make_unique<InlineConnection>();
150150
auto serverConn = folly::make_unique<InlineConnection>();
151-
clientConn->connectTo(*serverConn, true);
151+
clientConn->connectTo(*serverConn);
152152

153153
StrictMock<UnmanagedMockSubscriber<Payload>> clientInput;
154154
StrictMock<UnmanagedMockSubscription> serverOutputSub;
@@ -227,7 +227,7 @@ TEST(ReactiveSocketTest, RequestStreamCancel) {
227227

228228
auto clientConn = folly::make_unique<InlineConnection>();
229229
auto serverConn = folly::make_unique<InlineConnection>();
230-
clientConn->connectTo(*serverConn, true);
230+
clientConn->connectTo(*serverConn);
231231

232232
StrictMock<UnmanagedMockSubscriber<Payload>> clientInput;
233233
StrictMock<UnmanagedMockSubscription> serverOutputSub;
@@ -303,7 +303,7 @@ TEST(ReactiveSocketTest, RequestSubscription) {
303303

304304
auto clientConn = folly::make_unique<InlineConnection>();
305305
auto serverConn = folly::make_unique<InlineConnection>();
306-
clientConn->connectTo(*serverConn, true);
306+
clientConn->connectTo(*serverConn);
307307

308308
StrictMock<UnmanagedMockSubscriber<Payload>> clientInput;
309309
StrictMock<UnmanagedMockSubscription> serverOutputSub;
@@ -380,7 +380,7 @@ TEST(ReactiveSocketTest, RequestFireAndForget) {
380380

381381
auto clientConn = folly::make_unique<InlineConnection>();
382382
auto serverConn = folly::make_unique<InlineConnection>();
383-
clientConn->connectTo(*serverConn, true);
383+
clientConn->connectTo(*serverConn);
384384

385385
StrictMock<UnmanagedMockSubscriber<Payload>> clientInput;
386386
StrictMock<UnmanagedMockSubscription> serverOutputSub;
@@ -412,7 +412,7 @@ TEST(ReactiveSocketTest, RequestMetadataPush) {
412412

413413
auto clientConn = folly::make_unique<InlineConnection>();
414414
auto serverConn = folly::make_unique<InlineConnection>();
415-
clientConn->connectTo(*serverConn, true);
415+
clientConn->connectTo(*serverConn);
416416

417417
StrictMock<UnmanagedMockSubscriber<Payload>> clientInput;
418418
StrictMock<UnmanagedMockSubscription> serverOutputSub;
@@ -443,7 +443,7 @@ TEST(ReactiveSocketTest, Destructor) {
443443

444444
auto clientConn = folly::make_unique<InlineConnection>();
445445
auto serverConn = folly::make_unique<InlineConnection>();
446-
clientConn->connectTo(*serverConn, true);
446+
clientConn->connectTo(*serverConn);
447447

448448
// TODO: since we don't assert anything, should we just use the StatsPrinter
449449
// instead?

0 commit comments

Comments
 (0)