Fix bug #1333098. Concurrent access to the objectCache needs to be protected.

We add a Mutex around the objectCache map.

While there, I discovered a difference race condition in the api Watcher code.
So I fixed that in passing.

The new test fails if you run under '-race', and the tests in cmd/jujud/*TestMachineAgentRsyslog* used
to fail with the race detector and now pass.
+1


On Tue, Jun 24, 2014 at 4:10 PM, John Arbash Meinel <
notifications@github.com> wrote:

> In state/api/watcher/watcher.go:
>
> > @@ -145,6 +151,9 @@ func (w *notifyWatcher) loop() error {
> >  		return w.caller.Call("NotifyWatcher", w.notifyWatcherId, request, nil, &result)
> >  	}
> >  	w.commonWatcher.init()
> > +	// We have to add a wait group here, otherwise we aren't guaranteed to
> > +	// ever call the commonLoop goroutines.
> > +	w.wg.Add(1)
>
> I went with removing the "wg" from the global object and instead only
> using it as a local variable inside the commonLoop code.
> All the tests still pass, and the race detector is happy.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/juju/juju/pull/146/files#r14114357>.
>