forked from jshiffer/go-xmpp
Further reduce possible data races.
This commit is contained in:
parent
ce687243c1
commit
0ae62a33a2
7
xmpp.go
7
xmpp.go
@ -1563,6 +1563,11 @@ func (c *Client) nextEnd() (xml.EndElement, error) {
|
|||||||
t := xml.CopyToken(to)
|
t := xml.CopyToken(to)
|
||||||
switch t := t.(type) {
|
switch t := t.(type) {
|
||||||
case xml.EndElement:
|
case xml.EndElement:
|
||||||
|
// Do not unlock mutex if the stream is closed to
|
||||||
|
// prevent further reading on the stream.
|
||||||
|
if t.Name.Local == "stream" {
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
c.nextMutex.Unlock()
|
c.nextMutex.Unlock()
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
@ -1623,9 +1628,11 @@ func (c *Client) next() (xml.Name, interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal into that storage.
|
// Unmarshal into that storage.
|
||||||
|
c.nextMutex.Lock()
|
||||||
if err = c.p.DecodeElement(nv, &se); err != nil {
|
if err = c.p.DecodeElement(nv, &se); err != nil {
|
||||||
return xml.Name{}, nil, err
|
return xml.Name{}, nil, err
|
||||||
}
|
}
|
||||||
|
c.nextMutex.Unlock()
|
||||||
|
|
||||||
return se.Name, nv, err
|
return se.Name, nv, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user