Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
4b3836b3
Commit
4b3836b3
authored
Oct 16, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: double unlock
parent
82715a2e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
21 deletions
+19
-21
client.go
rpc/client.go
+19
-20
pool.go
rpc/pool.go
+0
-1
No files found.
rpc/client.go
View file @
4b3836b3
...
...
@@ -29,7 +29,7 @@ type CallOptions struct {
RequestTimeout
time
.
Duration
// response timeout
ResponseTimeout
time
.
Duration
Meta
map
[
interface
{}]
interface
{}
Meta
map
[
interface
{}]
interface
{}
}
type
CallOption
func
(
*
CallOptions
)
...
...
@@ -82,49 +82,48 @@ func NewClient(conf *ClientConfig) (*Client, error) {
func
(
c
*
Client
)
Notify
(
typ
CodecType
,
addr
,
service
,
method
string
,
args
interface
{},
opts
...
CallOption
)
error
{
var
copts
CallOptions
for
_
,
o
:=
range
opts
{
o
(
&
copts
)
}
return
jerrors
.
Trace
(
c
.
call
(
CT_OneWay
,
typ
,
addr
,
service
,
method
,
args
,
nil
,
nil
,
copts
))
}
// if @reply is nil, the transport layer will get the response without notify the invoker.
func
(
c
*
Client
)
Call
(
typ
CodecType
,
addr
,
service
,
method
string
,
args
,
reply
interface
{},
opts
...
CallOption
)
error
{
var
copts
CallOptions
var
copts
CallOptions
for
_
,
o
:=
range
opts
{
o
(
&
copts
)
}
ct
:=
CT_TwoWay
if
reply
==
nil
{
ct
=
CT_TwoWayNoReply
}
return
jerrors
.
Trace
(
c
.
call
(
ct
,
typ
,
addr
,
service
,
method
,
args
,
reply
,
nil
,
copts
))
}
func
(
c
*
Client
)
AsyncCall
(
typ
CodecType
,
addr
,
service
,
method
string
,
args
,
reply
interface
{},
handler
AsyncHandler
,
opts
...
CallOption
)
error
{
func
(
c
*
Client
)
AsyncCall
(
typ
CodecType
,
addr
,
service
,
method
string
,
args
,
reply
interface
{},
handler
AsyncHandler
,
opts
...
CallOption
)
error
{
var
copts
CallOptions
for
_
,
o
:=
range
opts
{
o
(
&
copts
)
}
return
jerrors
.
Trace
(
c
.
call
(
CT_TwoWay
,
typ
,
addr
,
service
,
method
,
args
,
reply
,
handler
,
copts
))
}
func
(
c
*
Client
)
call
(
ct
CallType
,
typ
CodecType
,
addr
,
service
,
method
string
,
args
,
reply
interface
{},
handler
AsyncHandler
,
opts
CallOptions
)
error
{
if
opts
.
RequestTimeout
==
0
{
if
opts
.
RequestTimeout
==
0
{
opts
.
RequestTimeout
=
c
.
conf
.
GettySessionParam
.
tcpWriteTimeout
}
if
opts
.
ResponseTimeout
==
0
{
opts
.
ResponseTimeout
=
c
.
conf
.
GettySessionParam
.
tcpReadTimeout
opts
.
ResponseTimeout
=
c
.
conf
.
GettySessionParam
.
tcpReadTimeout
}
if
!
typ
.
CheckValidity
()
{
return
errInvalidCodecType
...
...
@@ -135,7 +134,7 @@ func (c *Client) call(ct CallType, typ CodecType, addr, service, method string,
b
.
header
.
Method
=
method
b
.
header
.
CallType
=
ct
b
.
body
=
args
var
rsp
*
PendingResponse
if
ct
!=
CT_OneWay
{
rsp
=
NewPendingResponse
()
...
...
@@ -158,9 +157,9 @@ func (c *Client) call(ct CallType, typ CodecType, addr, service, method string,
if
err
=
c
.
transfer
(
session
,
typ
,
b
,
rsp
,
opts
);
err
!=
nil
{
return
jerrors
.
Trace
(
err
)
}
if
ct
==
CT_OneWay
||
handler
!=
nil
{
return
nil
return
nil
}
select
{
...
...
@@ -193,9 +192,9 @@ func (c *Client) heartbeat(session getty.Session, typ CodecType) error {
return
c
.
transfer
(
session
,
typ
,
nil
,
NewPendingResponse
(),
CallOptions
{})
}
func
(
c
*
Client
)
transfer
(
session
getty
.
Session
,
typ
CodecType
,
req
*
GettyRPCRequest
,
func
(
c
*
Client
)
transfer
(
session
getty
.
Session
,
typ
CodecType
,
req
*
GettyRPCRequest
,
rsp
*
PendingResponse
,
opts
CallOptions
)
error
{
var
(
sequence
uint64
err
error
...
...
@@ -212,7 +211,7 @@ func (c *Client) transfer(session getty.Session, typ CodecType,req *GettyRPCRequ
pkg
.
H
.
Command
=
gettyCmdRPCRequest
pkg
.
B
=
req
}
if
rsp
!=
nil
{
rsp
.
seq
=
sequence
c
.
addPendingResponse
(
rsp
)
...
...
rpc/pool.go
View file @
4b3836b3
...
...
@@ -309,7 +309,6 @@ func (p *gettyRPCClientPool) release(conn *gettyRPCClient, err error) {
connArray
:=
p
.
connMap
[
key
]
if
len
(
connArray
)
>=
p
.
size
{
p
.
Unlock
()
conn
.
close
()
return
}
...
...
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