5f9090a7f0
To perform writes in AioSocketChannel, we get a ByteBuffer view of the outbound buffer and specify it as a parameter when we call AsynchronousSocketChannel.write(). In most cases, the write() operation is finished immediately. However, sometimes, it is scheduled for later execution. In such a case, there's a chance for a user's handler to append more data to the outbound buffer. When more data is appended to the outbound buffer, the outbound buffer can expand its capacity by itself. Changing the capacity of a buffer is basically made of the following steps: 1. Allocate a larger new internal memory region. 2. Copy the current content of the buffer to the new memory region. 3. Rewire the buffer so that it refers to the new region. 4. Deallocate the old memory region. Because the old memory region is deallocated at the step 4, the write operation scheduled later will access the deallocated region, leading all sort of data corruption or even segfaults. To prevent this situation, I added suspendIntermediaryDeallocations() and resumeIntermediaryDeallocations() to UnsafeByteBuf. AioSocketChannel.doFlushByteBuf() now calls suspendIntermediaryDealloc() to defer the deallocation of the old memory regions until the completion handler is notified. |
||
---|---|---|
all | ||
buffer | ||
codec | ||
codec-http | ||
codec-socks | ||
common | ||
example | ||
handler | ||
license | ||
metrics-yammer | ||
tarball | ||
testsuite | ||
transport | ||
.fbfilter.xml | ||
.fbprefs | ||
.gitignore | ||
LICENSE.txt | ||
NOTICE.txt | ||
pom.xml | ||
README.md |
The Netty Project
Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.
Links
-
Web Site: http://netty.io/
-
Docs: http://netty.io/docs/
-
Blog: http://netty.io/blog/
-
Twitter: @netty_project
Getting Netty
-
Download Page: http://netty.io/downloads/
-
Maven Repository:
<dependencies>
...
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>X.Y.Z.Q</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
Developer Information
-
Netty is setup to build using Maven
-
You need JDK 7 to build Netty. Netty will run with JDK 5 (3.x) and JDK 6 (4).
-
master branch contains code for Netty 4.x
-
3 branch contains code for Netty 3.x