Skip to content

Commit

Permalink
All SslConduit delegate source resumeRead invocations run on IO threads
Browse files Browse the repository at this point in the history
  • Loading branch information
carterkozak committed Jul 12, 2018
1 parent 542e5c3 commit c32831f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions core/src/main/java/io/undertow/protocols/ssl/SslConduit.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,18 @@ public void run() {
}
};

private final Runnable resumeReadsCommand = new Runnable() {
@Override
public void run() {
delegate.getSourceChannel().resumeReads();
}
};

private final Runnable runReadListenerAndResumeCommand = new Runnable() {
@Override
public void run() {
if (allAreSet(state, FLAG_READS_RESUMED)) {
delegate.getSourceChannel().resumeReads();
resumeReadsCommand.run();
}
runReadListenerCommand.run();
}
Expand Down Expand Up @@ -241,20 +248,18 @@ private void resumeReads(boolean wakeup) {
if(anyAreSet(state, FLAG_DATA_TO_UNWRAP) || wakeup || unwrappedData != null) {
runReadListener(true);
} else {
if (Thread.currentThread() == delegate.getIoThread()) {
delegate.getSourceChannel().resumeReads();
} else {
delegate.getIoThread().execute(new Runnable() {
@Override
public void run() {
delegate.getSourceChannel().resumeReads();
}
});
}
delegateSourceResumeReads();
}
}
}

private void delegateSourceResumeReads() {
if (Thread.currentThread() == delegate.getIoThread()) {
resumeReadsCommand.run();
} else {
delegate.getIoThread().execute(resumeReadsCommand);
}
}

private void runReadListener(final boolean resumeInListener) {
try {
Expand Down Expand Up @@ -415,7 +420,7 @@ public boolean isWriteShutdown() {
public void resumeWrites() {
state |= FLAG_WRITES_RESUMED;
if(anyAreSet(state, FLAG_WRITE_REQUIRES_READ)) {
delegate.getSourceChannel().resumeReads();
delegateSourceResumeReads();
} else {
delegate.getSinkChannel().resumeWrites();
}
Expand Down

0 comments on commit c32831f

Please sign in to comment.