diff options
| author | Konstantin Lebedev <lebedev_k@tochka.com> | 2020-12-01 16:03:34 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <lebedev_k@tochka.com> | 2020-12-01 16:03:34 +0500 |
| commit | 03620776ece3175dac979b05c491d26d14faef0f (patch) | |
| tree | 4fce7d0a55c3fa7f5b7c43e9d90d5e194c439239 /weed/util | |
| parent | 4e55baf5b109cfe5cf9f65c44cd92c542b4acf5e (diff) | |
| parent | 005a6123e98170b2bdf99eb5b8a67ca3cea94190 (diff) | |
| download | seaweedfs-03620776ece3175dac979b05c491d26d14faef0f.tar.xz seaweedfs-03620776ece3175dac979b05c491d26d14faef0f.zip | |
Merge branch 'upstream_master' into store_s3cred
Diffstat (limited to 'weed/util')
| -rw-r--r-- | weed/util/compression.go | 36 | ||||
| -rw-r--r-- | weed/util/constants.go | 2 | ||||
| -rw-r--r-- | weed/util/http_util.go | 5 | ||||
| -rw-r--r-- | weed/util/retry.go | 4 |
4 files changed, 29 insertions, 18 deletions
diff --git a/weed/util/compression.go b/weed/util/compression.go index cf3ac7c57..9d52810cb 100644 --- a/weed/util/compression.go +++ b/weed/util/compression.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/klauspost/compress/zstd" + // "github.com/klauspost/compress/zstd" ) var ( @@ -55,19 +55,15 @@ func GzipData(input []byte) ([]byte, error) { return buf.Bytes(), nil } -var zstdEncoder, _ = zstd.NewWriter(nil) - -func ZstdData(input []byte) ([]byte, error) { - return zstdEncoder.EncodeAll(input, nil), nil -} - func DecompressData(input []byte) ([]byte, error) { if IsGzippedContent(input) { return ungzipData(input) } - if IsZstdContent(input) { - return unzstdData(input) - } + /* + if IsZstdContent(input) { + return unzstdData(input) + } + */ return input, UnsupportedCompression } @@ -82,12 +78,6 @@ func ungzipData(input []byte) ([]byte, error) { return output, err } -var decoder, _ = zstd.NewReader(nil) - -func unzstdData(input []byte) ([]byte, error) { - return decoder.DecodeAll(input, nil) -} - func IsGzippedContent(data []byte) bool { if len(data) < 2 { return false @@ -95,12 +85,26 @@ func IsGzippedContent(data []byte) bool { return data[0] == 31 && data[1] == 139 } +/* +var zstdEncoder, _ = zstd.NewWriter(nil) + +func ZstdData(input []byte) ([]byte, error) { + return zstdEncoder.EncodeAll(input, nil), nil +} + +var decoder, _ = zstd.NewReader(nil) + +func unzstdData(input []byte) ([]byte, error) { + return decoder.DecodeAll(input, nil) +} + func IsZstdContent(data []byte) bool { if len(data) < 4 { return false } return data[3] == 0xFD && data[2] == 0x2F && data[1] == 0xB5 && data[0] == 0x28 } +*/ /* * Default not to compressed since compression can be done on client side. diff --git a/weed/util/constants.go b/weed/util/constants.go index 0aeee111e..254f3cb59 100644 --- a/weed/util/constants.go +++ b/weed/util/constants.go @@ -5,7 +5,7 @@ import ( ) var ( - VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 11) + VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 13) COMMIT = "" ) diff --git a/weed/util/http_util.go b/weed/util/http_util.go index 7851d8293..2cd69b01b 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -374,3 +374,8 @@ func CloseResponse(resp *http.Response) { io.Copy(ioutil.Discard, resp.Body) resp.Body.Close() } + +func CloseRequest(req *http.Request) { + io.Copy(ioutil.Discard, req.Body) + req.Body.Close() +} diff --git a/weed/util/retry.go b/weed/util/retry.go index 85c4d150d..7b0f2d3c3 100644 --- a/weed/util/retry.go +++ b/weed/util/retry.go @@ -22,9 +22,11 @@ func Retry(name string, job func() error) (err error) { } if strings.Contains(err.Error(), "transport") { hasErr = true - glog.V(0).Infof("retry %s", name) + glog.V(0).Infof("retry %s: err: %v", name, err) time.Sleep(waitTime) waitTime += waitTime / 2 + } else { + break } } return err |
