Skip to content

Commit

Permalink
only release connection when channel got released to avoid double con…
Browse files Browse the repository at this point in the history
…nection release race condition

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed May 19, 2021
1 parent 92f6eab commit 0b97b84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public void send(HttpExchange exchange)
public void release()
{
setStream(null);
connection.release(this);
getHttpDestination().release(getHttpConnection());
if (connection.release(this))
getHttpDestination().release(getHttpConnection());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected HttpChannelOverHTTP2 newHttpChannel()
return new HttpChannelOverHTTP2(getHttpDestination(), this, getSession());
}

protected void release(HttpChannelOverHTTP2 channel)
protected boolean release(HttpChannelOverHTTP2 channel)
{
if (LOG.isDebugEnabled())
LOG.debug("Released {}", channel);
Expand All @@ -162,10 +162,12 @@ protected void release(HttpChannelOverHTTP2 channel)
channel.destroy();
else if (isRecycleHttpChannels())
idleChannels.offer(channel);
return true;
}
else
{
channel.destroy();
return false;
}
}

Expand Down
8 changes: 7 additions & 1 deletion jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ public void close()
// iterate the copy and close its entries
for (Entry entry : copy)
{
if (entry.tryRemove() && entry.pooled instanceof Closeable)
boolean removed = entry.tryRemove();
if (!removed)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("Pooled object still in use: {}", entry);
}
if (removed && entry.pooled instanceof Closeable)
IO.close((Closeable)entry.pooled);
}
}
Expand Down

0 comments on commit 0b97b84

Please sign in to comment.