Skip to content

Race condition on 401 introduced in #420 #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
slandelle opened this issue Jan 24, 2014 · 3 comments
Closed

Race condition on 401 introduced in #420 #463

slandelle opened this issue Jan 24, 2014 · 3 comments
Assignees
Milestone

Comments

@slandelle
Copy link
Contributor

PR #420 introduced a race condition on channel usage.

The author of this PR claimed that a new socket was open on 401, but this is not the case:

So the client doesn't necessarily open a new socket. It only does so if some other request got the connection from the pool before the next request is indeed performed: https://github.com/AsyncHttpClient/async-http-client/blob/ahc-1.7.x/src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java#L1355

This change cause a race condition, where nextRequest tries to reuse the previous channel while it has been offered to the pool and is eventually used by someone else.

@slandelle
Copy link
Contributor Author

Master not impacted

@slandelle
Copy link
Contributor Author

Actually, @taer was right about a new Socket being created in the sense that nextRequest is performed immediately, before the original channel is drained and offered to the pull.

@jfarcand WDYT? Does it make sense to change the callback in this case so that it doesn't offer to the pool once drain is done, but perform the next request?

@slandelle
Copy link
Contributor Author

Actually, we're not opening more sockets that we should as long as connection pooling is allowed, which should generally be the case. Let's leave it like this for now.

cs-workco pushed a commit to cs-workco/async-http-client that referenced this issue Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant