-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
You have a dead lock because you are double locking.
Lines 130 to 150 in 79c1cee
| lock.Lock() | |
| defer lock.Unlock() | |
| if ClientExists(name) { | |
| delete(clients, name) | |
| log.Print("[RemoveClient]: Removed client " + name) | |
| if InGroup(name) { | |
| RemoveClientFromGroup(name) | |
| } else { | |
| log.Print("[RemoveClient]: " + name + " was not in any groups.") | |
| return nil | |
| } | |
| } | |
| return errors.New("[RemoveClient]: Client (" + name + ") doesn't exist") | |
| } | |
| // AddClientToGroup will add a client to a group. | |
| // It doesn't return anything. | |
| func AddClientToGroup(c string, g string) { | |
Lines 78 to 85 in 79c1cee
| func ClientExists(n string) bool { | |
| lock.RLock() | |
| defer lock.RUnlock() | |
| for c := range clients { | |
| if c == n { | |
| return true | |
| } |
A fix would be
if ClientExists(name) {
lock.Lock()
defer lock.Unlock()
delete(clients, name)
log.Print("[RemoveClient]: Removed client " + name)
if InGroup(name)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels