1
1

Fix a couple of compile errors. Also, we need to ensure that we only attempt to call destructors on tsd keys that were defined.

This commit was SVN r15501.
Этот коммит содержится в:
Ralph Castain 2007-07-19 12:56:41 +00:00
родитель 7c52a0ce17
Коммит ccdb834574

Просмотреть файл

@ -11,6 +11,8 @@
#include "opal_config.h" #include "opal_config.h"
#include <errno.h>
#include "opal/threads/tsd.h" #include "opal/threads/tsd.h"
#if !OMPI_HAVE_POSIX_THREADS && !OMPI_HAVE_SOLARIS_THREADS && !defined(__WINDOWS__) #if !OMPI_HAVE_POSIX_THREADS && !OMPI_HAVE_SOLARIS_THREADS && !defined(__WINDOWS__)
@ -27,23 +29,25 @@ typedef struct tsd_entry_t tsd_entry_t;
static tsd_entry_t entries[TSD_ENTRIES]; static tsd_entry_t entries[TSD_ENTRIES];
static bool atexit_registered = false; static bool atexit_registered = false;
void static void
run_destructors(void) run_destructors(void)
{ {
int i; int i;
for (i = 0 i < TSD_ENTRIES ; ++i) { for (i = 0; i < TSD_ENTRIES ; ++i) {
opal_tsd_destructor_t destructor; opal_tsd_destructor_t destructor;
void *value; void *value;
destructor = entries[i].destructor; if (entries[i].used) {
value = entries[i].value; destructor = entries[i].destructor;
value = entries[i].value;
entries[i].used = false;
entries[i].destructor = NULL; entries[i].used = false;
entries[i].value = NULL; entries[i].destructor = NULL;
entries[i].value = NULL;
destructor(value);
destructor(value);
}
} }
} }
@ -66,6 +70,7 @@ opal_tsd_key_create(opal_tsd_key_t *key,
entries[i].value = NULL; entries[i].value = NULL;
entries[i].destructor = destructor; entries[i].destructor = destructor;
*key = i; *key = i;
break;
} }
} }
if (i == TSD_ENTRIES) return ENOMEM; if (i == TSD_ENTRIES) return ENOMEM;