mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-07 18:41:30 +01:00
Use buffered channel for inmemlayer's pendingConns to fix timeout errors (#21098)
Error in question is: `transport: Error while dialing: inmemlayer: timeout while accepting connection`
This commit is contained in:
parent
e13ccf9835
commit
fd20c99c4a
@ -107,7 +107,7 @@ func (l *InmemLayer) Listeners() []NetworkListener {
|
||||
|
||||
l.listener = &inmemListener{
|
||||
addr: l.addr,
|
||||
pendingConns: make(chan net.Conn),
|
||||
pendingConns: make(chan net.Conn, 1),
|
||||
|
||||
stopped: atomic.NewBool(false),
|
||||
stopCh: make(chan struct{}),
|
||||
|
||||
@ -27,6 +27,7 @@ func TestInmemCluster_Connect(t *testing.T) {
|
||||
listener := server.Listeners()[0]
|
||||
var accepted int
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
@ -69,7 +70,6 @@ func TestInmemCluster_Connect(t *testing.T) {
|
||||
t.Fatal("nil conn")
|
||||
}
|
||||
|
||||
close(stopCh)
|
||||
wg.Wait()
|
||||
|
||||
if accepted != 2 {
|
||||
@ -93,6 +93,7 @@ func TestInmemCluster_Disconnect(t *testing.T) {
|
||||
listener := server.Listeners()[0]
|
||||
var accepted int
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
@ -136,7 +137,6 @@ func TestInmemCluster_Disconnect(t *testing.T) {
|
||||
t.Fatal("nil conn")
|
||||
}
|
||||
|
||||
close(stopCh)
|
||||
wg.Wait()
|
||||
|
||||
if accepted != 1 {
|
||||
@ -199,6 +199,8 @@ func TestInmemCluster_ConnectCluster(t *testing.T) {
|
||||
|
||||
var accepted atomic.Int32
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
acceptConns := func(listener NetworkListener) {
|
||||
wg.Add(1)
|
||||
@ -255,7 +257,6 @@ func TestInmemCluster_ConnectCluster(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
close(stopCh)
|
||||
wg.Wait()
|
||||
|
||||
if accepted.Load() != 18 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user