@@ -71,10 +71,18 @@ Http3Session::Http3Session() {
71
71
mThroughCaptivePortal = gHttpHandler ->GetThroughCaptivePortal ();
72
72
}
73
73
74
- static nsresult StringAndPortToNetAddr (nsACString& remoteAddrStr,
75
- uint16_t remotePort, NetAddr* netAddr) {
76
- if (NS_FAILED(netAddr->InitFromString (remoteAddrStr, remotePort))) {
77
- return NS_ERROR_FAILURE;
74
+ static nsresult RawBytesToNetAddr (uint16_t aFamily, const uint8_t * aRemoteAddr,
75
+ uint16_t remotePort, NetAddr* netAddr) {
76
+ if (aFamily == AF_INET) {
77
+ netAddr->inet .family = AF_INET;
78
+ netAddr->inet .port = htons (remotePort);
79
+ memcpy (&netAddr->inet .ip , aRemoteAddr, 4 );
80
+ } else if (aFamily == AF_INET6) {
81
+ netAddr->inet6 .family = AF_INET6;
82
+ netAddr->inet6 .port = htons (remotePort);
83
+ memcpy (&netAddr->inet6 .ip .u8 , aRemoteAddr, 16 );
84
+ } else {
85
+ return NS_ERROR_UNEXPECTED;
78
86
}
79
87
80
88
return NS_OK;
@@ -133,6 +141,7 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
133
141
StaticPrefs::network_http_http3_max_stream_data (),
134
142
StaticPrefs::network_http_http3_version_negotiation_enabled (),
135
143
mConnInfo ->GetWebTransport (), gHttpHandler ->Http3QlogDir (), datagramSize,
144
+ StaticPrefs::network_http_http3_max_accumlated_time_ms (),
136
145
getter_AddRefs (mHttp3Connection ));
137
146
if (NS_FAILED(rv)) {
138
147
return rv;
@@ -882,46 +891,46 @@ nsresult Http3Session::ProcessOutput(nsIUDPSocket* socket) {
882
891
LOG ((" Http3Session::ProcessOutput reader=%p, [this=%p]" , mUdpConn .get (),
883
892
this ));
884
893
885
-
886
-
887
- while (true ) {
888
- nsTArray<uint8_t > packetToSend;
889
- nsAutoCString remoteAddrStr;
890
- uint16_t port = 0 ;
891
- uint64_t timeout = 0 ;
892
- if (!mHttp3Connection ->ProcessOutput (&remoteAddrStr, &port, packetToSend,
893
- &timeout)) {
894
- SetupTimer (timeout);
895
- break ;
896
- }
897
- MOZ_ASSERT (packetToSend.Length ());
898
- LOG (
899
- (" Http3Session::ProcessOutput sending packet with %u bytes to %s "
900
- " port=%d [this=%p]." ,
901
- (uint32_t )packetToSend.Length (),
902
- PromiseFlatCString (remoteAddrStr).get (), port, this ));
903
-
904
- uint32_t written = 0 ;
905
- NetAddr addr;
906
- if (NS_FAILED(StringAndPortToNetAddr (remoteAddrStr, port, &addr))) {
907
- continue ;
908
- }
909
- nsresult rv = socket->SendWithAddress (&addr, packetToSend, &written);
894
+ mSocket = socket;
895
+ nsresult rv = mHttp3Connection ->ProcessOutputAndSend (
896
+ this ,
897
+ [](void * aContext, uint16_t aFamily, const uint8_t * aAddr, uint16_t aPort,
898
+ const uint8_t * aData, uint32_t aLength) {
899
+ Http3Session* self = (Http3Session*)aContext;
900
+
901
+ uint32_t written = 0 ;
902
+ NetAddr addr;
903
+ if (NS_FAILED(RawBytesToNetAddr (aFamily, aAddr, aPort, &addr))) {
904
+ return NS_OK;
905
+ }
910
906
911
- LOG ((" Http3Session::ProcessOutput sending packet rv=%d osError=%d" ,
912
- static_cast <int32_t >(rv), NS_FAILED(rv) ? PR_GetOSError () : 0 ));
913
- if (NS_FAILED(rv) && (rv != NS_BASE_STREAM_WOULD_BLOCK)) {
914
- mSocketError = rv;
915
-
916
-
917
-
918
- return rv;
919
- }
920
- mTotalBytesWritten += packetToSend.Length ();
921
- mLastWriteTime = PR_IntervalNow ();
922
- }
907
+ LOG3 (
908
+ (" Http3Session::ProcessOutput sending packet with %u bytes to %s "
909
+ " port=%d [this=%p]." ,
910
+ aLength, addr.ToString ().get (), aPort, self));
923
911
924
- return NS_OK;
912
+ nsresult rv =
913
+ self->mSocket ->SendWithAddress (&addr, aData, aLength, &written);
914
+
915
+ LOG ((" Http3Session::ProcessOutput sending packet rv=%d osError=%d" ,
916
+ static_cast <int32_t >(rv), NS_FAILED(rv) ? PR_GetOSError () : 0 ));
917
+ if (NS_FAILED(rv) && (rv != NS_BASE_STREAM_WOULD_BLOCK)) {
918
+ self->mSocketError = rv;
919
+
920
+
921
+
922
+ return rv;
923
+ }
924
+ self->mTotalBytesWritten += aLength;
925
+ self->mLastWriteTime = PR_IntervalNow ();
926
+ return NS_OK;
927
+ },
928
+ [](void * aContext, uint64_t timeout) {
929
+ Http3Session* self = (Http3Session*)aContext;
930
+ self->SetupTimer (timeout);
931
+ });
932
+ mSocket = nullptr ;
933
+ return rv;
925
934
}
926
935
927
936
@@ -955,7 +964,8 @@ void Http3Session::SetupTimer(uint64_t aTimeout) {
955
964
return ;
956
965
}
957
966
958
- LOG ((" Http3Session::SetupTimer to %" PRIu64 " ms [this=%p]." , aTimeout, this ));
967
+ LOG3 (
968
+ (" Http3Session::SetupTimer to %" PRIu64 " ms [this=%p]." , aTimeout, this ));
959
969
960
970
961
971
mTimerShouldTrigger =
0 commit comments