Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: common/isolatedclient/isolatedclient.go

Issue 2884413002: Ensure (de)compressor is always closed. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | common/isolatedclient/isolatedfake/isolatedfake.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package isolatedclient 5 package isolatedclient
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/base64" 9 "encoding/base64"
10 "errors" 10 "errors"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 pr, pw := io.Pipe() 342 pr, pw := io.Pipe()
343 go func() { 343 go func() {
344 // The compressor itself is not thread safe. 344 // The compressor itself is not thread safe.
345 compressor, err := isolated.GetCompressor(pw) 345 compressor, err := isolated.GetCompressor(pw)
346 if err != nil { 346 if err != nil {
347 pw.CloseWithError(err) 347 pw.CloseWithError(err)
348 return 348 return
349 } 349 }
350 buf := make([]byte, 4096) 350 buf := make([]byte, 4096)
351 if _, err := io.CopyBuffer(compressor, src, buf); err != nil { 351 if _, err := io.CopyBuffer(compressor, src, buf); err != nil {
352 compressor.Close()
352 pw.CloseWithError(err) 353 pw.CloseWithError(err)
353 return 354 return
354 } 355 }
355 pw.CloseWithError(compressor.Close()) 356 pw.CloseWithError(compressor.Close())
356 }() 357 }()
357 358
358 return &compressed{pr, src} 359 return &compressed{pr, src}
359 } 360 }
OLDNEW
« no previous file with comments | « no previous file | common/isolatedclient/isolatedfake/isolatedfake.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698