mirror of https://github.com/grpc/grpc-java.git
netty: always flush at least once, even if there were no writes
This commit is contained in:
parent
083ea8e6aa
commit
297af4425e
|
|
@ -121,6 +121,7 @@ class WriteQueue {
|
|||
try {
|
||||
QueuedCommand cmd;
|
||||
int i = 0;
|
||||
boolean flushedOnce = false;
|
||||
while ((cmd = queue.poll()) != null) {
|
||||
channel.write(cmd, cmd.promise());
|
||||
if (++i == DEQUE_CHUNK_SIZE) {
|
||||
|
|
@ -129,10 +130,11 @@ class WriteQueue {
|
|||
// might never end as new events are continuously added to the queue, if we never
|
||||
// flushed in that case we would be guaranteed to OOM.
|
||||
channel.flush();
|
||||
flushedOnce = true;
|
||||
}
|
||||
}
|
||||
// Must flush at least once
|
||||
if (i != 0) {
|
||||
// Must flush at least once, even if there were no writes.
|
||||
if (i != 0 || !flushedOnce) {
|
||||
channel.flush();
|
||||
}
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class WriteQueueTest {
|
|||
public ChannelPromise promise;
|
||||
|
||||
private long writeCalledNanos;
|
||||
private long flushCalledNanos = writeCalledNanos + 1;
|
||||
private long flushCalledNanos = writeCalledNanos;
|
||||
|
||||
/**
|
||||
* Set up for test.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
import io.grpc.CallOptions;
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.ClientCall;
|
||||
import io.grpc.ExperimentalApi;
|
||||
import io.grpc.Metadata;
|
||||
import io.grpc.MethodDescriptor;
|
||||
import io.grpc.Status;
|
||||
|
|
|
|||
Loading…
Reference in New Issue