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.
Этот коммит содержится в:
родитель
7c52a0ce17
Коммит
ccdb834574
@ -11,6 +11,8 @@
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "opal/threads/tsd.h"
|
||||
|
||||
#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 bool atexit_registered = false;
|
||||
|
||||
void
|
||||
static void
|
||||
run_destructors(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 i < TSD_ENTRIES ; ++i) {
|
||||
for (i = 0; i < TSD_ENTRIES ; ++i) {
|
||||
opal_tsd_destructor_t destructor;
|
||||
void *value;
|
||||
|
||||
destructor = entries[i].destructor;
|
||||
value = entries[i].value;
|
||||
|
||||
entries[i].used = false;
|
||||
entries[i].destructor = NULL;
|
||||
entries[i].value = NULL;
|
||||
|
||||
destructor(value);
|
||||
if (entries[i].used) {
|
||||
destructor = entries[i].destructor;
|
||||
value = entries[i].value;
|
||||
|
||||
entries[i].used = false;
|
||||
entries[i].destructor = NULL;
|
||||
entries[i].value = NULL;
|
||||
|
||||
destructor(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,6 +70,7 @@ opal_tsd_key_create(opal_tsd_key_t *key,
|
||||
entries[i].value = NULL;
|
||||
entries[i].destructor = destructor;
|
||||
*key = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == TSD_ENTRIES) return ENOMEM;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user