Make _gss_load_mech() atomic and run only once, this have the side
effect that _gss_mechs and _gss_mech_oids is only initialized once, so if just the users of these two global variables calls _gss_load_mech() first, it will act as a barrier and make sure the variables are never changed and we don't need to lock them. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17842 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mech_locl.h"
|
#include "mech_locl.h"
|
||||||
|
#include <heim_threads.h>
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
#ifndef _PATH_GSS_MECH
|
#ifndef _PATH_GSS_MECH
|
||||||
@@ -35,6 +36,7 @@ RCSID("$Id$");
|
|||||||
|
|
||||||
struct _gss_mech_switch_list _gss_mechs = { NULL } ;
|
struct _gss_mech_switch_list _gss_mechs = { NULL } ;
|
||||||
gss_OID_set _gss_mech_oids;
|
gss_OID_set _gss_mech_oids;
|
||||||
|
static HEIMDAL_MUTEX _gss_mech_mutex = HEIMDAL_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a string containing an OID in 'dot' form
|
* Convert a string containing an OID in 'dot' form
|
||||||
@@ -195,13 +197,20 @@ _gss_load_mech(void)
|
|||||||
struct _gss_mech_switch *m;
|
struct _gss_mech_switch *m;
|
||||||
void *so;
|
void *so;
|
||||||
|
|
||||||
if (SLIST_FIRST(&_gss_mechs))
|
|
||||||
|
HEIMDAL_MUTEX_lock(&_gss_mech_mutex);
|
||||||
|
|
||||||
|
if (SLIST_FIRST(&_gss_mechs)) {
|
||||||
|
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
major_status = gss_create_empty_oid_set(&minor_status,
|
major_status = gss_create_empty_oid_set(&minor_status,
|
||||||
&_gss_mech_oids);
|
&_gss_mech_oids);
|
||||||
if (major_status)
|
if (major_status) {
|
||||||
|
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
add_builtin(__gss_krb5_initialize());
|
add_builtin(__gss_krb5_initialize());
|
||||||
add_builtin(__gss_spnego_initialize());
|
add_builtin(__gss_spnego_initialize());
|
||||||
@@ -209,6 +218,7 @@ _gss_load_mech(void)
|
|||||||
fp = fopen(_PATH_GSS_MECH, "r");
|
fp = fopen(_PATH_GSS_MECH, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
/* perror(_PATH_GSS_MECH); */
|
/* perror(_PATH_GSS_MECH); */
|
||||||
|
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +303,7 @@ _gss_load_mech(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gssapi_mech_interface
|
gssapi_mech_interface
|
||||||
|
Reference in New Issue
Block a user