Ver Fonte

Fix possible mutex deadlock in handle()

Also added some logging.
Bruce Marriner há 8 anos atrás
pai
commit
7ed2a289bc
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      discord.go

+ 4 - 2
discord.go

@@ -205,13 +205,13 @@ func (s *Session) handle(event interface{}) {
 
 	if handlers, ok := s.handlers[nil]; ok {
 		for _, handler := range handlers {
-			handler.Call(handlerParameters)
+			go handler.Call(handlerParameters)
 		}
 	}
 
 	if handlers, ok := s.handlers[reflect.TypeOf(event)]; ok {
 		for _, handler := range handlers {
-			handler.Call(handlerParameters)
+			go handler.Call(handlerParameters)
 		}
 	}
 }
@@ -219,6 +219,8 @@ func (s *Session) handle(event interface{}) {
 // initialize adds all internal handlers and state tracking handlers.
 func (s *Session) initialize() {
 
+	s.log(LogInformational, "called")
+
 	s.handlersMu.Lock()
 	if s.handlers != nil {
 		s.handlersMu.Unlock()