summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
154913e)
Deadlock happened when listener for window is resized
and write is invoked at the same time.
Change-Id: I8c662d6cd5edbc3e36b31a754d826f79bec76434
Signed-off-by: Martin Sunal <msunal@frinx.io>
Signed-off-by: Jaroslav Tóth <jtoth@frinx.io>
(cherry picked from commit
0f45153d60a0fc71a08d011e21fdf5e83c174290)
import org.apache.sshd.common.io.WritePendingException;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.common.io.WritePendingException;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.checkerframework.checker.lock.qual.GuardedBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.asyncIn = asyncIn;
}
this.asyncIn = asyncIn;
}
+ @GuardedBy("asyncInLock")
+ private boolean isWriteExecuted = false;
+
public void write(final ChannelHandlerContext ctx,
final Object msg, final ChannelPromise promise) {
if (asyncIn == null) {
public void write(final ChannelHandlerContext ctx,
final Object msg, final ChannelPromise promise) {
if (asyncIn == null) {
promise.setFailure(new IllegalStateException("Channel closed"));
} else {
final ByteBuf byteBufMsg = (ByteBuf) msg;
promise.setFailure(new IllegalStateException("Channel closed"));
} else {
final ByteBuf byteBufMsg = (ByteBuf) msg;
- if (!pending.isEmpty()) {
queueRequest(ctx, byteBufMsg, promise);
return;
}
queueRequest(ctx, byteBufMsg, promise);
return;
}
if (LOG.isTraceEnabled()) {
LOG.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg));
}
if (LOG.isTraceEnabled()) {
LOG.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg));
}
+
+ isWriteExecuted = true;
+
asyncIn.writePacket(toBuffer(byteBufMsg)).addListener(future -> {
// synchronized block due to deadlock that happens on ssh window resize
// writes and pending writes would lock the underlyinch channel session
asyncIn.writePacket(toBuffer(byteBufMsg)).addListener(future -> {
// synchronized block due to deadlock that happens on ssh window resize
// writes and pending writes would lock the underlyinch channel session
private void writePendingIfAny() {
synchronized (asyncInLock) {
if (pending.peek() == null) {
private void writePendingIfAny() {
synchronized (asyncInLock) {
if (pending.peek() == null) {
+ isWriteExecuted = false;