Fix deadlock(s)

This commit is contained in:
nak 2026-03-20 08:19:26 +00:00
parent 087534ce23
commit 081ba5da4e
3 changed files with 18 additions and 27 deletions

View file

@ -2,7 +2,7 @@
set -e
echo "Pulling latest..."
git pull
#git pull
echo "Building..."
go build -o overte-api .

32
hub.go
View file

@ -64,22 +64,22 @@ func (h *Hub) count() int {
// SendToUser sends a message to the first client identified as username.
func (h *Hub) SendToUser(username string, msg interface{}) {
data, err := json.Marshal(msg)
if err != nil {
return
}
h.mu.RLock()
defer h.mu.RUnlock()
for c := range h.clients {
if c.username == username {
select {
case c.send <- data:
default:
log.Printf("[WS] dropped private message to %s", username)
}
return
}
}
data, err := json.Marshal(msg)
if err != nil {
return
}
h.mu.RLock()
defer h.mu.RUnlock()
for c := range h.clients {
if c.username == username {
select {
case c.send <- data:
default:
log.Printf("[WS] dropped private message to %s (channel full)", username)
}
// no return — send to all matching clients
}
}
}
func (h *Hub) Broadcast(msg interface{}, sender *Client) {

View file

@ -415,25 +415,21 @@ func (t *Table) Reveal(username string) {
func (t *Table) advance() {
t.mu.Lock()
defer t.mu.Unlock()
// Check if only one player remains
if t.countActivePlayers() == 1 {
t.mu.Unlock()
t.awardPot()
return
}
// Check if betting is complete for this street
if !t.bettingComplete() {
t.Hand.ActionOn = t.nextActiveSeat(t.Hand.ActionOn)
t.mu.Unlock()
t.broadcastState()
t.startTurnTimer()
t.mu.Lock()
return
}
// Advance to next street
switch t.Hand.Phase {
case PhasePreflop:
var cards []string
@ -454,24 +450,19 @@ func (t *Table) advance() {
t.Hand.Phase = PhaseShowdown
t.mu.Unlock()
t.doShowdown()
t.mu.Lock()
return
}
// Reset bets for new street
for _, s := range t.Seats {
s.Bet = 0
}
t.acted = make(map[string]bool)
t.Hand.LastRaise = 0
t.Hand.MinRaise = t.Config.BigBlind
// Action starts left of dealer post-flop
t.Hand.ActionOn = t.nextActiveSeat(t.Hand.DealerSeat)
t.mu.Unlock()
t.broadcastState()
t.startTurnTimer()
t.mu.Lock()
}
func (t *Table) doShowdown() {