mirror of https://github.com/docker/docs.git
Merge pull request #2013 from allencloud/add-read-lock-only-when-necessary
add read lock for eventsHandler when only it is necessary.
This commit is contained in:
commit
3990430ab1
|
|
@ -73,8 +73,6 @@ func (eh *eventsHandler) cleanupHandler(remoteAddr string) {
|
||||||
// Handle writes information about a cluster event to each remote address in the cluster that has been added to the events handler.
|
// Handle writes information about a cluster event to each remote address in the cluster that has been added to the events handler.
|
||||||
// After an unsuccessful write to a remote address, the associated channel is closed and the address is removed from the events handler.
|
// After an unsuccessful write to a remote address, the associated channel is closed and the address is removed from the events handler.
|
||||||
func (eh *eventsHandler) Handle(e *cluster.Event) error {
|
func (eh *eventsHandler) Handle(e *cluster.Event) error {
|
||||||
eh.RLock()
|
|
||||||
|
|
||||||
// remove this hack once 1.10 is broadly adopted
|
// remove this hack once 1.10 is broadly adopted
|
||||||
from := e.From
|
from := e.From
|
||||||
e.From = e.From + " node:" + e.Engine.Name
|
e.From = e.From + " node:" + e.Engine.Name
|
||||||
|
|
@ -109,6 +107,8 @@ func (eh *eventsHandler) Handle(e *cluster.Event) error {
|
||||||
|
|
||||||
var failed []string
|
var failed []string
|
||||||
|
|
||||||
|
eh.RLock()
|
||||||
|
|
||||||
for key, w := range eh.ws {
|
for key, w := range eh.ws {
|
||||||
if _, err := fmt.Fprintf(w, string(data)); err != nil {
|
if _, err := fmt.Fprintf(w, string(data)); err != nil {
|
||||||
// collect them to handle later under Lock
|
// collect them to handle later under Lock
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue