ssh: soft code internal channel size for testing purposes
Change-Id: I2ee0ed4ba82d2d156a7896551dea04b28cdeceb0 Reviewed-on: https://go-review.googlesource.com/35184 Run-TryBot: Han-Wen Nienhuys <hanwen@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
+2
-2
@@ -461,8 +461,8 @@ func (m *mux) newChannel(chanType string, direction channelDirection, extraData
|
|||||||
pending: newBuffer(),
|
pending: newBuffer(),
|
||||||
extPending: newBuffer(),
|
extPending: newBuffer(),
|
||||||
direction: direction,
|
direction: direction,
|
||||||
incomingRequests: make(chan *Request, 16),
|
incomingRequests: make(chan *Request, chanSize),
|
||||||
msg: make(chan interface{}, 16),
|
msg: make(chan interface{}, chanSize),
|
||||||
chanType: chanType,
|
chanType: chanType,
|
||||||
extraData: extraData,
|
extraData: extraData,
|
||||||
mux: m,
|
mux: m,
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ func (c *Client) HandleChannelOpen(channelType string) <-chan NewChannel {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = make(chan NewChannel, 16)
|
ch = make(chan NewChannel, chanSize)
|
||||||
c.channelHandlers[channelType] = ch
|
c.channelHandlers[channelType] = ch
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -19,6 +19,11 @@ import (
|
|||||||
// messages are wrong when using ECDH.
|
// messages are wrong when using ECDH.
|
||||||
const debugHandshake = false
|
const debugHandshake = false
|
||||||
|
|
||||||
|
// chanSize sets the amount of buffering SSH connections. This is
|
||||||
|
// primarily for testing: setting chanSize=0 uncovers deadlocks more
|
||||||
|
// quickly.
|
||||||
|
const chanSize = 16
|
||||||
|
|
||||||
// keyingTransport is a packet based transport that supports key
|
// keyingTransport is a packet based transport that supports key
|
||||||
// changes. It need not be thread-safe. It should pass through
|
// changes. It need not be thread-safe. It should pass through
|
||||||
// msgNewKeys in both directions.
|
// msgNewKeys in both directions.
|
||||||
@@ -90,7 +95,7 @@ func newHandshakeTransport(conn keyingTransport, config *Config, clientVersion,
|
|||||||
conn: conn,
|
conn: conn,
|
||||||
serverVersion: serverVersion,
|
serverVersion: serverVersion,
|
||||||
clientVersion: clientVersion,
|
clientVersion: clientVersion,
|
||||||
incoming: make(chan []byte, 16),
|
incoming: make(chan []byte, chanSize),
|
||||||
requestKex: make(chan struct{}, 1),
|
requestKex: make(chan struct{}, 1),
|
||||||
startKex: make(chan *pendingKex, 1),
|
startKex: make(chan *pendingKex, 1),
|
||||||
|
|
||||||
|
|||||||
+28
-16
@@ -249,9 +249,25 @@ func TestHandshakeAutoRekeyWrite(t *testing.T) {
|
|||||||
defer trC.Close()
|
defer trC.Close()
|
||||||
defer trS.Close()
|
defer trS.Close()
|
||||||
|
|
||||||
|
done := make(chan int, 1)
|
||||||
|
const numPacket = 5
|
||||||
|
go func() {
|
||||||
|
defer close(done)
|
||||||
|
j := 0
|
||||||
|
for ; j < numPacket; j++ {
|
||||||
|
if _, err := trS.readPacket(); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if j != numPacket {
|
||||||
|
t.Errorf("got %d, want 5 messages", j)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
<-checker.called
|
<-checker.called
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < numPacket; i++ {
|
||||||
packet := make([]byte, 251)
|
packet := make([]byte, 251)
|
||||||
packet[0] = msgRequestSuccess
|
packet[0] = msgRequestSuccess
|
||||||
if err := trC.writePacket(packet); err != nil {
|
if err := trC.writePacket(packet); err != nil {
|
||||||
@@ -263,18 +279,7 @@ func TestHandshakeAutoRekeyWrite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
<-done
|
||||||
j := 0
|
|
||||||
for ; j < 5; j++ {
|
|
||||||
_, err := trS.readPacket()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if j != 5 {
|
|
||||||
t.Errorf("got %d, want 5 messages", j)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type syncChecker struct {
|
type syncChecker struct {
|
||||||
@@ -305,12 +310,19 @@ func TestHandshakeAutoRekeyRead(t *testing.T) {
|
|||||||
if err := trS.writePacket(packet); err != nil {
|
if err := trS.writePacket(packet); err != nil {
|
||||||
t.Fatalf("writePacket: %v", err)
|
t.Fatalf("writePacket: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// While we read out the packet, a key change will be
|
// While we read out the packet, a key change will be
|
||||||
// initiated.
|
// initiated.
|
||||||
if _, err := trC.readPacket(); err != nil {
|
done := make(chan int, 1)
|
||||||
t.Fatalf("readPacket(client): %v", err)
|
go func() {
|
||||||
}
|
defer close(done)
|
||||||
|
if _, err := trC.readPacket(); err != nil {
|
||||||
|
t.Fatalf("readPacket(client): %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-done
|
||||||
<-sync.called
|
<-sync.called
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -116,9 +116,9 @@ func (m *mux) Wait() error {
|
|||||||
func newMux(p packetConn) *mux {
|
func newMux(p packetConn) *mux {
|
||||||
m := &mux{
|
m := &mux{
|
||||||
conn: p,
|
conn: p,
|
||||||
incomingChannels: make(chan NewChannel, 16),
|
incomingChannels: make(chan NewChannel, chanSize),
|
||||||
globalResponses: make(chan interface{}, 1),
|
globalResponses: make(chan interface{}, 1),
|
||||||
incomingRequests: make(chan *Request, 16),
|
incomingRequests: make(chan *Request, chanSize),
|
||||||
errCond: newCond(),
|
errCond: newCond(),
|
||||||
}
|
}
|
||||||
if debugMux {
|
if debugMux {
|
||||||
|
|||||||
Reference in New Issue
Block a user