diff --git a/builtin.go b/builtin.go index 5257ffb..35706b4 100644 --- a/builtin.go +++ b/builtin.go @@ -17,8 +17,8 @@ import ( func (c *Client) registerBuiltins() { c.debug.Print("registering built-in handlers") - c.mu.Lock() - defer c.mu.Unlock() + c.Handlers.mu.Lock() + defer c.Handlers.mu.Unlock() // Built-in things that should always be supported. c.Handlers.register(true, true, RPL_WELCOME, HandlerFunc(handleConnect)) diff --git a/handler.go b/handler.go index fce8f29..b543300 100644 --- a/handler.go +++ b/handler.go @@ -214,6 +214,8 @@ type execStack struct { // Please note that there is no specific order/priority for which the handlers // are executed. func (c *Caller) exec(command string, bg bool, client *Client, event *Event) { + c.mu.RLock() + defer c.mu.RUnlock() // Build a stack of handlers which can be executed concurrently. var stack []execStack