Output proper error messages for prthread_setspecific failure in rlm_perl.c and lib...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 17 Feb 2013 18:02:59 +0000 (13:02 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 17 Feb 2013 18:02:59 +0000 (13:02 -0500)
src/lib/log.c
src/modules/rlm_perl/rlm_perl.c

index d44f024..0ab0488 100644 (file)
@@ -90,11 +90,15 @@ void fr_strerror_printf(const char *fmt, ...)
        
        buffer = pthread_getspecific(fr_strerror_key);
        if (!buffer) {
+               int ret;
+               
                buffer = malloc(FR_STRERROR_BUFSIZE);
                if (!buffer) return; /* panic and die! */
-
-               if (pthread_setspecific(fr_strerror_key, buffer) != 0) {
-                       fr_perror("Failed recording thread error");
+       
+               ret = pthread_setspecific(fr_strerror_key, buffer);
+               if (ret != 0) {
+                       fr_perror("Failed recording thread error: %s",
+                                 strerror(ret));
                        
                        return;
                }
index 3322060..75cb3fa 100644 (file)
@@ -248,6 +248,8 @@ static void rlm_perl_make_key(pthread_key_t *key)
 
 static PerlInterpreter *rlm_perl_clone(PerlInterpreter *perl, pthread_key_t *key)
 {
+       int ret;
+       
        PerlInterpreter *interp;
        UV clone_flags = 0;
 
@@ -269,7 +271,14 @@ static PerlInterpreter *rlm_perl_clone(PerlInterpreter *perl, pthread_key_t *key
        PERL_SET_CONTEXT(aTHX);
        rlm_perl_clear_handles(aTHX);
 
-       pthread_setspecific(*key, interp);
+       ret = pthread_setspecific(*key, interp);
+       if (ret != 0) {
+               radlog(L_DBG,"rlm_perl: Failed associating interpretor "
+                      "with thread %s", strerror(ret));
+                      
+               rlm_perl_destruct(interp);
+               return NULL;
+       }
 
        return interp;
 }