fix: handle Query/QueryRow/transaction errors in channel server handlers

Add error checking and logging for ~25 database call sites that were
silently dropping errors, preventing resource leaks (unclosed rows),
nil pointer panics, and silent data corruption in festa transactions.
This commit is contained in:
Houmgaor
2026-02-17 17:44:35 +01:00
parent 645c4ddd38
commit fb3e86f429
9 changed files with 174 additions and 93 deletions

View File

@@ -416,10 +416,15 @@ func (s *Server) FindSessionByCharID(charID uint32) *Session {
func (s *Server) DisconnectUser(uid uint32) {
var cid uint32
var cids []uint32
rows, _ := s.db.Query(`SELECT id FROM characters WHERE user_id=$1`, uid)
for rows.Next() {
rows.Scan(&cid)
cids = append(cids, cid)
rows, err := s.db.Query(`SELECT id FROM characters WHERE user_id=$1`, uid)
if err != nil {
s.logger.Error("Failed to query characters for disconnect", zap.Error(err))
} else {
defer rows.Close()
for rows.Next() {
rows.Scan(&cid)
cids = append(cids, cid)
}
}
for _, c := range s.Channels {
for _, session := range c.sessions {