Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/cli/cli-report.c | 11 +++--------
src/gui-wizard-gtk/wizard.c | 24 ++++++++++++------------
src/include/internal_libreport.h | 2 ++
src/plugins/ureport.c | 6 +++---
4 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
index 3923d60..c1d1401 100644
--- a/src/cli/cli-report.c
+++ b/src/cli/cli-report.c
@@ -466,7 +466,6 @@ static void ask_for_missing_settings(const char *event_name)
/*** Event running ***/
struct logging_state {
- bool saw_THANKYOU;
bool output_was_produced;
};
@@ -476,10 +475,9 @@ static char *do_log(char *log_line, void *param)
return log_line;
}
-static char *do_log_and_check_for_THANKYOU(char *log_line, void *param)
+static char *do_log2(char *log_line, void *param)
{
struct logging_state *l_state = param;
- l_state->saw_THANKYOU |= (strcmp("THANKYOU", log_line) == 0);
l_state->output_was_produced |= (log_line[0] != '\0');
return do_log(log_line, param);
}
@@ -754,7 +752,7 @@ int select_and_run_one_event(const char *dump_dir_name, const char
*pfx, int int
* 3. Performs review of problem data if event requires review.
* 4. Runs events commands.
* 5. Terminates a chain run if any event from the chain requires termination
- * (prints THANKYOU to stdout in the current implementation)
+ * (i.e. if it existed with EXIT_STOP_EVENT_RUN).
* 6. Terminates a chain run if any error occurs.
* 7. Continues with processing of next event.
*/
@@ -763,13 +761,12 @@ int run_event_chain(const char *dump_dir_name, GList *chain, int
interactive)
struct logging_state l_state;
struct run_event_state *run_state = new_run_event_state();
- run_state->logging_callback = do_log_and_check_for_THANKYOU;
+ run_state->logging_callback = do_log2;
run_state->logging_param = &l_state;
int retval = 0;
for (GList *eitem = chain; eitem; eitem = g_list_next(eitem))
{
- l_state.saw_THANKYOU = 0;
l_state.output_was_produced = 0;
const char *event_name = eitem->data;
retval = interactive
@@ -796,8 +793,6 @@ int run_event_chain(const char *dump_dir_name, GList *chain, int
interactive)
}
if (retval != 0)
break;
- if (l_state.saw_THANKYOU)
- break;
}
free_run_event_state(run_state);
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index b9f69a4..00f1f20 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1561,17 +1561,7 @@ static void run_event_gtk_error(const char *error_line, void
*param)
static char *run_event_gtk_logging(char *log_line, void *param)
{
struct analyze_event_data *evd = (struct analyze_event_data *)param;
-
- if (strcmp(log_line, "THANKYOU") == 0)
- {
- VERB1 log("Received a request for termination of processing of event chain.
(Request: '%s')", log_line);
- terminate_event_chain();
- if (!g_expert_mode)
- evd->success_msg = _("Processing finished.");
- }
- else
- update_command_run_log(log_line, evd);
-
+ update_command_run_log(log_line, evd);
return log_line;
}
@@ -1725,6 +1715,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition
condition, g
struct analyze_event_data *evd = data;
struct run_event_state *run_state = evd->run_state;
+ bool stop_requested = false;
int retval = consume_event_command_output(run_state, g_dump_dir_name);
if (retval < 0 && errno == EAGAIN)
@@ -1733,6 +1724,14 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition
condition, g
/* EOF/error */
+ if (WIFEXITED(run_state->process_status)
+ && WEXITSTATUS(run_state->process_status) == EXIT_STOP_EVENT_RUN
+ ) {
+ retval = 0;
+ run_state->process_status = 0;
+ stop_requested = true;
+ }
+
unexport_event_config(evd->env_list);
evd->env_list = NULL;
@@ -1800,7 +1799,8 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition
condition, g
dd_close(dd);
/* Stop if exit code is not 0, or no more commands */
- if (retval != 0
+ if (stop_requested
+ || retval != 0
|| spawn_next_command_in_evd(evd) < 0
) {
VERB1 log("done running event on '%s': %d", g_dump_dir_name,
retval);
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index b7c354d..3135b4a 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -432,7 +432,9 @@ extern int logmode;
#define xfunc_error_retval libreport_xfunc_error_retval
extern int xfunc_error_retval;
+/* A few magic exit codes */
#define EXIT_CANCEL_BY_USER 69
+#define EXIT_STOP_EVENT_RUN 70
#define set_xfunc_error_retval libreport_set_xfunc_error_retval
void set_xfunc_error_retval(int retval);
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
index e45e07a..764c7aa 100644
--- a/src/plugins/ureport.c
+++ b/src/plugins/ureport.c
@@ -351,7 +351,7 @@ int main(int argc, char **argv)
}
/* -b, -a nor -r were specified - upload uReport from dump_dir */
- int ret = 1; /* return 1 by default */
+ int ret = 1; /* "failure" (for now) */
char *dest_url = concat_path_file(config.ur_url, REPORT_URL_SFX);
config.ur_url = dest_url;
@@ -379,7 +379,7 @@ int main(int argc, char **argv)
if (!response->is_error)
{
VERB1 log("is known: %s", response->value);
- ret = 0;
+ ret = 0; /* "success" */
if (response->bthash)
{
@@ -403,7 +403,7 @@ int main(int argc, char **argv)
log(_("This problem has already been reported."));
if (response->message)
log(response->message);
- log("THANKYOU");
+ ret = EXIT_STOP_EVENT_RUN;
}
}
else
--
1.8.1.4