mirror of https://github.com/cbeuw/Cloak
Prevent terminal msg from being overwritten to later concurrent writes
This commit is contained in:
parent
32494b8d86
commit
91106f3c49
|
|
@ -73,7 +73,8 @@ type Session struct {
|
||||||
|
|
||||||
closed uint32
|
closed uint32
|
||||||
|
|
||||||
terminalMsg atomic.Value
|
terminalMsgSetter sync.Once
|
||||||
|
terminalMsg string
|
||||||
|
|
||||||
// the max size passed to Write calls before it splits it into multiple frames
|
// the max size passed to Write calls before it splits it into multiple frames
|
||||||
// i.e. the max size a piece of data can fit into a Frame.Payload
|
// i.e. the max size a piece of data can fit into a Frame.Payload
|
||||||
|
|
@ -263,16 +264,13 @@ func (sesh *Session) recvDataFromRemote(data []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sesh *Session) SetTerminalMsg(msg string) {
|
func (sesh *Session) SetTerminalMsg(msg string) {
|
||||||
sesh.terminalMsg.Store(msg)
|
sesh.terminalMsgSetter.Do(func() {
|
||||||
|
sesh.terminalMsg = msg
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sesh *Session) TerminalMsg() string {
|
func (sesh *Session) TerminalMsg() string {
|
||||||
msg := sesh.terminalMsg.Load()
|
return sesh.terminalMsg
|
||||||
if msg != nil {
|
|
||||||
return msg.(string)
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sesh *Session) closeSession() error {
|
func (sesh *Session) closeSession() error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue