Fix listen-bucket (Fixes #2942) (#2949)

Don't close socket while re-initializing notify-listeners, as the rpc
client object is shared between notify-listeners and peer clients.

Also, improves SendRPC() readability by using GetPeerClient().
This commit is contained in:
Aditya Manthramurthy
2016-10-16 20:52:10 -07:00
committed by Harshavardhana
parent 334cdb5d64
commit d02cb963d5
4 changed files with 7 additions and 16 deletions
+5 -1
View File
@@ -322,7 +322,11 @@ func (api objectAPIHandlers) ListenBucketNotificationHandler(w http.ResponseWrit
nEventCh := make(chan []NotificationEvent)
defer close(nEventCh)
// Add channel for listener events
globalEventNotifier.AddListenerChan(accountARN, nEventCh)
if err = globalEventNotifier.AddListenerChan(accountARN, nEventCh); err != nil {
errorIf(err, "Error adding a listener!")
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
return
}
// Remove listener channel after the writer has closed or the
// client disconnected.
defer globalEventNotifier.RemoveListenerChan(accountARN)