-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
From 12883ad006dacaabcc4bc5a321e6b69bdfe08db4 Mon Sep 17 00:00:00 2001 | ||
From: Irine Sistiana <[email protected]> | ||
Date: Mon, 18 Sep 2023 19:56:19 +0800 | ||
Subject: [PATCH] upgrade bytesPool, fixed #714 | ||
|
||
--- | ||
go.mod | 2 +- | ||
go.sum | 4 ++++ | ||
pkg/pool/allocator.go | 6 +++--- | ||
3 files changed, 8 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/go.mod b/go.mod | ||
index 2c359e3..f5cb30a 100644 | ||
--- a/go.mod | ||
+++ b/go.mod | ||
@@ -5,7 +5,7 @@ go 1.21 | ||
toolchain go1.21.1 | ||
|
||
require ( | ||
- github.com/IrineSistiana/go-bytes-pool v0.0.0-20230419012903-2f1f26674686 | ||
+ github.com/IrineSistiana/go-bytes-pool v0.0.0-20230918115058-c72bd9761c57 | ||
github.com/go-chi/chi/v5 v5.0.10 | ||
github.com/google/nftables v0.1.0 | ||
github.com/kardianos/service v1.2.2 | ||
diff --git a/go.sum b/go.sum | ||
index d4bbaa2..63c84d0 100644 | ||
--- a/go.sum | ||
+++ b/go.sum | ||
@@ -40,6 +40,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 | ||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= | ||
github.com/IrineSistiana/go-bytes-pool v0.0.0-20230419012903-2f1f26674686 h1:5R32cCep3VUDTKf3aurFKfgbvg+RScuBmZsw/DyyXco= | ||
github.com/IrineSistiana/go-bytes-pool v0.0.0-20230419012903-2f1f26674686/go.mod h1:pQ/FSsWSNYmNdgIKmulKlmVC/R2PEpq2vIEi3J9IijI= | ||
+github.com/IrineSistiana/go-bytes-pool v0.0.0-20230918113338-1af74a078e78 h1:Fem1OuBzs4A4kt/MPn09OjZKgphevSoBapSJR/40AzQ= | ||
+github.com/IrineSistiana/go-bytes-pool v0.0.0-20230918113338-1af74a078e78/go.mod h1:pQ/FSsWSNYmNdgIKmulKlmVC/R2PEpq2vIEi3J9IijI= | ||
+github.com/IrineSistiana/go-bytes-pool v0.0.0-20230918115058-c72bd9761c57 h1:nfurUSSmVY9sY/mYyoReOA1w2cR2fp2eicL9ojicZhQ= | ||
+github.com/IrineSistiana/go-bytes-pool v0.0.0-20230918115058-c72bd9761c57/go.mod h1:pQ/FSsWSNYmNdgIKmulKlmVC/R2PEpq2vIEi3J9IijI= | ||
github.com/IrineSistiana/ipset v0.5.1-0.20220703061533-6e0fc3b04c0a h1:GQdh/h0q0ni3L//CXusyk+7QdhBL289vdNaes1WKkHI= | ||
github.com/IrineSistiana/ipset v0.5.1-0.20220703061533-6e0fc3b04c0a/go.mod h1:rYF5DQLRGGoQ8ZSWeK+6eX5amAuPqwFkWjhQlEITGJQ= | ||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= | ||
diff --git a/pkg/pool/allocator.go b/pkg/pool/allocator.go | ||
index d8ac4ef..eb011ea 100644 | ||
--- a/pkg/pool/allocator.go | ||
+++ b/pkg/pool/allocator.go | ||
@@ -23,8 +23,8 @@ import ( | ||
bytesPool "github.com/IrineSistiana/go-bytes-pool" | ||
) | ||
|
||
-// defaultBufPool is an Allocator that has a maximum capacity. | ||
var ( | ||
- GetBuf = bytesPool.Get | ||
- ReleaseBuf = bytesPool.Release | ||
+ _pool = bytesPool.NewPool(10) // 1Mbyte pool, should be enough. | ||
+ GetBuf = _pool.Get | ||
+ ReleaseBuf = _pool.Release | ||
) | ||
-- | ||
2.34.8 | ||
|