Make clear that tcp-send methods are not handlers and may be called outside of queryLoop
This commit is contained in:
1 parent
657125fd54
commit
139758256b
1 file changed
+12
-12
+12
-12
@@ -185,7 +185,7 @@ func (conn *LocalConnection) log(args ...interface{}) {
|
|||||||
// note that tcpSender is immutable and guaranteed to be set by the
|
// note that tcpSender is immutable and guaranteed to be set by the
|
||||||
// time anybody can get hold of a ref to the Connection
|
// time anybody can get hold of a ref to the Connection
|
||||||
func (conn *LocalConnection) SendProtocolMsg(m ProtocolMsg) {
|
func (conn *LocalConnection) SendProtocolMsg(m ProtocolMsg) {
|
||||||
if err := conn.handleSendProtocolMsg(m); err != nil {
|
if err := conn.sendProtocolMsg(m); err != nil {
|
||||||
conn.Shutdown(err)
|
conn.Shutdown(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ func (conn *LocalConnection) queryLoop(queryChan <-chan *ConnectionInteraction)
|
|||||||
conn.Forward(true, conn.heartbeatFrame, nil)
|
conn.Forward(true, conn.heartbeatFrame, nil)
|
||||||
case <-tickerChan(conn.fragTest):
|
case <-tickerChan(conn.fragTest):
|
||||||
conn.setStackFrag(false)
|
conn.setStackFrag(false)
|
||||||
err = conn.handleSendSimpleProtocolMsg(ProtocolStartFragmentationTest)
|
err = conn.sendSimpleProtocolMsg(ProtocolStartFragmentationTest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -339,7 +339,7 @@ func (conn *LocalConnection) handleReceivedHeartbeat(remoteUDPAddr *net.UDPAddr)
|
|||||||
conn.Unlock()
|
conn.Unlock()
|
||||||
conn.heartbeatTimeout.Reset(HeartbeatTimeout)
|
conn.heartbeatTimeout.Reset(HeartbeatTimeout)
|
||||||
if !old {
|
if !old {
|
||||||
if err := conn.handleSendSimpleProtocolMsg(ProtocolConnectionEstablished); err != nil {
|
if err := conn.sendSimpleProtocolMsg(ProtocolConnectionEstablished); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,20 +376,12 @@ func (conn *LocalConnection) handleSetEstablished() error {
|
|||||||
// avoid initial waits for timers to fire
|
// avoid initial waits for timers to fire
|
||||||
conn.Forward(true, conn.heartbeatFrame, nil)
|
conn.Forward(true, conn.heartbeatFrame, nil)
|
||||||
conn.setStackFrag(false)
|
conn.setStackFrag(false)
|
||||||
if err := conn.handleSendSimpleProtocolMsg(ProtocolStartFragmentationTest); err != nil {
|
if err := conn.sendSimpleProtocolMsg(ProtocolStartFragmentationTest); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *LocalConnection) handleSendSimpleProtocolMsg(tag ProtocolTag) error {
|
|
||||||
return conn.handleSendProtocolMsg(ProtocolMsg{tag: tag})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conn *LocalConnection) handleSendProtocolMsg(m ProtocolMsg) error {
|
|
||||||
return conn.tcpSender.Send(Concat([]byte{byte(m.tag)}, m.msg))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (conn *LocalConnection) handleShutdown() {
|
func (conn *LocalConnection) handleShutdown() {
|
||||||
if conn.TCPConn != nil {
|
if conn.TCPConn != nil {
|
||||||
checkWarn(conn.TCPConn.Close())
|
checkWarn(conn.TCPConn.Close())
|
||||||
@@ -416,6 +408,14 @@ func (conn *LocalConnection) handleShutdown() {
|
|||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
||||||
|
func (conn *LocalConnection) sendSimpleProtocolMsg(tag ProtocolTag) error {
|
||||||
|
return conn.sendProtocolMsg(ProtocolMsg{tag: tag})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conn *LocalConnection) sendProtocolMsg(m ProtocolMsg) error {
|
||||||
|
return conn.tcpSender.Send(Concat([]byte{byte(m.tag)}, m.msg))
|
||||||
|
}
|
||||||
|
|
||||||
func (conn *LocalConnection) receiveTCP(decoder *gob.Decoder) {
|
func (conn *LocalConnection) receiveTCP(decoder *gob.Decoder) {
|
||||||
defer conn.Decryptor.Shutdown()
|
defer conn.Decryptor.Shutdown()
|
||||||
usingPassword := conn.SessionKey != nil
|
usingPassword := conn.SessionKey != nil
|
||||||
|
|||||||
Reference in new issue
Block a user