Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class TimeoutsHolder {
private static final Logger LOGGER = LoggerFactory.getLogger(TimeoutsHolder.class);

private final AtomicBoolean cancelled = new AtomicBoolean();
private final AtomicBoolean started = new AtomicBoolean();
private final Timer nettyTimer;
private volatile @Nullable EventExecutor eventExecutor;
private final NettyRequestSender requestSender;
Expand Down Expand Up @@ -105,8 +106,14 @@ public TimeoutsHolder(Timer nettyTimer, @Nullable EventExecutor eventExecutor, N
* <p>
* Called by {@link org.asynchttpclient.netty.NettyResponseFuture#setTimeoutsHolder}, so that installing a
* holder is what arms it and neither can be done without the other.
* <p>
* Only the first call arms. A second would overwrite the first handle, leaving an entry nobody can
* cancel to sit in its scheduler until the full deadline, pinning the task, the future and the channel.
*/
public void start() {
if (!started.compareAndSet(false, true)) {
return;
}
if (requestTimeoutTask != null) {
// The configured duration rather than the remaining time: this runs within microseconds of the
// constructor, and reading the clock again would only expose the deadline to a step between the two.
Expand Down
Loading