From 83514402882c80fe6bc7ac989ca78ad3cb122464 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 May 2011 19:23:51 +0200 Subject: fix for spurious "Lock file 'DIR/.lock' is locked by process PID" message Message was caused by concurrent access by abrt-gui (refreshing the list) and wizard (running events). Signed-off-by: Denys Vlasenko --- src/gui-gtk/abrt-gtk.c | 7 +++++++ src/gui-gtk/main.c | 3 +++ src/gui-wizard-gtk/wizard.c | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui-gtk/abrt-gtk.c b/src/gui-gtk/abrt-gtk.c index dc5aa5aa..61c5c4f9 100644 --- a/src/gui-gtk/abrt-gtk.c +++ b/src/gui-gtk/abrt-gtk.c @@ -44,7 +44,14 @@ enum void add_directory_to_dirlist(const char *dirname) { + /* Silently ignore *any* errors, not only EACCES. + * We saw "lock file is locked by process PID" error + * when we raced with wizard. + */ + int sv_logmode = logmode; + logmode = 0; struct dump_dir *dd = dd_opendir(dirname, DD_OPEN_READONLY | DD_FAIL_QUIETLY_EACCES); + logmode = sv_logmode; if (!dd) return; diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c index ec2904b1..0c1bc644 100644 --- a/src/gui-gtk/main.c +++ b/src/gui-gtk/main.c @@ -219,6 +219,9 @@ int main(int argc, char **argv) unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); + char *pfx = getenv("ABRT_PROG_PREFIX"); + if (pfx && string_to_bool(pfx)) + msg_prefix = PROGNAME; if (opts & OPT_p) { msg_prefix = PROGNAME; diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index ee6c3c39..6e3bec69 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -829,9 +829,6 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g } } - /* Inform abrt-gui that it is a good idea to rescan the directory */ - kill(getppid(), SIGCHLD); - /* Stop if exit code is not 0, or no more commands */ if (retval != 0 || spawn_next_command_in_evd(evd) < 0 @@ -839,6 +836,9 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g VERB1 log("done running event on '%s': %d", g_dump_dir_name, retval); //append_to_textview(evd->tv_log, msg); + /* Inform abrt-gui that it is a good idea to rescan the directory */ + kill(getppid(), SIGCHLD); + for (;;) { if (!evd->more_events) -- cgit From 6b9950f592cc646ce01dced25cd88b2f3c46034b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 May 2011 19:57:33 +0200 Subject: abrt-gui: better list refreshing. Closes #251 Fixes "crash list in gui is not refreshed when a new crash is detected" Signed-off-by: Denys Vlasenko --- src/gui-gtk/main.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c index 0c1bc644..ee19ac8c 100644 --- a/src/gui-gtk/main.c +++ b/src/gui-gtk/main.c @@ -94,6 +94,7 @@ static void init_notify(void) else { close_on_exec_on(inotify_fd); + ndelay_on(inotify_fd); VERB1 log("Adding inotify watch to glib main loop"); channel_inotify = g_io_channel_unix_new(inotify_fd); channel_inotify_event_id = g_io_add_watch(channel_inotify, @@ -103,6 +104,7 @@ static void init_notify(void) } } +#if 0 // UNUSED static void close_notify(void) { if (inotify_fd >= 0) @@ -117,15 +119,25 @@ static void close_notify(void) //VERB1 log("Done"); } } +#endif /* Inotify handler */ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpointer ptr_unused) { - /* We don't bother reading inotify fd. We simply close and reopen it. - * This happens rarely enough to not bother making it efficient. + /* Since dump dir creation usually involves directory rename as a last step, + * we end up rescanning twice. A small wait after first inotify event + * usually allows to avoid this. */ - close_notify(); - init_notify(); + usleep(10*1000); + + /* We read inotify events, but don't analyze them */ + gchar buf[sizeof(struct inotify_event) + PATH_MAX + 64]; + gsize bytes_read; + while (g_io_channel_read(gio, buf, sizeof(buf), &bytes_read) == G_IO_ERROR_NONE + && bytes_read > 0 + ) { + continue; + } rescan_and_refresh(); @@ -257,8 +269,8 @@ int main(int argc, char **argv) xpipe(s_signal_pipe); close_on_exec_on(s_signal_pipe[0]); close_on_exec_on(s_signal_pipe[1]); - ndelay_off(s_signal_pipe[0]); - ndelay_off(s_signal_pipe[1]); + ndelay_on(s_signal_pipe[0]); + ndelay_on(s_signal_pipe[1]); signal(SIGCHLD, handle_signal); g_io_add_watch(g_io_channel_unix_new(s_signal_pipe[0]), G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL, -- cgit