mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user