Closed Bug 1622861 Opened 4 years ago Closed 4 years ago

Improve Http3 closing

Categories

(Core :: Networking: HTTP, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: dragana, Assigned: dragana)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(2 files)

Http3 is a bit tricky in the regard of closing a connection. There are a couple of ways this can happen:

  1. a socket error
  2. a Firefoxshutdown
  3. a neqo error
  4. http3 timeout
  5. necko closing connection without a shutdown

This is explainer how this should work:

Socket error:
mSocketError will be set.
ProcessInput or ProcessOutput will return an error and their callers will close connection by calling CloseTransaction(the name is because of compatibility with http1.1)
Their callers are:

  1. HttpConnectionUDP::OnInputStreamReady -> HttpConnectionUDP::OnSocketReadable -> Http3Session::WriteSegmentsAgain -> ProcessInput
    HttpConnectionUDP::OnQuicTimeoutExpired
  2. HttpConnectionUDP::OnQuicTimeoutExpired -> ProcessOutput
  3. HttpConnectionUDP::OnOutputStreamReady -> HttpConnectionUDP::OnSocketWritable -> Http3Session::ReadSegmentsAgain -> ProcessOutput

CloseTransaction will call mHttp3Session->Close. Because this is a socket error we do not need to try to send any CLOSE_CONNECTION frame, we can just close neqo and remove references.

Firefox Shutdown:
on shutdown CloseTransaction will be called with aIsShutdown set. This will also close Http3Session and remove any reference. A CLOSE_CONNECTION frame will not be sent.

Neqo error:
A Http3Event::Tag::ConnectionClosing event will be received from neqo. mError will be set to NS_ERROR_NET_HTTP3_PROTOCOL_ERROR (TODO, I think this is fine, buy may be revisited) and the same error will be return. A caller will closed the connection by calling CloseTransaction.
Callers are:

  1. HttpConnectionUDP::OnQuicTimeoutExpired -> ProcessEvents
  2. HttpConnectionUDP::OnInputStreamReady -> HttpConnectionUDP::OnSocketReadable -> Http3Session::WriteSegmentsAgain -> ProcessInput

In this case will close Http3Session, but we will keep Http3Session and HttpConnectionUDP still in nsHttpConnectiomMgr's active list. The connection is in the active list but it will not be used for any transaction.

There are a couple of ways it will be removed from the list:

  1. After a neqo timeout a Http3Event::Tag::ConnectionClosed event will be received. This event be read in one of 2 paths above(moste probably from OnQuicTimeoutExpired). This will try to close http3 session again and this time the http3Session will change into CLOSED state and it will delete all reference.
  2. There is a shutdown: CloseTransaction will be called with aIsShutdown set. This will also close Http3Session and remove any reference.

Http3 timeout:
A Http3Event::Tag::ConnectionClosed event will be received (without receiving a Http3Event::Tag::ConnectionClosing event).
A caller will closed the connection by calling CloseTransaction.
Callers are:

  1. HttpConnectionUDP::OnQuicTimeoutExpired -> ProcessEvents
  2. HttpConnectionUDP::OnInputStreamReady -> HttpConnectionUDP::OnSocketReadable -> Http3Session::WriteSegmentsAgain -> ProcessInputCloseTransaction will call mHttp3Session->Close. Because this is a timeout and neqo has been closed already we can just remove references.

necko closing connection without a shutdown:
CloseTransaction will call mHttp3Session->Close. In this case will close Http3Session, but we will keep Http3Session and HttpConnectionUDP still in nsHttpConnectiomMgr's active list. The connection is in the active list but it will not be used for any transaction.

There are a couple of ways it will be removed from the list:

  1. After a neqo timeout a Http3Event::Tag::ConnectionClosed event will be received. This event be read in one of 2 paths above(most probably from OnQuicTimeoutExpired). This will try to close http3 session again and this time the http3Session will change into/ CLOSED state and it will delete all reference.
  2. There is a shutdown: CloseTransaction will be called with aIsShutdown set. This will also close Http3Session and remove any reference.
Attachment #9133611 - Attachment description: Bug 1622861 - Make closing of http3 connection more understandable asnd remove some unused code. r=mayhemer → Bug 1622861 - Make closing of http3 connection more understandable and remove some unused code. r=mayhemer
Pushed by ddamjanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bf921cb07c7d
Make closing of http3 connection more understandable and remove some unused code. r=mayhemer
Pushed by ddamjanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bb6a227ceda7
Check that Http3Session is present in HttpConnectionUDP::CloseTransaction. r=kershaw
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: