Short-term fix for parallel writes

This commit is contained in:
Rafael Weinstein
2015-09-09 18:11:22 -07:00
parent 8e49286f0a
commit cdcd60c8ea

View File

@@ -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()