1 /*
2 * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
13 * Copyright (c) 2011-2013 Los Alamos National Security, LLC.
14 * All rights reserved.
15 * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
16 * Copyright (c) 2014-2015 Research Organization for Information Science
17 * and Technology (RIST). All rights reserved.
18 * $COPYRIGHT$
19 *
20 * Additional copyrights may follow
21 *
22 * $HEADER$
23 */
24
25
26 #include "orte_config.h"
27 #include "orte/constants.h"
28
29 #include <string.h>
30 #ifdef HAVE_UNISTD_H
31 #include <unistd.h>
32 #endif
33 #ifdef HAVE_SYS_TYPES_H
34 #include <sys/types.h>
35 #endif
36
37 #include "orte/mca/mca.h"
38 #include "opal/mca/base/base.h"
39
40 #include "opal/util/opal_environ.h"
41 #include "opal/util/output.h"
42
43 #include "orte/util/show_help.h"
44 #include "orte/mca/errmgr/base/base.h"
45 #include "orte/mca/errmgr/base/errmgr_private.h"
46
47 #include "orte/mca/errmgr/base/static-components.h"
48
49 /*
50 * Globals
51 */
52 orte_errmgr_base_t orte_errmgr_base = {{{0}}};
53
54 /* Public module provides a wrapper around previous functions */
55 orte_errmgr_base_module_t orte_errmgr_default_fns = {
56 .init = NULL, /* init */
57 .finalize = NULL, /* finalize */
58 .logfn = orte_errmgr_base_log,
59 .abort = orte_errmgr_base_abort,
60 .abort_peers = orte_errmgr_base_abort_peers
61 };
62 /* NOTE: ABSOLUTELY MUST initialize this
63 * struct to include the log function as it
64 * gets called even if the errmgr hasn't been
65 * opened yet due to error
66 */
67 orte_errmgr_base_module_t orte_errmgr = {
68 .logfn = orte_errmgr_base_log
69 };
70
71 static int orte_errmgr_base_close(void)
72 {
73 /* Close selected component */
74 if (NULL != orte_errmgr.finalize) {
75 orte_errmgr.finalize();
76 }
77
78 /* always leave a default set of fn pointers */
79 orte_errmgr = orte_errmgr_default_fns;
80
81 /* destruct the callback list */
82 OPAL_LIST_DESTRUCT(&orte_errmgr_base.error_cbacks);
83
84 return mca_base_framework_components_close(&orte_errmgr_base_framework, NULL);
85 }
86
87 /**
88 * * Function for finding and opening either all MCA components, or the one
89 * * that was specifically requested via a MCA parameter.
90 * */
91 static int orte_errmgr_base_open(mca_base_open_flag_t flags)
92 {
93 /* load the default fns */
94 orte_errmgr = orte_errmgr_default_fns;
95
96 /* initialize the error callback list */
97 OBJ_CONSTRUCT(&orte_errmgr_base.error_cbacks, opal_list_t);
98
99 /* Open up all available components */
100 return mca_base_framework_components_open(&orte_errmgr_base_framework, flags);
101 }
102
103 MCA_BASE_FRAMEWORK_DECLARE(orte, errmgr, "ORTE Error Manager", NULL,
104 orte_errmgr_base_open, orte_errmgr_base_close,
105 mca_errmgr_base_static_components, 0);