avoid race condition when calling SimplePV.updateValue()
avoid race condition when calling SimplePV.updateValue()

PV records are ultimately updated in the SimplePV.updateValue() method.
This method is called in two places in the code: in SimplePV's scan()
method, which is run in a separate thread, and in calls to Driver.updatePVs().
which is usually executed manually in user code.  A lack of synchronization
in these calls allows for possible collisions in the record updates, which
seem to manifest in occasional redundant updates as see by clients.

This patch reorders the sequence of calls around updateValue() to use the
update flag as an effective synchronization token.  Since the updateValue()
method is not called if the PV "flag" is True, resetting the flag right
before the call, instead of right after, seems to prevent the double updates.

paulscherrerinstitute/pcaspy,paulscherrerinstitute/pcaspy,paulscherrerinstitute/pcaspy