improve plugin initialization state guard

the variable guards against invocations of api callbacks
before the plugins have been initialized. valgrind didnt like
that it was not being locked in the same way in all the places
it is used.