Wrap the metadata with a mutex to guarantee thread safety across core/router/sessions

This commit is contained in:
Neil Alexander 2018-12-12 22:40:49 +00:00
parent 97464feba9
commit 042a3400fe
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 40 additions and 14 deletions

View file

@ -355,7 +355,7 @@ func (p *sessionPing) decode(bs []byte) bool {
////////////////////////////////////////////////////////////////////////////////
// Encodes a sessionPing into its wire format.
// Encodes a sessionMeta into its wire format.
func (p *sessionMeta) encode() []byte {
var pTypeVal uint64
if p.IsResponse {
@ -370,7 +370,7 @@ func (p *sessionMeta) encode() []byte {
return bs
}
// Decodes an encoded sessionPing into the struct, returning true if successful.
// Decodes an encoded sessionMeta into the struct, returning true if successful.
func (p *sessionMeta) decode(bs []byte) bool {
var pType uint64
switch {
@ -380,6 +380,9 @@ func (p *sessionMeta) decode(bs []byte) bool {
return false
}
if p.IsResponse = pType == wire_SessionMetaResponse; p.IsResponse {
if len(bs) == 0 {
return false
}
p.Metadata = make(metadata, len(bs))
if !wire_chop_slice(p.Metadata[:], &bs) {
return false