Skip to content
Merged
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
11 changes: 6 additions & 5 deletions proxy/http2/Http2ClientSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ Http2ClientSession::free()
void
Http2ClientSession::start()
{
VIO *read_vio;

SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());

SET_HANDLER(&Http2ClientSession::main_event_handler);
HTTP2_SET_SESSION_HANDLER(&Http2ClientSession::state_read_connection_preface);

read_vio = this->do_io_read(this, INT64_MAX, this->read_buffer);
write_vio = this->do_io_write(this, INT64_MAX, this->sm_writer);
VIO *read_vio = this->do_io_read(this, INT64_MAX, this->read_buffer);
write_vio = this->do_io_write(this, INT64_MAX, this->sm_writer);

// 3.5 HTTP/2 Connection Preface. Upon establishment of a TCP connection and
// determination that HTTP/2 will be used by both peers, each endpoint MUST
Expand All @@ -183,7 +181,10 @@ Http2ClientSession::start()

this->connection_state.init();
send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_INIT, this);
this->handleEvent(VC_EVENT_READ_READY, read_vio);

if (this->sm_reader->is_read_avail_more_than(0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implicitly says we have something to do if we can read 1 byte. What is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be Connection Preface ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the first byte of Connection Preface here? The length should be 10 bytes or so.

Copy link
Contributor Author

@masaori335 masaori335 Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not put these assumption here to make the logic simple.

Think about the error cases, if we start reading with 1 byte, the handler can reject the connection with malformed strings smaller than 10 bytes. ( actually, current state_read_connection_preface() doesn't do this )

Also, in the HTTP/2 over TLS case this is 0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we could remove this since nobody cares cleartext H2. That would be more simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's my first idea, but I'm not confident because there is a path of the buffer is given to the the Http2SessionAccept from the outside.

this->handleEvent(VC_EVENT_READ_READY, read_vio);
}
}

void
Expand Down