Skip to content

Commit

Permalink
abrtd: de-prioritize post-create event scripts
Browse files Browse the repository at this point in the history
The crash processing should not make the computer unusable. It sometimes
happens that the captured data causes abrt scripts to take an inadequate
amount of resources and the computer becomes less responsive.

This patch increases the nice value of post-create processes by 10 (I took
10 because it is the default value of command 'nice'), so those
processes will be scheduled after the more valuable processes.

Related: rhbz#1236422

Signed-off-by: Jakub Filak <jfilak@redhat.com>
  • Loading branch information
Jakub Filak committed Jul 15, 2015
1 parent 304bcca commit 7451d0f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
7 changes: 7 additions & 0 deletions doc/abrtd.txt
Expand Up @@ -36,6 +36,13 @@ OPTIONS
-p::
Add program names to log.

ENVIRONMENT
-----------
ABRT_EVENT_NICE::
'abrtd' runs its post-mortem processing with the nice value incremented by 10
in order to not take too much resources and keep the computer responsive. If
you want to adjust the increment value, use the ABRT_EVENT_NICE environment
variable.

CAVEATS
-------
Expand Down
19 changes: 18 additions & 1 deletion src/daemon/abrt-handle-event.c
Expand Up @@ -403,16 +403,18 @@ int main(int argc, char **argv)
abrt_init(argv);

const char *program_usage_string = _(
"& [-v -i] -e|--event EVENT DIR..."
"& [-v -i -n INCREMENT] -e|--event EVENT DIR..."
);

char *event_name = NULL;
int interactive = 0; /* must be _int_, OPT_BOOL expects that! */
int nice_incr = 0;

struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_STRING('e', "event" , &event_name, "EVENT", _("Run EVENT on DIR")),
OPT_BOOL('i', "interactive" , &interactive, _("Communicate directly to the user")),
OPT_INTEGER('n', "nice" , &nice_incr, _("Increment the nice value by INCREMENT")),
OPT_END()
};

Expand All @@ -423,6 +425,21 @@ int main(int argc, char **argv)

load_abrt_conf();

const char *const opt_env_nice = getenv("ABRT_EVENT_NICE");
if (opt_env_nice != NULL && opt_env_nice[0] != '\0')
{
log_debug("Using ABRT_EVENT_NICE=%s to increment the nice value", opt_env_nice);
nice_incr = xatoi(opt_env_nice);
}

if (nice_incr != 0)
{
log_debug("Incrementing the nice value by %d", nice_incr);
const int ret = nice(nice_incr);
if (ret == -1)
perror_msg_and_die("Failed to increment the nice value");
}

bool post_create = (strcmp(event_name, "post-create") == 0);
char *dump_dir_name = NULL;
while (*argv)
Expand Down
14 changes: 8 additions & 6 deletions src/daemon/abrt-server.c
Expand Up @@ -126,15 +126,17 @@ static int delete_path(const char *dump_dir_name)

static pid_t spawn_event_handler_child(const char *dump_dir_name, const char *event_name, int *fdp)
{
char *args[7];
char *args[9];
args[0] = (char *) LIBEXEC_DIR"/abrt-handle-event";
/* Do not forward ASK_* messages to parent*/
args[1] = (char *) "-i";
args[2] = (char *) "-e";
args[3] = (char *) event_name;
args[4] = (char *) "--";
args[5] = (char *) dump_dir_name;
args[6] = NULL;
args[2] = (char *) "--nice";
args[3] = (char *) "10";
args[4] = (char *) "-e";
args[5] = (char *) event_name;
args[6] = (char *) "--";
args[7] = (char *) dump_dir_name;
args[8] = NULL;

int pipeout[2];
int flags = EXECFLG_INPUT_NUL | EXECFLG_OUTPUT | EXECFLG_QUIET | EXECFLG_ERR2OUT;
Expand Down

0 comments on commit 7451d0f

Please sign in to comment.