This source file includes following definitions.
- orte_rtc_base_assign
- orte_rtc_base_set
- orte_rtc_base_get_avail_vals
- write_help_msg
- orte_rtc_base_send_warn_show_help
- orte_rtc_base_send_error_show_help
1
2
3
4
5
6
7
8
9
10
11 #include "orte_config.h"
12
13 #include "opal/util/fd.h"
14 #include "opal/util/show_help.h"
15
16 #include "orte/mca/errmgr/errmgr.h"
17 #include "orte/mca/odls/odls_types.h"
18
19 #include "orte/mca/rtc/base/base.h"
20
21 void orte_rtc_base_assign(orte_job_t *jdata)
22 {
23 orte_rtc_base_selected_module_t *active;
24
25 OPAL_LIST_FOREACH(active, &orte_rtc_base.actives, orte_rtc_base_selected_module_t) {
26 if (NULL != active->module->assign) {
27
28 active->module->assign(jdata);
29 }
30 }
31 }
32
33 void orte_rtc_base_set(orte_job_t *jdata, orte_proc_t *proc,
34 char ***environ_copy, int error_fd)
35 {
36 orte_rtc_base_selected_module_t *active;
37
38 OPAL_LIST_FOREACH(active, &orte_rtc_base.actives, orte_rtc_base_selected_module_t) {
39 if (NULL != active->module->set) {
40
41 active->module->set(jdata, proc, environ_copy, error_fd);
42 }
43 }
44 }
45
46 void orte_rtc_base_get_avail_vals(opal_list_t *vals)
47 {
48 orte_rtc_base_selected_module_t *active;
49
50 OPAL_LIST_FOREACH(active, &orte_rtc_base.actives, orte_rtc_base_selected_module_t) {
51 if (NULL != active->module->get_available_values) {
52
53 active->module->get_available_values(vals);
54 }
55 }
56 }
57
58
59 static int write_help_msg(int fd, orte_odls_pipe_err_msg_t *msg, const char *file,
60 const char *topic, va_list ap)
61 {
62 int ret;
63 char *str;
64
65 if (NULL == file || NULL == topic) {
66 return OPAL_ERR_BAD_PARAM;
67 }
68
69 str = opal_show_help_vstring(file, topic, true, ap);
70
71 msg->file_str_len = (int) strlen(file);
72 if (msg->file_str_len > ORTE_ODLS_MAX_FILE_LEN) {
73 ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
74 return ORTE_ERR_BAD_PARAM;
75 }
76 msg->topic_str_len = (int) strlen(topic);
77 if (msg->topic_str_len > ORTE_ODLS_MAX_TOPIC_LEN) {
78 ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
79 return ORTE_ERR_BAD_PARAM;
80 }
81 msg->msg_str_len = (int) strlen(str);
82
83
84 if (OPAL_SUCCESS != (ret = opal_fd_write(fd, sizeof(*msg), msg))) {
85 goto out;
86 }
87 if (msg->file_str_len > 0 &&
88 OPAL_SUCCESS != (ret = opal_fd_write(fd, msg->file_str_len, file))) {
89 goto out;
90 }
91 if (msg->topic_str_len > 0 &&
92 OPAL_SUCCESS != (ret = opal_fd_write(fd, msg->topic_str_len, topic))) {
93 goto out;
94 }
95 if (msg->msg_str_len > 0 &&
96 OPAL_SUCCESS != (ret = opal_fd_write(fd, msg->msg_str_len, str))) {
97 goto out;
98 }
99
100 out:
101 free(str);
102 return ret;
103 }
104
105 int orte_rtc_base_send_warn_show_help(int fd, const char *file,
106 const char *topic, ...)
107 {
108 int ret;
109 va_list ap;
110 orte_odls_pipe_err_msg_t msg;
111
112 msg.fatal = false;
113 msg.exit_status = 0;
114
115
116 va_start(ap, topic);
117 ret = write_help_msg(fd, &msg, file, topic, ap);
118 va_end(ap);
119
120 return ret;
121 }
122
123 void orte_rtc_base_send_error_show_help(int fd, int exit_status,
124 const char *file, const char *topic, ...)
125 {
126 va_list ap;
127 orte_odls_pipe_err_msg_t msg;
128
129 msg.fatal = true;
130 msg.exit_status = exit_status;
131
132
133 va_start(ap, topic);
134 write_help_msg(fd, &msg, file, topic, ap);
135 va_end(ap);
136
137 exit(exit_status);
138 }
139