grpcomm/base: plug a memory leak on finalize
manually allocate sequence numbers to be stored into the orte_grpcomm_base.sig_table hash table, and manually release them on orte_grpcomm_base_close() Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
родитель
2189c5bcc3
Коммит
fe25f50871
@ -13,7 +13,7 @@
|
||||
* Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* Copyright (c) 2015-2017 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
@ -59,6 +59,9 @@ static bool recv_issued = false;
|
||||
static int orte_grpcomm_base_close(void)
|
||||
{
|
||||
orte_grpcomm_base_active_t *active;
|
||||
void *key;
|
||||
size_t size;
|
||||
uint32_t *seq_number;
|
||||
|
||||
if (recv_issued) {
|
||||
orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORTE_RML_TAG_XCAST);
|
||||
@ -73,6 +76,10 @@ static int orte_grpcomm_base_close(void)
|
||||
}
|
||||
OPAL_LIST_DESTRUCT(&orte_grpcomm_base.actives);
|
||||
OPAL_LIST_DESTRUCT(&orte_grpcomm_base.ongoing);
|
||||
for (void *_nptr=NULL; \
|
||||
OPAL_SUCCESS == opal_hash_table_get_next_key_ptr(&orte_grpcomm_base.sig_table, &key, &size, (void **)&seq_number, _nptr, &_nptr);) {
|
||||
free(seq_number);
|
||||
}
|
||||
OBJ_DESTRUCT(&orte_grpcomm_base.sig_table);
|
||||
|
||||
return mca_base_framework_components_close(&orte_grpcomm_base_framework, NULL);
|
||||
|
@ -141,7 +141,7 @@ static void allgather_stub(int fd, short args, void *cbdata)
|
||||
int rc;
|
||||
orte_grpcomm_base_active_t *active;
|
||||
orte_grpcomm_coll_t *coll;
|
||||
void *seq_number;
|
||||
uint32_t *seq_number;
|
||||
|
||||
OPAL_OUTPUT_VERBOSE((1, orte_grpcomm_base_framework.framework_output,
|
||||
"%s grpcomm:base:allgather stub",
|
||||
@ -150,11 +150,14 @@ static void allgather_stub(int fd, short args, void *cbdata)
|
||||
/* retrieve an existing tracker, create it if not
|
||||
* already found. The allgather module is responsible
|
||||
* for releasing it upon completion of the collective */
|
||||
ret = opal_hash_table_get_value_ptr(&orte_grpcomm_base.sig_table, (void *)cd->sig->signature, cd->sig->sz * sizeof(orte_process_name_t), &seq_number);
|
||||
ret = opal_hash_table_get_value_ptr(&orte_grpcomm_base.sig_table, (void *)cd->sig->signature, cd->sig->sz * sizeof(orte_process_name_t), (void **)&seq_number);
|
||||
if (OPAL_ERR_NOT_FOUND == ret) {
|
||||
cd->sig->seq_num = 0;
|
||||
seq_number = (uint32_t *)malloc(sizeof(uint32_t));
|
||||
*seq_number = 0;
|
||||
} else if (OPAL_SUCCESS == ret) {
|
||||
cd->sig->seq_num = *((uint32_t *)(seq_number)) + 1;
|
||||
*seq_number = *seq_number + 1;
|
||||
cd->sig->seq_num = *seq_number;
|
||||
} else {
|
||||
OPAL_OUTPUT((orte_grpcomm_base_framework.framework_output,
|
||||
"%s rpcomm:base:allgather cannot get signature from hash table",
|
||||
@ -163,7 +166,7 @@ static void allgather_stub(int fd, short args, void *cbdata)
|
||||
OBJ_RELEASE(cd);
|
||||
return;
|
||||
}
|
||||
ret = opal_hash_table_set_value_ptr(&orte_grpcomm_base.sig_table, (void *)cd->sig->signature, cd->sig->sz * sizeof(orte_process_name_t), (void *)&cd->sig->seq_num);
|
||||
ret = opal_hash_table_set_value_ptr(&orte_grpcomm_base.sig_table, (void *)cd->sig->signature, cd->sig->sz * sizeof(orte_process_name_t), (void *)seq_number);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
OPAL_OUTPUT((orte_grpcomm_base_framework.framework_output,
|
||||
"%s rpcomm:base:allgather cannot add new signature to hash table",
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user