Skip to content

Commit 4bf26c3

Browse files
committed
NETTY-410 NioWorker write deadlock
Applied the patch provided by Greg Dhuse.
1 parent b9ef785 commit 4bf26c3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,21 @@ private void write0(final NioDatagramChannel channel) {
568568
}
569569
}
570570
channel.inWriteNowLoop = false;
571+
572+
// Initially, the following block was executed after releasing
573+
// the writeLock, but there was a race condition, and it has to be
574+
// executed before releasing the writeLock:
575+
//
576+
// https://issues.jboss.org/browse/NETTY-410
577+
//
578+
if (addOpWrite) {
579+
setOpWrite(channel);
580+
} else if (removeOpWrite) {
581+
clearOpWrite(channel);
582+
}
571583
}
572584

573585
fireWriteComplete(channel, writtenBytes);
574-
575-
if (addOpWrite) {
576-
setOpWrite(channel);
577-
} else if (removeOpWrite) {
578-
clearOpWrite(channel);
579-
}
580586
}
581587

582588
private void setOpWrite(final NioDatagramChannel channel) {

0 commit comments

Comments
 (0)