You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/11/09 03:38:19 UTC
[GitHub] [cassandra] maedhroz commented on a change in pull request #1304: Cassandra 17033
maedhroz commented on a change in pull request #1304:
URL: https://github.com/apache/cassandra/pull/1304#discussion_r745264624
##########
File path: src/java/org/apache/cassandra/net/InboundSockets.java
##########
@@ -99,15 +99,28 @@ private InboundSocket(InboundConnectionSettings settings)
throw new IllegalStateException();
binding = InboundConnectionInitiator.bind(settings, connections, pipelineInjector);
}
-
- return binding.addListener(ignore -> {
+ // isOpen is defined as "listen.isOpen", but this is set AFTER the binding future is set
+ // to make sure the future returned does not complete until listen is set, need a new
+ // future to replicate "Future.map" behavior.
+ AsyncChannelPromise promise = new AsyncChannelPromise(binding.channel());
+ binding.addListener(f -> {
+ if (!f.isSuccess())
+ {
+ synchronized (this)
+ {
+ binding = null;
+ }
+ promise.setFailure(f.cause());
+ return;
+ }
synchronized (this)
{
- if (binding.isSuccess())
- listen = binding.channel();
+ listen = binding.channel();
binding = null;
}
+ promise.setSuccess(null);
});
+ return promise;
Review comment:
So to summarize my understanding, waiting for `binding`, the previously returned `Future` was insufficient, because the body of the listener is not guaranteed to run before it presents itself as complete. So (taking care to protect the shared mutable state of `binding` and `listen`), we create a separate `promise` whose completion guarantees that the state we need to change has already been changed. If so, +1 :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org