summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-07-03 14:04:19 +0200
committerxengineering <me@xengineering.eu>2023-07-03 14:04:19 +0200
commit8df0398af97f2f9e782f4f5581ea5f4db236710d (patch)
tree53286da2739ae794ce7d420bb913a93139961880
parent322e2c5f24c830282dbd66adbb95a7acf1255c9a (diff)
parent58aecc9d860a18767aa51d0d94793057e1aa57e2 (diff)
downloadlimox-8df0398af97f2f9e782f4f5581ea5f4db236710d.tar
limox-8df0398af97f2f9e782f4f5581ea5f4db236710d.tar.zst
limox-8df0398af97f2f9e782f4f5581ea5f4db236710d.zip
Merge branch 'fix-btn-callback-race'
This fixes a race condition which was discovered during testing with a bad network connection. Good network connections seem to hide this error.
-rw-r--r--limox.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/limox.go b/limox.go
index 87e20de..5bb2d57 100644
--- a/limox.go
+++ b/limox.go
@@ -80,6 +80,7 @@ func (l *Limox) run() error {
}
func (l *Limox) buttonCallback() {
+ c := l.sessionIn
switch l.State {
case Disconnected:
jid := l.JidEditor.Text()
@@ -89,10 +90,10 @@ func (l *Limox) buttonCallback() {
l.sessionIn = xmpp.StartSession(l.sessionOut, jid, pwd)
l.State = Connecting
case Connecting:
- go func() { l.sessionIn <- xmpp.SessionShouldDisconnect{} }()
+ go func() { c <- xmpp.SessionShouldDisconnect{} }()
l.State = Disconnected
case Connected:
- go func() { l.sessionIn <- xmpp.SessionShouldDisconnect{} }()
+ go func() { c <- xmpp.SessionShouldDisconnect{} }()
l.State = Disconnected
}
}