Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f46f4151
authored
May 15, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix lock is not working
parent
4f1f170f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
controller/channel.go
+11
-5
No files found.
controller/channel.go
View file @
f46f4151
...
...
@@ -261,13 +261,16 @@ func TestChannel(c *gin.Context) {
}
var
testAllChannelsLock
sync
.
Mutex
var
testAllChannelsRunning
bool
=
false
func
testAllChannels
(
c
*
gin
.
Context
)
error
{
ok
:=
testAllChannelsLock
.
TryLock
()
if
!
ok
{
return
errors
.
New
(
"测试已在运行"
)
testAllChannelsLock
.
Lock
()
if
testAllChannelsRunning
{
testAllChannelsLock
.
Unlock
()
return
errors
.
New
(
"测试已在运行中"
)
}
defer
testAllChannelsLock
.
Unlock
()
testAllChannelsRunning
=
true
testAllChannelsLock
.
Unlock
()
channels
,
err
:=
model
.
GetAllChannels
(
0
,
0
,
true
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
...
...
@@ -303,10 +306,13 @@ func testAllChannels(c *gin.Context) error {
}
channel
.
UpdateResponseTime
(
milliseconds
)
}
err
:=
common
.
SendEmail
(
"通道测试完成"
,
email
,
"通道测试完成"
)
err
:=
common
.
SendEmail
(
"通道测试完成"
,
email
,
"通道测试完成
,如果没有收到禁用通知,说明所有通道都正常
"
)
if
err
!=
nil
{
common
.
SysError
(
fmt
.
Sprintf
(
"发送邮件失败:%s"
,
err
.
Error
()))
}
testAllChannelsLock
.
Lock
()
testAllChannelsRunning
=
false
testAllChannelsLock
.
Unlock
()
}()
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment