Add some thread primitives
[mech_eap.git] / util_context.c
index d7a87d3..fab4313 100644 (file)
@@ -47,6 +47,12 @@ gssEapAllocContext(OM_uint32 *minor,
         return GSS_S_FAILURE;
     }
 
+    if (GSSEAP_MUTEX_INIT(&ctx->mutex) != 0) {
+        *minor = errno;
+        gssEapReleaseContext(&tmpMinor, &ctx);
+        return GSS_S_FAILURE;
+    }
+
     *minor = krb5_init_context(&ctx->kerberosCtx);
     if (*minor != 0) {
         gssEapReleaseContext(&tmpMinor, &ctx);
@@ -100,6 +106,8 @@ gssEapReleaseContext(OM_uint32 *minor,
     gss_release_oid(&tmpMinor, &ctx->mechanismUsed);
     sequenceFree(ctx->seqState);
 
+    GSSEAP_MUTEX_DESTROY(&ctx->mutex);
+
     memset(ctx, 0, sizeof(*ctx));
     GSSEAP_FREE(ctx);
     *pCtx = GSS_C_NO_CONTEXT;