Fix a race condition problem

I've fixed #3857.

And I am sorry. I didn't know my commit was notified to upstream automatically. 
I shouldn't have done force-push.
I prefer `__safeUpdateMode` too, it is less likely to conflict with userland variable names.