remove unused StreamCallback

This commit is contained in:
Marten Seemann 2017-02-17 16:01:30 +07:00
parent 5029ab0934
commit 824f122a79
No known key found for this signature in database
GPG key ID: 3603F40B121FCDEA
7 changed files with 13 additions and 43 deletions

View file

@ -20,7 +20,6 @@ import (
"github.com/lucas-clemente/quic-go/crypto"
"github.com/lucas-clemente/quic-go/handshake"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/utils"
)
type linkedConnection struct {
@ -98,14 +97,14 @@ var _ = Describe("Benchmarks", func() {
connID := protocol.ConnectionID(mrand.Uint32())
c1 := newLinkedConnection(nil)
session1I, err := newSession(c1, version, connID, nil, func(Session, utils.Stream) {}, func(id protocol.ConnectionID) {})
session1I, err := newSession(c1, version, connID, nil, func(id protocol.ConnectionID) {})
if err != nil {
Expect(err).NotTo(HaveOccurred())
}
session1 := session1I.(*session)
c2 := newLinkedConnection(session1)
session2I, err := newSession(c2, version, connID, nil, func(Session, utils.Stream) {}, func(id protocol.ConnectionID) {})
session2I, err := newSession(c2, version, connID, nil, func(id protocol.ConnectionID) {})
if err != nil {
Expect(err).NotTo(HaveOccurred())
}

View file

@ -208,7 +208,7 @@ func (c *Client) handlePacket(packet []byte) error {
func (c *Client) createNewSession(negotiatedVersions []protocol.VersionNumber) error {
var err error
c.session, err = newClientSession(c.conn, c.addr, c.hostname, c.version, c.connectionID, c.tlsConfig, c.streamCallback, c.closeCallback, c.cryptoChangeCallback, negotiatedVersions)
c.session, err = newClientSession(c.conn, c.addr, c.hostname, c.version, c.connectionID, c.tlsConfig, c.closeCallback, c.cryptoChangeCallback, negotiatedVersions)
if err != nil {
return err
}
@ -217,8 +217,6 @@ func (c *Client) createNewSession(negotiatedVersions []protocol.VersionNumber) e
return nil
}
func (c *Client) streamCallback(Session, utils.Stream) {}
func (c *Client) closeCallback(id protocol.ConnectionID) {
utils.Infof("Connection %x closed.", id)
}

View file

@ -65,10 +65,6 @@ func NewClient(t *QuicRoundTripper, tlsConfig *tls.Config, hostname string) (*Cl
return c, nil
}
func (c *Client) handleStreamCb(session *quic.Session, stream utils.Stream) {
utils.Debugf("Handling stream %d", stream.StreamID())
}
func (c *Client) cryptoChangeCallback(isForwardSecure bool) {
c.cryptoChangedCond.L.Lock()
defer c.cryptoChangedCond.L.Unlock()

View file

@ -36,9 +36,7 @@ type server struct {
sessionsMutex sync.RWMutex
deleteClosedSessionsAfter time.Duration
streamCallback StreamCallback
newSession func(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error)
newSession func(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, closeCallback closeCallback) (packetHandler, error)
}
var _ Listener = &server{}
@ -60,7 +58,6 @@ func NewListener(config *Config) (Listener, error) {
config: config,
certChain: certChain,
scfg: scfg,
streamCallback: func(Session, utils.Stream) {},
sessions: map[protocol.ConnectionID]packetHandler{},
newSession: newSession,
deleteClosedSessionsAfter: protocol.ClosedSessionDeleteTimeout,
@ -195,7 +192,6 @@ func (s *server) handlePacket(pconn net.PacketConn, remoteAddr net.Addr, packet
version,
hdr.ConnectionID,
s.scfg,
s.streamCallback,
s.closeCallback,
)
if err != nil {

View file

@ -44,7 +44,7 @@ func (s *mockSession) RemoteAddr() net.Addr {
var _ Session = &mockSession{}
func newMockSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error) {
func newMockSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, closeCallback closeCallback) (packetHandler, error) {
return &mockSession{
connectionID: connectionID,
}, nil

View file

@ -35,9 +35,6 @@ var (
errSessionAlreadyClosed = errors.New("Cannot close session. It was already closed before.")
)
// StreamCallback gets a stream frame and returns a reply frame
type StreamCallback func(Session, utils.Stream)
// CryptoChangeCallback is called every time the encryption level changes
// Once the callback has been called with isForwardSecure = true, it is guarantueed to not be called with isForwardSecure = false after that
type CryptoChangeCallback func(isForwardSecure bool)
@ -51,7 +48,6 @@ type session struct {
perspective protocol.Perspective
version protocol.VersionNumber
streamCallback StreamCallback
closeCallback closeCallback
cryptoChangeCallback CryptoChangeCallback
@ -103,14 +99,13 @@ type session struct {
var _ Session = &session{}
// newSession makes a new session
func newSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error) {
func newSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, closeCallback closeCallback) (packetHandler, error) {
s := &session{
conn: conn,
connectionID: connectionID,
perspective: protocol.PerspectiveServer,
version: v,
streamCallback: streamCallback,
closeCallback: closeCallback,
cryptoChangeCallback: func(bool) {},
connectionParameters: handshake.NewConnectionParamatersManager(protocol.PerspectiveServer, v),
@ -137,14 +132,13 @@ func newSession(conn connection, v protocol.VersionNumber, connectionID protocol
return s, err
}
func newClientSession(pconn net.PacketConn, addr net.Addr, hostname string, v protocol.VersionNumber, connectionID protocol.ConnectionID, tlsConfig *tls.Config, streamCallback StreamCallback, closeCallback closeCallback, cryptoChangeCallback CryptoChangeCallback, negotiatedVersions []protocol.VersionNumber) (*session, error) {
func newClientSession(pconn net.PacketConn, addr net.Addr, hostname string, v protocol.VersionNumber, connectionID protocol.ConnectionID, tlsConfig *tls.Config, closeCallback closeCallback, cryptoChangeCallback CryptoChangeCallback, negotiatedVersions []protocol.VersionNumber) (*session, error) {
s := &session{
conn: &conn{pconn: pconn, currentAddr: addr},
connectionID: connectionID,
perspective: protocol.PerspectiveClient,
version: v,
streamCallback: streamCallback,
closeCallback: closeCallback,
cryptoChangeCallback: cryptoChangeCallback,
connectionParameters: handshake.NewConnectionParamatersManager(protocol.PerspectiveClient, v),
@ -708,8 +702,6 @@ func (s *session) newStream(id protocol.StreamID) (*stream, error) {
s.flowControlManager.NewStream(id, true)
}
s.streamCallback(s, stream)
return stream, nil
}

View file

@ -114,18 +114,16 @@ var _ ackhandler.ReceivedPacketHandler = &mockReceivedPacketHandler{}
var _ = Describe("Session", func() {
var (
sess *session
clientSess *session
streamCallbackCalled bool
closeCallbackCalled bool
scfg *handshake.ServerConfig
mconn *mockConnection
cpm *mockConnectionParametersManager
sess *session
clientSess *session
closeCallbackCalled bool
scfg *handshake.ServerConfig
mconn *mockConnection
cpm *mockConnectionParametersManager
)
BeforeEach(func() {
mconn = &mockConnection{}
streamCallbackCalled = false
closeCallbackCalled = false
certChain := crypto.NewCertChain(testdata.GetTLSConfig())
@ -138,7 +136,6 @@ var _ = Describe("Session", func() {
protocol.Version35,
0,
scfg,
func(Session, utils.Stream) { streamCallbackCalled = true },
func(protocol.ConnectionID) { closeCallbackCalled = true },
)
Expect(err).NotTo(HaveOccurred())
@ -155,7 +152,6 @@ var _ = Describe("Session", func() {
protocol.Version35,
0,
nil,
func(Session, utils.Stream) { streamCallbackCalled = true },
func(protocol.ConnectionID) { closeCallbackCalled = true },
func(isForwardSecure bool) {},
nil,
@ -172,7 +168,6 @@ var _ = Describe("Session", func() {
protocol.VersionWhatever,
0,
scfg,
func(Session, utils.Stream) { streamCallbackCalled = true },
func(protocol.ConnectionID) { closeCallbackCalled = true },
)
Expect(err).ToNot(HaveOccurred())
@ -188,7 +183,6 @@ var _ = Describe("Session", func() {
protocol.VersionWhatever,
0,
scfg,
func(Session, utils.Stream) { streamCallbackCalled = true },
func(protocol.ConnectionID) { closeCallbackCalled = true },
)
Expect(err).ToNot(HaveOccurred())
@ -202,7 +196,6 @@ var _ = Describe("Session", func() {
StreamID: 5,
Data: []byte{0xde, 0xca, 0xfb, 0xad},
})
Expect(streamCallbackCalled).To(BeTrue())
p := make([]byte, 4)
str, err := sess.streamsMap.GetOrOpenStream(5)
Expect(err).ToNot(HaveOccurred())
@ -228,7 +221,6 @@ var _ = Describe("Session", func() {
Data: []byte{0xde, 0xca},
})
numOpenStreams := len(sess.streamsMap.openStreams)
Expect(streamCallbackCalled).To(BeTrue())
sess.handleStreamFrame(&frames.StreamFrame{
StreamID: 5,
Offset: 2,
@ -262,7 +254,6 @@ var _ = Describe("Session", func() {
numOpenStreams := len(sess.streamsMap.openStreams)
str, _ := sess.streamsMap.GetOrOpenStream(5)
Expect(str).ToNot(BeNil())
Expect(streamCallbackCalled).To(BeTrue())
p := make([]byte, 4)
_, err := str.Read(p)
Expect(err).To(MatchError(io.EOF))
@ -282,7 +273,6 @@ var _ = Describe("Session", func() {
numOpenStreams := len(sess.streamsMap.openStreams)
str, _ := sess.streamsMap.GetOrOpenStream(5)
Expect(str).ToNot(BeNil())
Expect(streamCallbackCalled).To(BeTrue())
p := make([]byte, 4)
_, err := str.Read(p)
Expect(err).To(MatchError(io.EOF))
@ -315,7 +305,6 @@ var _ = Describe("Session", func() {
str, err := sess.streamsMap.GetOrOpenStream(5)
Expect(err).ToNot(HaveOccurred())
Expect(str).ToNot(BeNil())
Expect(streamCallbackCalled).To(BeTrue())
p := make([]byte, 4)
_, err = str.Read(p)
Expect(err).ToNot(HaveOccurred())