File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,9 @@ func zCompress(src []byte, dst io.Writer) error {
64
64
if _ , err := zw .Write (src ); err != nil {
65
65
return err
66
66
}
67
- zw .Close ()
67
+ err := zw .Close ()
68
68
zwPool .Put (zw )
69
- return nil
69
+ return err
70
70
}
71
71
72
72
type compIO struct {
@@ -168,10 +168,13 @@ func (c *compIO) writePackets(packets []byte) (int, error) {
168
168
buf .Write (payload )
169
169
uncompressedLen = 0
170
170
} else {
171
- zCompress (payload , buf )
171
+ err := zCompress (payload , buf )
172
+ if debug && err != nil {
173
+ fmt .Printf ("zCompress error: %v" , err )
174
+ }
172
175
// do not compress if compressed data is larger than uncompressed data
173
- // I intentionally miss 7 byte header in the buf; compress more than 7 bytes.
174
- if buf .Len () >= uncompressedLen {
176
+ // I intentionally miss 7 byte header in the buf; zCompress must compress more than 7 bytes.
177
+ if err != nil || buf .Len () >= uncompressedLen {
175
178
buf .Reset ()
176
179
buf .Write (blankHeader )
177
180
buf .Write (payload )
You can’t perform that action at this time.
0 commit comments