C_Initialize may be called by multiple threads
C_Initialize may be called by multiple threads

While trying to setup an OpenSC context, the global_locking
and detect cards, it is possible that multiple threads may
call C_Initialize. The current code tries to prevent this using
"if (context == NULL)"  but this is not a mutex, and
multiple threads may endup overwrite contexts and global locking and
cause additional problems, with pcsc and segfault.

FireFox appears to do this see #2032

The PR adds a mutex or Critical section to make sure only one
thread creates the context sets the global_locking  and does
the initial detect cards, etc.

This allows the global_lock (if requested) to be setup
which is then used for other calls.

All but the first call to C_Initialize will return with CKR_OK,
others will return CKR_CRYPTOKI_ALREADY_INITIALIZED.

 Date:      Mon Jan 11 12:47:12 2021 -0600
 Changes to be committed:
	modified:   src/pkcs11/pkcs11-global.c

frankmorgner/OpenSC,frankmorgner/OpenSC,mouse07410/OpenSC,hongquan/OpenSC-main,frankmorgner/OpenSC,dengert/OpenSC,philipWendland/OpenSC,philipWendland/OpenSC,OpenSC/OpenSC,mouse07410/OpenSC,OpenSC/OpenSC,hongquan/OpenSC-main,LudovicRousseau/OpenSC,Jakuje/OpenSC,metsma/OpenSC,dengert/OpenSC,OpenSC/OpenSC,Jakuje/OpenSC,metsma/OpenSC,fabled/OpenSC,Jakuje/OpenSC,metsma/OpenSC,fabled/OpenSC,LudovicRousseau/OpenSC,philipWendland/OpenSC,Jakuje/OpenSC,hongquan/OpenSC-main,LudovicRousseau/OpenSC,fabled/OpenSC,mouse07410/OpenSC,fabled/OpenSC,frankmorgner/OpenSC,dengert/OpenSC