Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
8d46ac0f
Unverified
Commit
8d46ac0f
authored
5 years ago
by
vito.he
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #286 from pantianying/develop_gettyPool_lock
change the position of the lock
parents
9604e7ac
e6e0e14f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
protocol/dubbo/pool.go
+12
-5
12 additions, 5 deletions
protocol/dubbo/pool.go
registry/protocol/protocol.go
+3
-3
3 additions, 3 deletions
registry/protocol/protocol.go
registry/protocol/protocol_test.go
+0
-5
0 additions, 5 deletions
registry/protocol/protocol_test.go
with
15 additions
and
13 deletions
protocol/dubbo/pool.go
+
12
−
5
View file @
8d46ac0f
...
...
@@ -289,7 +289,17 @@ func (p *gettyRPCClientPool) close() {
}
func
(
p
*
gettyRPCClientPool
)
getGettyRpcClient
(
protocol
,
addr
string
)
(
*
gettyRPCClient
,
error
)
{
var
(
conn
*
gettyRPCClient
err
error
)
if
conn
,
err
=
p
.
selectGettyRpcClient
(
protocol
,
addr
);
err
==
nil
&&
conn
==
nil
{
// create new conn
return
newGettyRPCClientConn
(
p
,
protocol
,
addr
)
}
return
conn
,
err
}
func
(
p
*
gettyRPCClientPool
)
selectGettyRpcClient
(
protocol
,
addr
string
)
(
*
gettyRPCClient
,
error
)
{
p
.
Lock
()
defer
p
.
Unlock
()
if
p
.
conns
==
nil
{
...
...
@@ -308,13 +318,10 @@ func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPC
continue
}
conn
.
updateActive
(
now
)
//update active time
return
conn
,
nil
}
// create new conn
return
newGettyRPCClientConn
(
p
,
protocol
,
addr
)
return
nil
,
nil
}
func
(
p
*
gettyRPCClientPool
)
release
(
conn
*
gettyRPCClient
,
err
error
)
{
if
conn
==
nil
||
conn
.
getActive
()
==
0
{
return
...
...
This diff is collapsed.
Click to expand it.
registry/protocol/protocol.go
+
3
−
3
View file @
8d46ac0f
...
...
@@ -338,10 +338,10 @@ func setProviderUrl(regURL *common.URL, providerURL *common.URL) {
}
func
GetProtocol
()
protocol
.
Protocol
{
if
regProtocol
=
=
nil
{
re
gProtocol
=
newRegistry
Protocol
()
if
regProtocol
!
=
nil
{
re
turn
reg
Protocol
}
return
reg
Protocol
return
newRegistry
Protocol
()
}
type
wrappedInvoker
struct
{
...
...
This diff is collapsed.
Click to expand it.
registry/protocol/protocol_test.go
+
0
−
5
View file @
8d46ac0f
...
...
@@ -291,8 +291,3 @@ func TestExportWithApplicationConfig(t *testing.T) {
v2
,
_
:=
regProtocol
.
bounds
.
Load
(
getCacheKey
(
newUrl
))
assert
.
NotNil
(
t
,
v2
)
}
func
TestGetProtocol
(
t
*
testing
.
T
)
{
singleton
:=
GetProtocol
()
assert
.
True
(
t
,
singleton
==
GetProtocol
())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment