Fix possible mutex deadlock in handle()

Also added some logging.
This commit is contained in:
Bruce Marriner 2016-05-28 13:51:17 -05:00
parent 32aa5718d1
commit 7ed2a289bc

View file

@ -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()