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
382169c6
Unverified
Commit
382169c6
authored
5 years ago
by
fangyincheng
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #288 from xujianhai666/fix-map-attach
fix(core): add lock for attachment
parents
4ce2ea8b
944e6dc8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
protocol/invocation/rpcinvocation.go
+6
-0
6 additions, 0 deletions
protocol/invocation/rpcinvocation.go
with
6 additions
and
0 deletions
protocol/invocation/rpcinvocation.go
+
6
−
0
View file @
382169c6
...
...
@@ -19,6 +19,7 @@ package invocation
import
(
"reflect"
"sync"
)
import
(
...
...
@@ -37,6 +38,7 @@ type RPCInvocation struct {
callBack
interface
{}
attachments
map
[
string
]
string
invoker
protocol
.
Invoker
lock
sync
.
RWMutex
}
func
NewRPCInvocation
(
methodName
string
,
arguments
[]
interface
{},
attachments
map
[
string
]
string
)
*
RPCInvocation
{
...
...
@@ -80,6 +82,8 @@ func (r *RPCInvocation) Attachments() map[string]string {
}
func
(
r
*
RPCInvocation
)
AttachmentsByKey
(
key
string
,
defaultValue
string
)
string
{
r
.
lock
.
RLock
()
defer
r
.
lock
.
RUnlock
()
if
r
.
attachments
==
nil
{
return
defaultValue
}
...
...
@@ -91,6 +95,8 @@ func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string
}
func
(
r
*
RPCInvocation
)
SetAttachments
(
key
string
,
value
string
)
{
r
.
lock
.
Lock
()
defer
r
.
lock
.
Unlock
()
if
r
.
attachments
==
nil
{
r
.
attachments
=
make
(
map
[
string
]
string
)
}
...
...
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