good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
jrpc
Manage
Activity
Members
Labels
Plan
Issues
6
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
jrpc
Commits
5347bf6b
Commit
5347bf6b
authored
1 year ago
by
Garet Halliday
Browse files
Options
Downloads
Patches
Plain Diff
don't hang in idreply if conn closes
parent
548b2022
No related branches found
Branches containing commit
Tags
v0.2.23
Tags containing commit
1 merge request
!37
return error to all clients waiting on idreply when connection closes
Pipeline
#33423
canceled with stage
Stage: test
in 4 minutes and 39 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/codecs/rdwr/client.go
+4
-2
4 additions, 2 deletions
contrib/codecs/rdwr/client.go
pkg/clientutil/idreply.go
+16
-1
16 additions, 1 deletion
pkg/clientutil/idreply.go
pkg/jrpctest/suites.go
+12
-0
12 additions, 0 deletions
pkg/jrpctest/suites.go
with
32 additions
and
3 deletions
contrib/codecs/rdwr/client.go
+
4
−
2
View file @
5347bf6b
...
...
@@ -66,7 +66,9 @@ func (c *Client) Mount(h jsonrpc.Middleware) {
func
(
c
*
Client
)
listen
()
error
{
var
msg
json
.
RawMessage
defer
c
.
cn
()
defer
func
()
{
_
=
c
.
Close
()
}()
dec
:=
json
.
NewDecoder
(
bufio
.
NewReader
(
c
.
rd
))
for
{
err
:=
dec
.
Decode
(
&
msg
)
...
...
@@ -157,7 +159,7 @@ func (c *Client) SetHeader(key string, value string) {
func
(
c
*
Client
)
Close
()
error
{
c
.
cn
()
return
nil
return
c
.
p
.
Close
()
}
func
(
c
*
Client
)
writeContext
(
ctx
context
.
Context
,
xs
[]
byte
)
error
{
...
...
This diff is collapsed.
Click to expand it.
pkg/clientutil/idreply.go
+
16
−
1
View file @
5347bf6b
...
...
@@ -3,6 +3,7 @@ package clientutil
import
(
"context"
"io"
"net"
"sync"
"sync/atomic"
...
...
@@ -12,6 +13,8 @@ import (
type
IdReply
struct
{
id
atomic
.
Int64
closed
chan
struct
{}
chs
map
[
string
]
chan
msgOrError
mu
sync
.
Mutex
}
...
...
@@ -23,7 +26,8 @@ type msgOrError struct {
func
NewIdReply
()
*
IdReply
{
return
&
IdReply
{
chs
:
make
(
map
[
string
]
chan
msgOrError
,
1
),
closed
:
make
(
chan
struct
{}),
chs
:
make
(
map
[
string
]
chan
msgOrError
,
1
),
}
}
...
...
@@ -94,5 +98,16 @@ func (i *IdReply) Ask(ctx context.Context, id []byte) (io.ReadCloser, error) {
case
<-
ctx
.
Done
()
:
i
.
remove
(
id
)
return
nil
,
ctx
.
Err
()
case
<-
i
.
closed
:
return
nil
,
net
.
ErrClosed
}
}
func
(
i
*
IdReply
)
Closed
()
<-
chan
struct
{}
{
return
i
.
closed
}
func
(
i
*
IdReply
)
Close
()
error
{
close
(
i
.
closed
)
return
nil
}
This diff is collapsed.
Click to expand it.
pkg/jrpctest/suites.go
+
12
−
0
View file @
5347bf6b
...
...
@@ -3,7 +3,9 @@ package jrpctest
import
(
"context"
"embed"
"errors"
"math/rand"
"net"
"reflect"
"sync"
"testing"
...
...
@@ -188,6 +190,16 @@ func RunBasicTestSuite(t *testing.T, args BasicTestSuiteArgs) {
wg
.
Wait
()
})
makeTest
(
"close"
,
func
(
t
*
testing
.
T
,
server
*
server
.
Server
,
client
jsonrpc
.
Conn
)
{
go
func
()
{
_
=
client
.
Close
()
}()
err
:=
jsonrpc
.
CallInto
(
context
.
Background
(),
client
,
nil
,
"test_block"
)
if
!
errors
.
Is
(
err
,
net
.
ErrClosed
)
{
t
.
Errorf
(
"expected close error but got %v"
,
err
)
}
})
makeTest
(
""
,
func
(
t
*
testing
.
T
,
server
*
server
.
Server
,
client
jsonrpc
.
Conn
)
{
})
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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