Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
企猫商务
frp
提交
228e225f
F
frp
项目概览
企猫商务
/
frp
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
frp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
228e225f
编写于
5月 12, 2020
作者:
T
Tank
提交者:
GitHub
5月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: sync/atomic bug, fix #1804 (#1805)
Co-authored-by:
N
tanghuafa
<
tanghuafa@bytedance.com
>
上级
bd6435c9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
17 deletion
+18
-17
models/metrics/mem/server.go
models/metrics/mem/server.go
+5
-5
tests/util/util.go
tests/util/util.go
+1
-0
utils/metric/counter.go
utils/metric/counter.go
+12
-12
未找到文件。
models/metrics/mem/server.go
浏览文件 @
228e225f
...
@@ -177,12 +177,12 @@ func (m *serverMetrics) GetServer() *ServerStats {
...
@@ -177,12 +177,12 @@ func (m *serverMetrics) GetServer() *ServerStats {
s
:=
&
ServerStats
{
s
:=
&
ServerStats
{
TotalTrafficIn
:
m
.
info
.
TotalTrafficIn
.
TodayCount
(),
TotalTrafficIn
:
m
.
info
.
TotalTrafficIn
.
TodayCount
(),
TotalTrafficOut
:
m
.
info
.
TotalTrafficOut
.
TodayCount
(),
TotalTrafficOut
:
m
.
info
.
TotalTrafficOut
.
TodayCount
(),
CurConns
:
m
.
info
.
CurConns
.
Count
(
),
CurConns
:
int64
(
m
.
info
.
CurConns
.
Count
()
),
ClientCounts
:
m
.
info
.
ClientCounts
.
Count
(
),
ClientCounts
:
int64
(
m
.
info
.
ClientCounts
.
Count
()
),
ProxyTypeCounts
:
make
(
map
[
string
]
int64
),
ProxyTypeCounts
:
make
(
map
[
string
]
int64
),
}
}
for
k
,
v
:=
range
m
.
info
.
ProxyTypeCounts
{
for
k
,
v
:=
range
m
.
info
.
ProxyTypeCounts
{
s
.
ProxyTypeCounts
[
k
]
=
v
.
Count
(
)
s
.
ProxyTypeCounts
[
k
]
=
int64
(
v
.
Count
()
)
}
}
return
s
return
s
}
}
...
@@ -202,7 +202,7 @@ func (m *serverMetrics) GetProxiesByType(proxyType string) []*ProxyStats {
...
@@ -202,7 +202,7 @@ func (m *serverMetrics) GetProxiesByType(proxyType string) []*ProxyStats {
Type
:
proxyStats
.
ProxyType
,
Type
:
proxyStats
.
ProxyType
,
TodayTrafficIn
:
proxyStats
.
TrafficIn
.
TodayCount
(),
TodayTrafficIn
:
proxyStats
.
TrafficIn
.
TodayCount
(),
TodayTrafficOut
:
proxyStats
.
TrafficOut
.
TodayCount
(),
TodayTrafficOut
:
proxyStats
.
TrafficOut
.
TodayCount
(),
CurConns
:
proxyStats
.
CurConns
.
Count
(
),
CurConns
:
int64
(
proxyStats
.
CurConns
.
Count
()
),
}
}
if
!
proxyStats
.
LastStartTime
.
IsZero
()
{
if
!
proxyStats
.
LastStartTime
.
IsZero
()
{
ps
.
LastStartTime
=
proxyStats
.
LastStartTime
.
Format
(
"01-02 15:04:05"
)
ps
.
LastStartTime
=
proxyStats
.
LastStartTime
.
Format
(
"01-02 15:04:05"
)
...
@@ -233,7 +233,7 @@ func (m *serverMetrics) GetProxiesByTypeAndName(proxyType string, proxyName stri
...
@@ -233,7 +233,7 @@ func (m *serverMetrics) GetProxiesByTypeAndName(proxyType string, proxyName stri
Type
:
proxyStats
.
ProxyType
,
Type
:
proxyStats
.
ProxyType
,
TodayTrafficIn
:
proxyStats
.
TrafficIn
.
TodayCount
(),
TodayTrafficIn
:
proxyStats
.
TrafficIn
.
TodayCount
(),
TodayTrafficOut
:
proxyStats
.
TrafficOut
.
TodayCount
(),
TodayTrafficOut
:
proxyStats
.
TrafficOut
.
TodayCount
(),
CurConns
:
proxyStats
.
CurConns
.
Count
(
),
CurConns
:
int64
(
proxyStats
.
CurConns
.
Count
()
),
}
}
if
!
proxyStats
.
LastStartTime
.
IsZero
()
{
if
!
proxyStats
.
LastStartTime
.
IsZero
()
{
res
.
LastStartTime
=
proxyStats
.
LastStartTime
.
Format
(
"01-02 15:04:05"
)
res
.
LastStartTime
=
proxyStats
.
LastStartTime
.
Format
(
"01-02 15:04:05"
)
...
...
tests/util/util.go
浏览文件 @
228e225f
...
@@ -143,6 +143,7 @@ func SendUdpMsg(addr string, msg string) (res string, err error) {
...
@@ -143,6 +143,7 @@ func SendUdpMsg(addr string, msg string) (res string, err error) {
return
return
}
}
conn
.
SetReadDeadline
(
time
.
Now
()
.
Add
(
10
*
time
.
Second
))
buf
:=
make
([]
byte
,
2048
)
buf
:=
make
([]
byte
,
2048
)
n
,
errRet
:=
conn
.
Read
(
buf
)
n
,
errRet
:=
conn
.
Read
(
buf
)
if
errRet
!=
nil
{
if
errRet
!=
nil
{
...
...
utils/metric/counter.go
浏览文件 @
228e225f
...
@@ -19,9 +19,9 @@ import (
...
@@ -19,9 +19,9 @@ import (
)
)
type
Counter
interface
{
type
Counter
interface
{
Count
()
int
64
Count
()
int
32
Inc
(
int
64
)
Inc
(
int
32
)
Dec
(
int
64
)
Dec
(
int
32
)
Snapshot
()
Counter
Snapshot
()
Counter
Clear
()
Clear
()
}
}
...
@@ -33,28 +33,28 @@ func NewCounter() Counter {
...
@@ -33,28 +33,28 @@ func NewCounter() Counter {
}
}
type
StandardCounter
struct
{
type
StandardCounter
struct
{
count
int
64
count
int
32
}
}
func
(
c
*
StandardCounter
)
Count
()
int
64
{
func
(
c
*
StandardCounter
)
Count
()
int
32
{
return
atomic
.
LoadInt
64
(
&
c
.
count
)
return
atomic
.
LoadInt
32
(
&
c
.
count
)
}
}
func
(
c
*
StandardCounter
)
Inc
(
count
int
64
)
{
func
(
c
*
StandardCounter
)
Inc
(
count
int
32
)
{
atomic
.
AddInt
64
(
&
c
.
count
,
count
)
atomic
.
AddInt
32
(
&
c
.
count
,
count
)
}
}
func
(
c
*
StandardCounter
)
Dec
(
count
int
64
)
{
func
(
c
*
StandardCounter
)
Dec
(
count
int
32
)
{
atomic
.
AddInt
64
(
&
c
.
count
,
-
count
)
atomic
.
AddInt
32
(
&
c
.
count
,
-
count
)
}
}
func
(
c
*
StandardCounter
)
Snapshot
()
Counter
{
func
(
c
*
StandardCounter
)
Snapshot
()
Counter
{
tmp
:=
&
StandardCounter
{
tmp
:=
&
StandardCounter
{
count
:
atomic
.
LoadInt
64
(
&
c
.
count
),
count
:
atomic
.
LoadInt
32
(
&
c
.
count
),
}
}
return
tmp
return
tmp
}
}
func
(
c
*
StandardCounter
)
Clear
()
{
func
(
c
*
StandardCounter
)
Clear
()
{
atomic
.
StoreInt
64
(
&
c
.
count
,
0
)
atomic
.
StoreInt
32
(
&
c
.
count
,
0
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录