Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:deal the panic when invoker destroy #358

Merged
merged 7 commits into from
Feb 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions protocol/dubbo/dubbo_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (

// DubboInvoker ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment for this file, pls.

type DubboInvoker struct {
sync.RWMutex
pantianying marked this conversation as resolved.
Show resolved Hide resolved
protocol.BaseInvoker
client *Client
quitOnce sync.Once
Expand All @@ -62,6 +63,8 @@ func NewDubboInvoker(url common.URL, client *Client) *DubboInvoker {

// Invoke ...
func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
di.RLock()
pantianying marked this conversation as resolved.
Show resolved Hide resolved
defer di.RUnlock()
var (
err error
result protocol.RPCResult
Expand Down Expand Up @@ -109,11 +112,15 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati

// Destroy ...
func (di *DubboInvoker) Destroy() {
di.Lock()
pantianying marked this conversation as resolved.
Show resolved Hide resolved
defer di.Unlock()

di.quitOnce.Do(func() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someone check this pls: Can this be async

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reqNum is used for judging if dubbo invoker is available ? Why not use isAvailable() func instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to check whether there are any stock requests in the invoker during destroy

di.BaseInvoker.Destroy()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In extreme cases, infinite circulation possible? Should we control the upper limit?

Copy link
Member Author

@pantianying pantianying Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In extreme cases,there is always a request in the invoker that has not ended. If it is forcibly destroyed, it may cause a program panic. The severity of this result is greater than adding a loop.

if di.client != nil {
di.client.Close()
di.client = nil
}
})
}
Expand Down