ttrpc: increase maximum message length

This change increases the maximum message size to 4MB to be inline
with the grpc default. The buffer management approach has been changed
to use a pool to minimize allocations and keep memory usage low.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-11-29 13:30:41 -08:00
parent ed51a24609
commit 2a1ad5f6c7
5 changed files with 131 additions and 45 deletions

View File

@@ -167,12 +167,11 @@ func (c *Client) run() {
go func() {
// start one more goroutine to recv messages without blocking.
for {
var p [messageLengthMax]byte
// TODO(stevvooe): Something still isn't quite right with error
// handling on the client-side, causing EOFs to come through. We
// need other fixes in this changeset, so we'll address this
// correctly later.
mh, err := c.channel.recv(context.TODO(), p[:])
mh, p, err := c.channel.recv(context.TODO())
select {
case incoming <- received{
mh: mh,
@@ -204,6 +203,7 @@ func (c *Client) run() {
waiter.err <- r.err
} else {
waiter.err <- proto.Unmarshal(r.p, waiter.msg.(proto.Message))
c.channel.putmbuf(r.p)
}
} else {
queued[r.mh.StreamID] = r