|
5 | 5 | * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights |
6 | 6 | * reserved. |
7 | 7 | * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. |
8 | | - * Copyright (c) 2014 Intel Corporation. All rights reserved. |
| 8 | + * Copyright (c) 2014-2016 Intel Corporation. All rights reserved. |
9 | 9 | * $COPYRIGHT$ |
10 | 10 | * |
11 | 11 | * Additional copyrights may follow |
|
24 | 24 |
|
25 | 25 | #include "orte/mca/rml/rml.h" |
26 | 26 | #include "orte/mca/state/state.h" |
| 27 | +#include "orte/runtime/orte_wait.h" |
27 | 28 | #include "orte/util/name_fns.h" |
28 | 29 |
|
29 | 30 | #include "orte/mca/rml/base/base.h" |
@@ -72,14 +73,36 @@ static int orte_rml_base_register(mca_base_register_flag_t flags) |
72 | 73 | return ORTE_SUCCESS; |
73 | 74 | } |
74 | 75 |
|
75 | | -static int orte_rml_base_close(void) |
| 76 | +static void cleanup(int sd, short args, void *cbdata) |
76 | 77 | { |
77 | | - opal_list_item_t *item; |
| 78 | + volatile bool *active = (volatile bool*)cbdata; |
78 | 79 |
|
79 | | - while (NULL != (item = opal_list_remove_first(&orte_rml_base.posted_recvs))) { |
80 | | - OBJ_RELEASE(item); |
| 80 | + OPAL_LIST_DESTRUCT(&orte_rml_base.posted_recvs); |
| 81 | + if (NULL != active) { |
| 82 | + *active = false; |
81 | 83 | } |
82 | | - OBJ_DESTRUCT(&orte_rml_base.posted_recvs); |
| 84 | +} |
| 85 | + |
| 86 | +static int orte_rml_base_close(void) |
| 87 | +{ |
| 88 | + volatile bool active; |
| 89 | + |
| 90 | + /* because the RML posted recvs list is in a separate |
| 91 | + * async thread for apps, we can't just destruct it here. |
| 92 | + * Instead, we push it into that event thread and destruct |
| 93 | + * it there */ |
| 94 | + if (ORTE_PROC_IS_APP) { |
| 95 | + opal_event_t ev; |
| 96 | + active = true; |
| 97 | + opal_event_set(orte_event_base, &ev, -1, |
| 98 | + OPAL_EV_WRITE, cleanup, (void*)&active); |
| 99 | + opal_event_set_priority(&ev, ORTE_ERROR_PRI); |
| 100 | + opal_event_active(&ev, OPAL_EV_WRITE, 1); |
| 101 | + ORTE_WAIT_FOR_COMPLETION(active); |
| 102 | + } else { |
| 103 | + /* we can call the destruct directly */ |
| 104 | + cleanup(0, 0, NULL); |
| 105 | + } |
83 | 106 |
|
84 | 107 | OPAL_TIMING_REPORT(orte_rml_base.timing, &tm_rml); |
85 | 108 |
|
|
0 commit comments