Closed Bug 1355700 Opened 8 years ago Closed 8 years ago

Count the available connections correctly at nsHttpConnectionMgr::AtActiveConnectionLimit

Categories

(Core :: Networking, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: kershaw, Assigned: kershaw)

References

Details

(Whiteboard: [necko-active])

Attachments

(1 file, 2 obsolete files)

This is a regression of bug 1312782. Since nsHttpConnectionMgr::AvailableNewConnectionCount [1] always returns an unsigned integer, we handled the available count for urgent-start case incorrectly. [1] http://searchfox.org/mozilla-central/rev/2fc8c8d483d9ec9fd0ec319c6c53807f7fa8e8a2/netwerk/protocol/http/nsHttpConnectionMgr.cpp#946-948
Summary: - Change the return value of AvailableNewConnectionCount to int32_t - Fix the regression of counting connections for urgent-start transactions Thanks.
Attachment #8857330 - Flags: review?(honzab.moz)
Blocks: 1312782, 1348053
Whiteboard: [necko-active]
Dragana, just FYI when you are looking at bug 1355539 in case this patch happens to be related. But from quickly looking at it, it's probably not...
Comment on attachment 8857330 [details] [diff] [review] Correct the count of available new connection Review of attachment 8857330 [details] [diff] [review]: ----------------------------------------------------------------- ::: netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ +1030,5 @@ > LOG(("nsHttpConnectionMgr::AvailableNewConnectionCount " > "total connection count = %d, limit %d\n", > totalCount, maxPersistConns)); > > + return maxPersistConns - totalCount; you are mixing uint16 and uint32 and the result is int32. that's not good. you need to static cast or something. @@ +1184,4 @@ > if (caps & NS_HTTP_URGENT_START) { > + if (availableConnections < 0 && > + (static_cast<int32_t>(Abs(availableConnections)) >= > + static_cast<int32_t>(mMaxUrgentExcessiveConns))) { This could be better written as: // AvailableNewConnectionCount may return a negative number when we are over // the default per-host limit. if (-availableConnections > static_cast<int32_t>(mMaxUrgentExcessiveConns)) { } It took a while to decypher this, since IMO it's naturally expected that AvailableNewConnectionCount returns an unsigned result. We could go with this 'signed' approach is we find a good name for the AvailableNewConnectionCount method. This name simply doesn't reflect the return value. ConnectionAvailability? ConnectionBalance? I really don't know, what may show that it's not a good idea to let it return a signed int. You can always somewhat return to the code as it was before https://bugzilla.mozilla.org/attachment.cgi?id=8851541&action=diff#a/netwerk/protocol/http/nsHttpConnectionMgr.cpp_sec7 ::: netwerk/protocol/http/nsHttpConnectionMgr.h @@ +474,5 @@ > bool considerAll); > > // Given the connection entry, return the available count for creating > // new connections. Return 0 if the active connection count is > // exceeded |mMaxPersistConnsPerProxy| or |mMaxPersistConnsPerHost|. and the comment definitely needs an update too
Attachment #8857330 - Flags: review?(honzab.moz) → feedback+
(In reply to Honza Bambas (:mayhemer) from comment #3) > Comment on attachment 8857330 [details] [diff] [review] > Correct the count of available new connection > > Review of attachment 8857330 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: netwerk/protocol/http/nsHttpConnectionMgr.cpp > @@ +1030,5 @@ > > LOG(("nsHttpConnectionMgr::AvailableNewConnectionCount " > > "total connection count = %d, limit %d\n", > > totalCount, maxPersistConns)); > > > > + return maxPersistConns - totalCount; > > you are mixing uint16 and uint32 and the result is int32. that's not good. > you need to static cast or something. > Got it. Thanks. > @@ +1184,4 @@ > > if (caps & NS_HTTP_URGENT_START) { > > + if (availableConnections < 0 && > > + (static_cast<int32_t>(Abs(availableConnections)) >= > > + static_cast<int32_t>(mMaxUrgentExcessiveConns))) { > > This could be better written as: > > // AvailableNewConnectionCount may return a negative number when we are over > // the default per-host limit. > if (-availableConnections > static_cast<int32_t>(mMaxUrgentExcessiveConns)) { > } > > It took a while to decypher this, since IMO it's naturally expected that > AvailableNewConnectionCount returns an unsigned result. > Agree. It's too complicated and also hard to read. > We could go with this 'signed' approach is we find a good name for the > AvailableNewConnectionCount method. This name simply doesn't reflect the > return value. > > ConnectionAvailability? ConnectionBalance? I really don't know, what may > show that it's not a good idea to let it return a signed int. You can > always somewhat return to the code as it was before > https://bugzilla.mozilla.org/attachment.cgi?id=8851541&action=diff#a/netwerk/ > protocol/http/nsHttpConnectionMgr.cpp_sec7 > Maybe we should split |AvailableNewConnectionCount| into two functions: TotalActiveConnections and MaxPersistConnections. This should make the code easier to read. Moreover, I can change the code as it was before, which is clear and less error-prone.
Summary: - Split AvailableNewConnectionCount into two functions - Change the code in |AtActiveConnectionLimit| back Thanks.
Attachment #8857330 - Attachment is obsolete: true
Attachment #8858769 - Flags: review?(honzab.moz)
Comment on attachment 8858769 [details] [diff] [review] Correct the count of available new connection - v2 Review of attachment 8858769 [details] [diff] [review]: ----------------------------------------------------------------- lgtm, thanks ::: netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ +1097,3 @@ > > if (caps & NS_HTTP_URGENT_START) { > + if (totalCount >= static_cast<uint32_t>(mMaxUrgentExcessiveConns + maxPersistConns)) { do we still need the static_cast?
Attachment #8858769 - Flags: review?(honzab.moz) → review+
and please push to try before landing and also make sure the problem that you found this issue through is fixed.
Carry reviewer's name.
Attachment #8858769 - Attachment is obsolete: true
Attachment #8859818 - Flags: review+
Keywords: checkin-needed
Pushed by ihsiao@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/e2fccaa1a87a Correct the count of available new connections. r=honzab
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: