Bug 1608967 - Adapt necko to new neqo r=michal

- process_timer used to be called by process_output, that is not the case any more, therefore we nee$
- how closing/closed event has change: on idle-timeout only closed even is called which means that neqo connection is completely closed and should not be kept alive.

Differential Revision: https://phabricator.services.mozilla.com/D59801

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dragana Damjanovic 2020-01-20 21:06:07 +00:00
Родитель e9bb1fcf9f
Коммит a3834a2925
4 изменённых файлов: 36 добавлений и 6 удалений

Просмотреть файл

@ -59,6 +59,7 @@ Http3Session::Http3Session()
mCleanShutdown(false),
mGoawayReceived(false),
mShouldClose(false),
mIsClosedByNeqo(false),
mError(NS_OK),
mBeforeConnectedError(false) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
@ -331,8 +332,9 @@ nsresult Http3Session::ProcessEvents(uint32_t count, uint32_t* countWritten,
if (NS_SUCCEEDED(mError) && !IsClosing()) {
mError = NS_ERROR_NET_HTTP3_PROTOCOL_ERROR;
}
CloseInternal(false);
mState = CLOSED;
mIsClosedByNeqo = true;
// We need to return here and let nsHttpConnection close the session.
return mError;
break;
default:
break;
@ -430,6 +432,7 @@ nsresult Http3Session::ProcessOutput() {
// This is only called when timer expires.
nsresult Http3Session::ProcessOutputAndEvents() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mHttp3Connection->ProcessTimer();
nsresult rv = ProcessOutput();
if (NS_FAILED(rv)) {
return rv;
@ -437,8 +440,8 @@ nsresult Http3Session::ProcessOutputAndEvents() {
mHttp3Connection->ProcessHttp3();
bool notUsed;
uint32_t n = 0;
Unused << ProcessEvents(nsIOService::gDefaultSegmentSize, &n, &notUsed);
if (mState == CLOSED) {
rv = ProcessEvents(nsIOService::gDefaultSegmentSize, &n, &notUsed);
if (NS_FAILED(rv)) {
// Now we can remove all references and Http3Session will be destroyed.
if (mTimer) {
mTimer->Cancel();
@ -446,6 +449,7 @@ nsresult Http3Session::ProcessOutputAndEvents() {
mConnection = nullptr;
mSocketTransport = nullptr;
mSegmentReaderWriter = nullptr;
mState = CLOSED;
}
return NS_OK;
}
@ -794,6 +798,14 @@ nsresult Http3Session::WriteSegmentsAgain(nsAHttpSegmentWriter* writer,
if (NS_SUCCEEDED(rv)) {
Unused << mConnection->ResumeRecv();
}
uint64_t timeout = mHttp3Connection->ProcessOutput();
// Check if we have datagrams to send. If we have let's poll for writing.
if (mConnection && mHttp3Connection->HasDataToSend()) {
Unused << mConnection->ResumeSend();
}
SetupTimer(timeout);
return rv;
}
@ -802,8 +814,10 @@ void Http3Session::Close(nsresult aReason) {
mError = aReason;
CloseInternal(true);
if (mCleanShutdown) {
// It is network-tear-down. We need to remove all references, so that
if (mCleanShutdown || mIsClosedByNeqo) {
// It is network-tear-down or neqo is state CLOSED(it does not need to send
// any more packets or wait for new packets).
// We need to remove all references, so that
// Http3Session will be destroyed.
if (mTimer) {
mTimer->Cancel();
@ -811,6 +825,7 @@ void Http3Session::Close(nsresult aReason) {
mConnection = nullptr;
mSocketTransport = nullptr;
mSegmentReaderWriter = nullptr;
mState = CLOSED;
}
}

Просмотреть файл

@ -150,6 +150,7 @@ class Http3Session final : public nsAHttpTransaction,
bool mCleanShutdown;
bool mGoawayReceived;
bool mShouldClose;
bool mIsClosedByNeqo;
nsresult mError;
bool mBeforeConnectedError;
uint64_t mCurrentForegroundTabOuterContentWindowId;

Просмотреть файл

@ -43,6 +43,10 @@ class NeqoHttp3Conn final {
uint64_t ProcessOutput() { return neqo_http3conn_process_output(this); }
void ProcessTimer() { neqo_http3conn_process_timer(this); }
bool HasDataToSend() { return neqo_http3conn_has_data_to_send(this); }
nsresult GetDataToSend(nsTArray<uint8_t>& aData) {
aData.TruncateLength(0);
return neqo_http3conn_get_data_to_send(this, &aData);

Просмотреть файл

@ -180,6 +180,16 @@ pub extern "C" fn neqo_http3conn_process_output(conn: &mut NeqoHttp3Conn) -> u64
}
}
#[no_mangle]
pub extern "C" fn neqo_http3conn_process_timer(conn: &mut NeqoHttp3Conn) {
conn.conn.process_timer(Instant::now());
}
#[no_mangle]
pub extern "C" fn neqo_http3conn_has_data_to_send(conn: &mut NeqoHttp3Conn) -> bool {
!conn.packets_to_send.is_empty()
}
#[no_mangle]
pub extern "C" fn neqo_http3conn_get_data_to_send(
conn: &mut NeqoHttp3Conn,