Fix IsInitialBlockDownload which was broken by headers first.
Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true.
Merge pull request #5158

9ec75c5 Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true. (Ruben Dario Ponticelli)
a2d0fc6 Fix IsInitialBlockDownload which was broken by headers first. (Ruben Dario Ponticelli)