http2: improve GoAway handling

This commit is contained in:
Thomas Kriechbaumer 2016-05-26 13:43:24 +02:00
parent 7f4ac6f27b
commit ac70eaed66

View File

@ -165,9 +165,21 @@ class Http2Layer(base.Layer):
new_settings = dict([(id, cs.new_value) for (id, cs) in six.iteritems(event.changed_settings)]) new_settings = dict([(id, cs.new_value) for (id, cs) in six.iteritems(event.changed_settings)])
other_conn.h2.safe_update_settings(new_settings) other_conn.h2.safe_update_settings(new_settings)
elif isinstance(event, events.ConnectionTerminated): elif isinstance(event, events.ConnectionTerminated):
# Do not immediately terminate the other connection. if event.error_code == h2.errors.NO_ERROR:
# Some streams might be still sending data to the client. # Do not immediately terminate the other connection.
return False # Some streams might be still sending data to the client.
return False
else:
# Something terrible has happened - kill everything!
self.client_conn.h2.close_connection(
error_code=event.error_code,
last_stream_id=event.last_stream_id,
additional_data=event.additional_data
)
self.client_conn.send(self.client_conn.h2.data_to_send())
self._kill_all_streams()
return False
elif isinstance(event, events.PushedStreamReceived): elif isinstance(event, events.PushedStreamReceived):
# pushed stream ids should be unique and not dependent on race conditions # pushed stream ids should be unique and not dependent on race conditions
# only the parent stream id must be looked up first # only the parent stream id must be looked up first