Skip to content

Commit

Permalink
Add yet more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Apr 27, 2023
1 parent e89c872 commit 97823a7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ private void executeClose(
*/

try {
if (LOG.isTraceEnabled()) {
LOG.trace("close op executing");
}

this.operationQueue.forEach(op -> {
if (!Objects.equals(close.future, op.future())) {
op.future().cancel(true);
Expand All @@ -161,9 +165,13 @@ private void executeClose(
try {
this.delegate.close();
} catch (final Exception e) {
LOG.debug("close: ", e);
LOG.debug("close op: ", e);
}
} finally {
if (LOG.isTraceEnabled()) {
LOG.trace("close op shutting down executor");
}

this.commandExecutor.shutdown();

try {
Expand All @@ -173,6 +181,10 @@ private void executeClose(
}

close.future.complete(null);

if (LOG.isTraceEnabled()) {
LOG.trace("close op completed");
}
}
}

Expand Down Expand Up @@ -295,12 +307,24 @@ public final CompletableFuture<Void> disconnectAsync()
@Override
public final void close()
{
if (LOG.isTraceEnabled()) {
LOG.trace("close requested");
}

if (this.closed.compareAndSet(false, true)) {
if (LOG.isTraceEnabled()) {
LOG.trace("close scheduled");
}

final var future =
CompletableFuture.completedFuture(null);
this.operationQueue.add(new OpType.Close<>(future));

try {
future.get();
if (LOG.isTraceEnabled()) {
LOG.trace("close future completed");
}
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
} catch (final ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ public final void disconnect()
@Override
public final void close()
{
if (LOG.isTraceEnabled()) {
LOG.trace("close requested");
}

synchronized (this.stateLock) {
final var state = this.stateNow;
if (state == CLIENT_CLOSING || state == CLIENT_CLOSED) {
Expand All @@ -297,7 +301,7 @@ public final void close()

try {
if (LOG.isTraceEnabled()) {
LOG.trace("close");
LOG.trace("close starting");
}

this.statePublisher.submit(CLIENT_CLOSED);
Expand Down

0 comments on commit 97823a7

Please sign in to comment.