Fix apply_changes function race condition

Due to an error in logic of apply_changes method
we had problems with parallel deployment of controllers
as we were generating XML patch between live CIB and
shadow generated on the base of (sometimes!) older CIB.

This could lead to the problem that crm_diff removes
some of the data from the live CIB as it was not present
in the old CIB.

An example of such behaviour is the bug with location
constraints missing for virtual ip addresses as our
service provider was creating them in this window
between shadow creation and retrieving of the live CIB
thus crm_diff was generating patch removing this location
and leading to this bug.

Change-Id: Icb28fe6d90f44084d424b793db792869e0c6c66c
Closes-bug: #1396481
Merge "Fix apply_changes function race condition"