File: errmgr_default_app.c

package info (click to toggle)
openmpi 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 99,912 kB
  • ctags: 55,589
  • sloc: ansic: 525,999; f90: 18,307; makefile: 12,062; sh: 6,583; java: 6,278; asm: 3,515; cpp: 2,227; perl: 2,136; python: 1,350; lex: 734; fortran: 52; tcl: 12
file content (195 lines) | stat: -rw-r--r-- 6,049 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * Copyright (c) 2009-2011 The Trustees of Indiana University.
 *                         All rights reserved.
 *
 * Copyright (c) 2010      Cisco Systems, Inc.  All rights reserved.
 *
 * Copyright (c) 2004-2006 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2011-2013 Los Alamos National Security, LLC.
 *                         All rights reserved.
 * Copyright (c) 2015      Intel, Inc. All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "orte_config.h"

#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif  /* HAVE_UNISTD_H */
#include <string.h>

#include "opal/util/output.h"
#include "opal/dss/dss.h"
#include "opal/errhandler/opal_errhandler.h"
#include "opal/mca/pmix/pmix.h"

#include "orte/util/error_strings.h"
#include "orte/util/name_fns.h"
#include "orte/util/show_help.h"
#include "orte/runtime/orte_globals.h"
#include "orte/mca/rml/rml.h"
#include "orte/mca/odls/odls_types.h"
#include "orte/mca/state/state.h"

#include "orte/mca/errmgr/base/base.h"
#include "orte/mca/errmgr/base/errmgr_private.h"
#include "errmgr_default_app.h"

/*
 * Module functions: Global
 */
 static int init(void);
 static int finalize(void);

 static int abort_peers(orte_process_name_t *procs,
                        orte_std_cntr_t num_procs,
                        int error_code);

/******************
 * HNP module
 ******************/
 orte_errmgr_base_module_t orte_errmgr_default_app_module = {
    init,
    finalize,
    orte_errmgr_base_log,
    orte_errmgr_base_abort,
    abort_peers,
    NULL,
    NULL,
    NULL,
    orte_errmgr_base_register_migration_warning,
    orte_errmgr_base_register_error_callback,
    orte_errmgr_base_execute_error_callbacks
};

static void proc_errors(int fd, short args, void *cbdata);
static void pmix_error(int error, opal_proc_t *proc, void *cbdata)
{
    OPAL_OUTPUT_VERBOSE((1, orte_errmgr_base_framework.framework_output,
                        "%s errmgr:default_app: errhandler called",
                        ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));

    /* push it into our event base */
    ORTE_ACTIVATE_PROC_STATE(ORTE_PROC_MY_NAME, ORTE_PROC_STATE_COMM_FAILED);
}

static int myerrhandle = -1;

static void register_cbfunc(int status, int errhndler, void *cbdata)
{
    myerrhandle = errhndler;
}

static void notify_cbfunc(int status,
                          opal_list_t *procs,
                          opal_list_t *info,
                          opal_pmix_release_cbfunc_t cbfunc,
                          void *cbdata)
{
    if (NULL != cbfunc) {
        cbfunc(cbdata);
    }
    OPAL_OUTPUT_VERBOSE((1, orte_errmgr_base_framework.framework_output,
                        "%s errmgr:default_app: pmix errhandler called",
                        ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
    /* push it into our event base */
    ORTE_ACTIVATE_PROC_STATE(ORTE_PROC_MY_NAME, ORTE_PROC_STATE_COMM_FAILED);
}

/************************
 * API Definitions
 ************************/
 static int init(void)
 {
    /* setup state machine to trap proc errors */
    orte_state.add_proc_state(ORTE_PROC_STATE_ERROR, proc_errors, ORTE_ERROR_PRI);

    /* register an errhandler */
    opal_register_errhandler(pmix_error, NULL);

    /* tie the default PMIx errhandler back to us */
    opal_pmix.register_errhandler(NULL, notify_cbfunc, register_cbfunc, NULL);

    return ORTE_SUCCESS;
}

static int finalize(void)
{
    opal_deregister_errhandler();
    opal_pmix.deregister_errhandler(myerrhandle, NULL, NULL);
    return ORTE_SUCCESS;
}

static void proc_errors(int fd, short args, void *cbdata)
{
    orte_state_caddy_t *caddy = (orte_state_caddy_t*)cbdata;
    char *nodename;
    orte_error_t err;
    opal_pointer_array_t errors;

    OPAL_OUTPUT_VERBOSE((1, orte_errmgr_base_framework.framework_output,
                        "%s errmgr:default_app: proc %s state %s",
                        ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                        ORTE_NAME_PRINT(&caddy->name),
                        orte_proc_state_to_str(caddy->proc_state)));

    /*
     * if orte is trying to shutdown, just let it
     */
     if (orte_finalizing) {
        OBJ_RELEASE(caddy);
        return;
    }

    /* pass the error to the error_callbacks for processing */
    OBJ_CONSTRUCT(&errors, opal_pointer_array_t);
    opal_pointer_array_init(&errors, 1, INT_MAX, 1);
    err.errcode = caddy->proc_state;
    err.proc = caddy->name;
    opal_pointer_array_add(&errors, &err);


    if (ORTE_PROC_STATE_UNABLE_TO_SEND_MSG == caddy->proc_state) {
        /* we can't send a message - print a message */
        nodename = orte_get_proc_hostname(&caddy->name);
        orte_show_help("help-errmgr-base",
                       "undeliverable-msg",
                       true, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                       orte_process_info.nodename,
                       ORTE_NAME_PRINT(&caddy->name),
                       (NULL == nodename) ? "Unknown" : nodename);
        /* flag that we must abnormally terminate as far as the
         * RTE is concerned
         */
         orte_abnormal_term_ordered = true;
     } else if (ORTE_PROC_STATE_LIFELINE_LOST == caddy->proc_state) {
        /* we need to die, so mark us so */
        orte_abnormal_term_ordered = true;
    }

    orte_errmgr_base_execute_error_callbacks(&errors);
    OBJ_DESTRUCT(&errors);

    OBJ_RELEASE(caddy);
}

static int abort_peers(orte_process_name_t *procs,
                       orte_std_cntr_t num_procs,
                       int error_code)
{
    /* just abort */
    if (0 < opal_output_get_verbosity(orte_errmgr_base_framework.framework_output)) {
        orte_errmgr_base_abort(error_code, "%s called abort_peers",
                               ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
    } else {
        orte_errmgr_base_abort(error_code, NULL);
    }
    return ORTE_SUCCESS;
}