Skip to content

Commit

Permalink
Allow implementations to decide when to make signal handling asynchro…
Browse files Browse the repository at this point in the history
…nous.

This moves the place where the signal handler is asynchronous. For signals
the ordering of arrivial may be important. Making them asynchronous by defualt
does not allow for this policy decision to be made by the signal handler. In
order to preserve the current behavior, make the default handler asynchronous
instead of all handlers.
  • Loading branch information
jsouthworth committed Sep 17, 2017
1 parent 7f21b8d commit 29c37e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (conn *Conn) inWorker() {
conn.namesLck.Unlock()
}
}
go conn.handleSignal(msg)
conn.handleSignal(msg)
case TypeMethodCall:
go conn.handleCall(msg)
}
Expand Down
18 changes: 10 additions & 8 deletions default_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,16 @@ type defaultSignalHandler struct {
}

func (sh *defaultSignalHandler) DeliverSignal(intf, name string, signal *Signal) {
sh.RLock()
defer sh.RUnlock()
if sh.closed {
return
}
for _, ch := range sh.signals {
ch <- signal
}
go func() {
sh.RLock()
defer sh.RUnlock()
if sh.closed {
return
}
for _, ch := range sh.signals {
ch <- signal
}
}()
}

func (sh *defaultSignalHandler) Init() error {
Expand Down

0 comments on commit 29c37e6

Please sign in to comment.