fix #58
fix #80 Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@ goproxy
|
|||||||
*.exe
|
*.exe
|
||||||
*.exe~
|
*.exe~
|
||||||
.*
|
.*
|
||||||
|
*.prof
|
||||||
!.gitignore
|
!.gitignore
|
||||||
release-*
|
release-*
|
||||||
proxy.crt
|
proxy.crt
|
||||||
|
|||||||
@ -10,6 +10,9 @@ v4.8
|
|||||||
5.优化了sps日志输出.
|
5.优化了sps日志输出.
|
||||||
6.--debug参数增加了Profiling功能,可以保存cpu,内存等多种调试数据到文件.
|
6.--debug参数增加了Profiling功能,可以保存cpu,内存等多种调试数据到文件.
|
||||||
7.优化了服务注册,避免了不必要的内存开销.
|
7.优化了服务注册,避免了不必要的内存开销.
|
||||||
|
8.增加了Dockerfile和docker安装手册.
|
||||||
|
9.优化了ioCopy避免了内存泄漏,大大提升了内存占用的稳定性.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
v4.7
|
v4.7
|
||||||
|
|||||||
@ -76,7 +76,8 @@ func IoBind(dst io.ReadWriteCloser, src io.ReadWriteCloser, fn func(err interfac
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
func ioCopy(dst io.ReadWriter, src io.ReadWriter) (err error) {
|
func ioCopy(dst io.ReadWriter, src io.ReadWriter) (err error) {
|
||||||
buf := make([]byte, 32*1024)
|
buf := LeakyBuffer.Get()
|
||||||
|
defer LeakyBuffer.Put(buf)
|
||||||
n := 0
|
n := 0
|
||||||
for {
|
for {
|
||||||
n, err = src.Read(buf)
|
n, err = src.Read(buf)
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
// Provides leaky buffer, based on the example in Effective Go.
|
// Provides leaky buffer, based on the example in Effective Go.
|
||||||
package ss
|
package utils
|
||||||
|
|
||||||
type LeakyBuf struct {
|
type LeakyBuf struct {
|
||||||
bufSize int // size of each buffer
|
bufSize int // size of each buffer
|
||||||
freeList chan []byte
|
freeList chan []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
const leakyBufSize = 4108 // data.len(2) + hmacsha1(10) + data(4096)
|
const LeakyBufSize = 2048 // data.len(2) + hmacsha1(10) + data(4096)
|
||||||
const maxNBuf = 2048
|
const maxNBuf = 2048
|
||||||
|
|
||||||
var leakyBuf = NewLeakyBuf(maxNBuf, leakyBufSize)
|
var LeakyBuffer = NewLeakyBuf(maxNBuf, LeakyBufSize)
|
||||||
|
|
||||||
// NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each
|
// NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each
|
||||||
// with bufSize bytes.
|
// with bufSize bytes.
|
||||||
@ -10,8 +10,15 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/snail007/goproxy/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const leakyBufSize = 4108 // data.len(2) + hmacsha1(10) + data(4096)
|
||||||
|
const maxNBuf = 2048
|
||||||
|
|
||||||
|
var leakyBuf = utils.NewLeakyBuf(maxNBuf, leakyBufSize)
|
||||||
|
|
||||||
func IsFileExists(path string) (bool, error) {
|
func IsFileExists(path string) (bool, error) {
|
||||||
stat, err := os.Stat(path)
|
stat, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user