Skip to content
Snippets Groups Projects
Commit e2c88550 authored by meskio's avatar meskio :mountain_snow: Committed by onyinyang
Browse files

internal: unregister the events channel before closing it

defers are executed in oposite direction that then are called. If we
call the close defer after the unregistration of the channel it will
executed first. It can happen that an event arrive between the two of
them and crash rdsys.

* Closes: #222
parent 381e8c23
No related branches found
Tags tor-0.2.2.5-alpha
1 merge request!375internal: unregister the events channel before closing it
Pipeline #201043 passed
......@@ -224,9 +224,9 @@ func (b *BackendContext) getResourceStreamHandler(w http.ResponseWriter, r *http
w.WriteHeader(http.StatusOK)
diffs := make(chan *core.ResourceDiff)
defer close(diffs)
b.Resources.RegisterChan(req, diffs)
defer b.Resources.UnregisterChan(req.RequestOrigin, diffs)
defer close(diffs)
sendDiff := func(diff *core.ResourceDiff) error {
jsonBlurb, err := json.MarshalIndent(diff, "", " ")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment