Add a barrier to avoid a race in some cases.