Index: net/socket/client_socket_pool_base.cc |
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc |
index 912dfeeaff137b4752f896e91eacf779b791966a..f5978625bd2e0ce2ae805ae55f2ff565b5ef1728 100644 |
--- a/net/socket/client_socket_pool_base.cc |
+++ b/net/socket/client_socket_pool_base.cc |
@@ -902,37 +902,36 @@ void ClientSocketPoolBaseHelper::ReleaseSocket( |
} |
void ClientSocketPoolBaseHelper::CheckForStalledSocketGroups() { |
- // If we have idle sockets, see if we can give one to the top-stalled group. |
- std::string top_group_name; |
- Group* top_group = NULL; |
- if (!FindTopStalledGroup(&top_group, &top_group_name)) { |
- // There may still be a stalled group in a lower level pool. |
- for (std::set<LowerLayeredPool*>::iterator it = lower_pools_.begin(); |
- it != lower_pools_.end(); |
- ++it) { |
- if ((*it)->IsStalled()) { |
- CloseOneIdleSocket(); |
- break; |
- } |
+ // Loop until there's nothing more to do. |
+ while (true) { |
+ // If we have idle sockets, see if we can give one to the top-stalled group. |
+ std::string top_group_name; |
+ Group* top_group = NULL; |
+ if (!FindTopStalledGroup(&top_group, &top_group_name)) { |
+ // There may still be a stalled group in a lower level pool. |
+ for (std::set<LowerLayeredPool*>::iterator it = lower_pools_.begin(); |
+ it != lower_pools_.end(); ++it) { |
+ if ((*it)->IsStalled()) { |
+ CloseOneIdleSocket(); |
+ break; |
davidben
2017/05/18 20:22:51
What's causing the socket pools to react to the fr
mmenke
2017/05/18 20:44:57
Destroying the socket will do that.
So suppose th
davidben
2017/05/18 20:52:31
I guess the vague analogy to our sync-return || ER
mmenke
2017/05/18 21:00:43
Ideally, we really should only have at most one (n
|
+ } |
+ } |
+ return; |
} |
- return; |
- } |
- if (ReachedMaxSocketsLimit()) { |
- if (idle_socket_count() > 0) { |
- CloseOneIdleSocket(); |
- } else { |
- // We can't activate more sockets since we're already at our global |
- // limit. |
- return; |
+ if (ReachedMaxSocketsLimit()) { |
+ if (idle_socket_count() > 0) { |
+ CloseOneIdleSocket(); |
+ } else { |
+ // We can't activate more sockets since we're already at our global |
+ // limit. |
+ return; |
+ } |
} |
- } |
- // Note: we don't loop on waking stalled groups. If the stalled group is at |
- // its limit, may be left with other stalled groups that could be |
- // woken. This isn't optimal, but there is no starvation, so to avoid |
- // the looping we leave it at this. |
davidben
2017/05/18 20:22:51
Previously we tried to avoid infinite looping here
mmenke
2017/05/18 20:44:57
Correct. I can't see how we'd get into an infinit
|
- OnAvailableSocketSlot(top_group_name, top_group); |
+ // Note that this may delete top_group. |
+ OnAvailableSocketSlot(top_group_name, top_group); |
+ } |
} |
// Search for the highest priority pending request, amongst the groups that |