From cdcd60c8ea6c7388e5b61aeecf23bb15ae70911b Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Wed, 9 Sep 2015 18:11:22 -0700 Subject: [PATCH] Short-term fix for parallel writes --- chunks/http_store.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chunks/http_store.go b/chunks/http_store.go index 89ee9fdb8f..d6310c4363 100644 --- a/chunks/http_store.go +++ b/chunks/http_store.go @@ -41,6 +41,7 @@ type httpStoreClient struct { cb *chunkBuffer wg *sync.WaitGroup writeLimit chan int + wmu *sync.Mutex } type httpStoreServer struct { @@ -61,6 +62,7 @@ func NewHttpStoreClient(host string) *httpStoreClient { newChunkBuffer(), &sync.WaitGroup{}, make(chan int, writeLimit), + &sync.Mutex{}, } for i := 0; i < readLimit; i++ { @@ -125,6 +127,9 @@ func (c *httpStoreClient) Put() ChunkWriter { } func (c *httpStoreClient) write(r ref.Ref, buff *bytes.Buffer) { + c.wmu.Lock() + defer c.wmu.Unlock() + c.cb.appendChunk(buff) if c.cb.isFull() { c.flushBuffered()