mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2026-06-29 20:13:46 -07:00
xmpp_transport: Add buffer to closeChan to prevent deadlock
closeChan is used to communicate that a stream close has been received. In the case where the client initiates the stream closure, this works: 1) client sends stream close 2) client reads from closeChan, waiting for the server's stream close In the case where the server initiates the stream closure, it failed: 1) transport writes to closeChan x) client is not waiting on closeChan, so the write blocks and transport hangs This change allows up to one event to be written asynchronously to closeChan. After the client is notified about the disconnection, it will read from closeChan as in the client-initiated flow but will simply find the stream close already there.
This commit is contained in:
committed by
Mickaël Rémond
parent
7df984516d
commit
b407d5cd11
+1
-1
@@ -43,7 +43,7 @@ func (t *XMPPTransport) Connect() (string, error) {
|
||||
return "", NewConnError(err, true)
|
||||
}
|
||||
|
||||
t.closeChan = make(chan stanza.StreamClosePacket)
|
||||
t.closeChan = make(chan stanza.StreamClosePacket, 1)
|
||||
t.readWriter = newStreamLogger(t.conn, t.logFile)
|
||||
t.decoder = xml.NewDecoder(bufio.NewReaderSize(t.readWriter, maxPacketSize))
|
||||
t.decoder.CharsetReader = t.Config.CharsetReader
|
||||
|
||||
Reference in New Issue
Block a user