Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
af422610
Commit
af422610
authored
Oct 21, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1e5a24b7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
wcfs/wcfs.go
wcfs/wcfs.go
+22
-4
No files found.
wcfs/wcfs.go
View file @
af422610
...
...
@@ -1961,20 +1961,38 @@ func (wlink *WatchLink) sendReq(ctx context.Context, req string) (reply string,
stream
=
atomic
.
AddUint64
(
&
wlink
.
reqNext
,
+
2
)
}
rxq
:=
make
(
chan
string
,
1
)
// cap=1 not to block _serve if we return canceled
rxq
:=
make
(
chan
string
,
1
)
wlink
.
rxMu
.
Lock
()
wlink
.
rxTab
[
stream
]
=
rxq
// XXX assert .stream is not there?
_
,
already
:=
wlink
.
rxTab
[
stream
]
if
!
already
{
wlink
.
rxTab
[
stream
]
=
rxq
}
wlink
.
rxMu
.
Unlock
()
if
already
{
panic
(
"BUG: to-be-sent stream is present in rxtab"
)
}
defer
func
()
{
if
err
!=
nil
{
// remove rxq from rxTab
// ( _serve could have already deleted it if unexpected
// reply came to the stream, but no other rxq should
// have registered on the [stream] slot )
wlink
.
rxMu
.
Lock
()
delete
(
wlink
.
rxTab
,
stream
)
wlink
.
rxMu
.
Unlock
()
// no need to drain rxq - it was created with cap=1
}
}()
err
=
wlink
.
send
(
ctx
,
stream
,
req
)
if
err
!=
nil
{
// XXX del rxTab[stream]
return
""
,
err
}
select
{
case
<-
ctx
.
Done
()
:
// XXX del rxTab[stream] ?
return
""
,
ctx
.
Err
()
case
reply
=
<-
rxq
:
...
...
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