Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix memory leak of TransportRequestHandler.streamIds.
  • Loading branch information
viirya committed Apr 28, 2015
commit 3b3f38a0f3eee2301a85f67b10658724864bfb4e
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public OneForOneStreamManager() {
streams = new ConcurrentHashMap<Long, StreamState>();
}

@Override
public boolean streamHasNext(long streamId) {
return streams.containsKey(streamId);
}

@Override
public ManagedBuffer getChunk(long streamId, int chunkIndex) {
StreamState state = streams.get(streamId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public abstract class StreamManager {
*/
public abstract ManagedBuffer getChunk(long streamId, int chunkIndex);

/**
* Indicates that if the specified stream has next chunks to read further.
*/
public boolean streamHasNext(long streamId) { return true; }

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this method, it should no longer be used.

* Indicates that the TCP connection that was tied to the given stream has been terminated. After
* this occurs, we are guaranteed not to read from the stream again, so any state can be cleaned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ private void processFetchRequest(final ChunkFetchRequest req) {
ManagedBuffer buf;
try {
buf = streamManager.getChunk(req.streamChunkId.streamId, req.streamChunkId.chunkIndex);
if (!streamManager.streamHasNext(req.streamChunkId.streamId)) {
streamIds.remove(req.streamChunkId.streamId);
}
} catch (Exception e) {
logger.error(String.format(
"Error opening block %s for request from %s", req.streamChunkId, client), e);
Expand Down