Skip to content

Commit a525e70

Browse files
committedDec 16, 2010
Convert "opal_show_help" to be a global variable pointer.
It is statically initialized to the real back-end OPAL show_help function. During orte_show_help_init(), the variable is re-assigned with the value of the back-end ORTE show_help function (the one that does error message aggregation). Therefore, anything that calls opal_show_help() after a certain point in orte_init() will have their show_help messages be aggregated. w00t! Even code down in OPAL -- that has no knowledge of ORTE -- will have their messages aggregated. '''Double w00t!''' During orte_show_help_finalize(), we restore the original pointer value so that it something calls opal_show_help() after orte_finalize(), it'll still work properly (but it won't be aggregated). This commit was SVN r24185.
1 parent 80c1e9a commit a525e70

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed
 

‎opal/util/show_help.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ static const char *dash_line = "------------------------------------------------
4242
static int output_stream = -1;
4343
static char **search_dirs = NULL;
4444

45+
/*
46+
* Local functions
47+
*/
48+
static int opal_show_vhelp_internal(const char *filename, const char *topic,
49+
bool want_error_header, va_list arglist);
50+
static int opal_show_help_internal(const char *filename, const char *topic,
51+
bool want_error_header, ...);
52+
53+
opal_show_help_fn_t opal_show_help = opal_show_help_internal;
54+
opal_show_vhelp_fn_t opal_show_vhelp = opal_show_vhelp_internal;
55+
56+
4557
int opal_show_help_init(void)
4658
{
4759
opal_output_stream_t lds;
@@ -311,8 +323,8 @@ char *opal_show_help_string(const char *filename, const char *topic,
311323
return output;
312324
}
313325

314-
int opal_show_vhelp(const char *filename, const char *topic,
315-
bool want_error_header, va_list arglist)
326+
static int opal_show_vhelp_internal(const char *filename, const char *topic,
327+
bool want_error_header, va_list arglist)
316328
{
317329
char *output;
318330

@@ -329,8 +341,8 @@ int opal_show_vhelp(const char *filename, const char *topic,
329341
return (NULL == output) ? OPAL_ERROR : OPAL_SUCCESS;
330342
}
331343

332-
int opal_show_help(const char *filename, const char *topic,
333-
bool want_error_header, ...)
344+
static int opal_show_help_internal(const char *filename, const char *topic,
345+
bool want_error_header, ...)
334346
{
335347
va_list arglist;
336348
int rc;

‎opal/util/show_help.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,17 @@ OPAL_DECLSPEC int opal_show_help_finalize(void);
128128
* based on the topic, and displays it. If want_error_header is
129129
* true, a header and footer of asterisks are also displayed.
130130
*/
131-
OPAL_DECLSPEC int opal_show_help(const char *filename, const char *topic,
132-
bool want_error_header, ...);
131+
typedef int (*opal_show_help_fn_t)(const char *filename, const char *topic,
132+
bool want_error_header, ...);
133+
OPAL_DECLSPEC extern opal_show_help_fn_t opal_show_help;
133134

134135
/**
135136
* This function does the same thing as opal_show_help(), but accepts
136137
* a va_list form of varargs.
137138
*/
138-
OPAL_DECLSPEC int opal_show_vhelp(const char *filename, const char *topic,
139-
bool want_error_header, va_list ap);
139+
typedef int (*opal_show_vhelp_fn_t)(const char *filename, const char *topic,
140+
bool want_error_header, va_list ap);
141+
OPAL_DECLSPEC extern opal_show_vhelp_fn_t opal_show_vhelp;
140142

141143
/**
142144
* This function does the same thing as opal_show_help(), but returns

‎orte/util/show_help.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ static bool show_help_timer_set = false;
130130
static opal_event_t show_help_timer_event;
131131
static bool ready;
132132

133+
static opal_show_help_fn_t save_help = NULL;
134+
133135
static void tuple_list_item_constructor(tuple_list_item_t *obj)
134136
{
135137
obj->tli_filename = NULL;
@@ -576,14 +578,17 @@ int orte_show_help_init(void)
576578
{
577579
OPAL_OUTPUT_VERBOSE((5, orte_debug_output, "orte_show_help init"));
578580

581+
/* Show help duplicate detection */
579582
if (ready) {
580583
return ORTE_SUCCESS;
581584
}
582585
ready = true;
583586

584-
/* Show help duplicate detection */
585587
OBJ_CONSTRUCT(&abd_tuples, opal_list_t);
586588

589+
save_help = opal_show_help;
590+
opal_show_help = orte_show_help;
591+
587592
return ORTE_SUCCESS;
588593
}
589594

@@ -593,7 +598,10 @@ void orte_show_help_finalize(void)
593598
return;
594599
}
595600
ready = false;
596-
601+
602+
opal_show_help = save_help;
603+
save_help = NULL;
604+
597605
/* Shutdown show_help, showing final messages */
598606
if (ORTE_PROC_IS_HNP) {
599607
show_accumulated_duplicates(0, 0, NULL);
@@ -606,7 +614,6 @@ void orte_show_help_finalize(void)
606614
orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORTE_RML_TAG_SHOW_HELP);
607615
return;
608616
}
609-
610617
}
611618

612619
int orte_show_help(const char *filename, const char *topic,

0 commit comments

Comments
 (0)
Please sign in to comment.