25
25
#include < QSslConfiguration>
26
26
#include < QSslError>
27
27
#endif
28
+ #include < QMutexLocker>
28
29
29
30
#include " qgsauthcertutils.h"
30
31
#include " qgsauthmanager.h"
@@ -52,8 +53,9 @@ QgsAuthPkcs12Method::QgsAuthPkcs12Method()
52
53
53
54
QgsAuthPkcs12Method::~QgsAuthPkcs12Method ()
54
55
{
55
- qDeleteAll ( mPkiConfigBundleCache );
56
- mPkiConfigBundleCache .clear ();
56
+ QMutexLocker locker ( &mConfigMutex );
57
+ qDeleteAll ( sPkiConfigBundleCache );
58
+ sPkiConfigBundleCache .clear ();
57
59
}
58
60
59
61
QString QgsAuthPkcs12Method::key () const
@@ -222,7 +224,8 @@ void QgsAuthPkcs12Method::updateMethodConfig( QgsAuthMethodConfig &mconfig )
222
224
223
225
QgsPkiConfigBundle *QgsAuthPkcs12Method::getPkiConfigBundle ( const QString &authcfg )
224
226
{
225
- QgsPkiConfigBundle * bundle = nullptr ;
227
+ QMutexLocker locker ( &mConfigMutex );
228
+ QgsPkiConfigBundle *bundle = nullptr ;
226
229
227
230
// check if it is cached
228
231
if ( mPkiConfigBundleCache .contains ( authcfg ) )
@@ -272,6 +275,7 @@ QgsPkiConfigBundle *QgsAuthPkcs12Method::getPkiConfigBundle( const QString &auth
272
275
273
276
bundle = new QgsPkiConfigBundle ( mconfig, clientcert, clientkey );
274
277
278
+ locker.unlock ();
275
279
// cache bundle
276
280
putPkiConfigBundle ( authcfg, bundle );
277
281
@@ -280,13 +284,15 @@ QgsPkiConfigBundle *QgsAuthPkcs12Method::getPkiConfigBundle( const QString &auth
280
284
281
285
void QgsAuthPkcs12Method::putPkiConfigBundle ( const QString &authcfg, QgsPkiConfigBundle *pkibundle )
282
286
{
287
+ QMutexLocker locker ( &mConfigMutex );
283
288
QgsDebugMsg ( QString ( " Putting PKI bundle for authcfg %1" ).arg ( authcfg ) );
284
289
mPkiConfigBundleCache .insert ( authcfg, pkibundle );
285
290
}
286
291
287
292
void QgsAuthPkcs12Method::removePkiConfigBundle ( const QString &authcfg )
288
293
{
289
- if ( mPkiConfigBundleCache .contains ( authcfg ) )
294
+ QMutexLocker locker ( &mConfigMutex );
295
+ if ( sPkiConfigBundleCache .contains ( authcfg ) )
290
296
{
291
297
QgsPkiConfigBundle * pkibundle = mPkiConfigBundleCache .take ( authcfg );
292
298
delete pkibundle;
0 commit comments