[krbdev.mit.edu #6569] krb5-1.7 hangs on Solaris

Arlene Berry via RT rt-comment at krbdev.mit.edu
Tue Sep 22 15:57:04 EDT 2009


We're seeing hangs on Solaris because krb5-1.7 uses res_init and
res_search from multiple threads. On Solaris, those functions are not
thread safe.  To fix it we changed krb5int_dns_init to call res_init
only once and added a mutex around res_search:

 

Index: src/lib/krb5/os/dnsglue.c

===================================================================

--- src/lib/krb5/os/dnsglue.c (revision 37274)

+++ src/lib/krb5/os/dnsglue.c (working copy)

@@ -63,6 +63,10 @@

 static int initparse(struct krb5int_dns_state *);

 #endif

 

+#if !USE_RES_NINIT

+static k5_mutex_t dns_res_lock = K5_MUTEX_PARTIAL_INITIALIZER;

+#endif

+

 /*

  * krb5int_dns_init()

  *

@@ -102,12 +106,24 @@

 #if USE_RES_NINIT

     memset(&statbuf, 0, sizeof(statbuf));

     ret = res_ninit(&statbuf);

-#else

-    ret = res_init();

-#endif

     if (ret < 0)

      return -1;

+#else

+    if (!(_res.options & RES_INIT))

+    {

+     ret = res_init();

+     if (ret < 0)

+         return -1;

 

+     ret = k5_mutex_finish_init(&dns_res_lock);

+     if (ret < 0)

+         return ret;

+    }

+    ret = k5_mutex_lock(&dns_res_lock);

+    if (ret < 0)

+     return ret;

+#endif

+

     do {

      p = (ds->ansp == NULL)

          ? malloc(nextincr) : realloc(ds->ansp, nextincr);

@@ -152,6 +168,8 @@

 errout:

 #if USE_RES_NINIT

     res_ndestroy(&statbuf);

+#else

+    k5_mutex_unlock(&dns_res_lock);

 #endif

     if (ret < 0) {

      if (ds->ansp != NULL) {

 

 





More information about the krb5-bugs mailing list