-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix for issue 125 - lz4 data corruption when concurrency is used #127
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,10 @@ func (z *Writer) writeHeader() error { | |
|
||
// Write compresses data from the supplied buffer into the underlying io.Writer. | ||
// Write does not return until the data has been written. | ||
func (z *Writer) Write(buf []byte) (int, error) { | ||
func (z *Writer) Write(buffer []byte) (int, error) { | ||
buf := make([]byte, len(buffer)) | ||
copy(buf, buffer) | ||
|
||
if !z.Header.done { | ||
if err := z.writeHeader(); err != nil { | ||
return 0, err | ||
|
@@ -223,7 +226,10 @@ func (z *Writer) Write(buf []byte) (int, error) { | |
} | ||
|
||
// compressBlock compresses a block. | ||
func (z *Writer) compressBlock(data []byte) error { | ||
func (z *Writer) compressBlock(dataBlock []byte) error { | ||
data := make([]byte, len(dataBlock)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move it up before this is called and use the getBuffer function call,. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I missed this comment, it seems we might be able to use those pools that are already defined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated it, I am new to the code and didn't know there were already pools defined for each block size :) |
||
copy(data, dataBlock) | ||
|
||
if !z.NoChecksum { | ||
_, _ = z.checksum.Write(data) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying here is not required.