X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot.git;a=blobdiff_plain;f=moonshot%2Fmech_eap%2Fdisplay_status.c;h=e826b198f48fb6ee8ab90544eb45160e89879408;hp=78738ff2bb4fa4ed459acb8e36d653507fd3791d;hb=ecf20954105d5ac0b7a47bd4932c2dacc1a96e3e;hpb=e423e21b42ce7dd5a44612bebc3d8741b01ce10c diff --git a/moonshot/mech_eap/display_status.c b/moonshot/mech_eap/display_status.c index 78738ff..e826b19 100644 --- a/moonshot/mech_eap/display_status.c +++ b/moonshot/mech_eap/display_status.c @@ -36,33 +36,24 @@ #include "gssapiP_eap.h" -static GSSEAP_THREAD_ONCE gssEapStatusInfoKeyOnce = GSSEAP_ONCE_INITIALIZER; -static GSSEAP_THREAD_KEY gssEapStatusInfoKey; - struct gss_eap_status_info { OM_uint32 code; char *message; struct gss_eap_status_info *next; }; -static void -destroyStatusInfo(void *arg) +void +gssEapDestroyStatusInfo(struct gss_eap_status_info *p) { - struct gss_eap_status_info *p = arg, *next; + struct gss_eap_status_info *next; - for (p = arg; p != NULL; p = next) { + for (; p != NULL; p = next) { next = p->next; GSSEAP_FREE(p->message); GSSEAP_FREE(p); } } -static void -createStatusInfoKey(void) -{ - GSSEAP_KEY_CREATE(&gssEapStatusInfoKey, destroyStatusInfo); -} - /* * Associate a message with a mechanism (minor) status code. This function * takes ownership of the message regardless of success. The message must @@ -73,23 +64,23 @@ createStatusInfoKey(void) static void saveStatusInfoNoCopy(OM_uint32 minor, char *message) { - struct gss_eap_status_info **next = NULL, *p; - - GSSEAP_ONCE(&gssEapStatusInfoKeyOnce, createStatusInfoKey); - - p = GSSEAP_GETSPECIFIC(gssEapStatusInfoKey); - for (; p != NULL; p = p->next) { - if (p->code == minor) { - /* Set message in-place */ - if (p->message != NULL) - GSSEAP_FREE(p->message); - p->message = message; - return; + struct gss_eap_status_info **next = NULL, *p=NULL; + struct gss_eap_thread_local_data *tld = gssEapGetThreadLocalData(); + + if (tld != NULL) { + for (p = tld->statusInfo; p != NULL; p = p->next) { + if (p->code == minor) { + /* Set message in-place */ + if (p->message != NULL) + GSSEAP_FREE(p->message); + p->message = message; + return; + } + next = &p->next; } - next = &p->next; + p = GSSEAP_CALLOC(1, sizeof(*p)); } - p = GSSEAP_CALLOC(1, sizeof(*p)); if (p == NULL) { if (message != NULL) GSSEAP_FREE(message); @@ -102,21 +93,20 @@ saveStatusInfoNoCopy(OM_uint32 minor, char *message) if (next != NULL) *next = p; else - GSSEAP_SETSPECIFIC(gssEapStatusInfoKey, p); + tld->statusInfo = p; } static const char * getStatusInfo(OM_uint32 minor) { struct gss_eap_status_info *p; + struct gss_eap_thread_local_data *tld = gssEapGetThreadLocalData(); - GSSEAP_ONCE(&gssEapStatusInfoKeyOnce, createStatusInfoKey); - - for (p = GSSEAP_GETSPECIFIC(gssEapStatusInfoKey); - p != NULL; - p = p->next) { - if (p->code == minor) - return p->message; + if (tld != NULL) { + for (p = tld->statusInfo; p != NULL; p = p->next) { + if (p->code == minor) + return p->message; + } } return NULL;