diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-05-02 19:57:33 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-05-02 19:57:33 +0200 |
commit | 6b9950f592cc646ce01dced25cd88b2f3c46034b (patch) | |
tree | 67070735934c9c8a28217cad3b0a9b29dcf996ec | |
parent | f06cd3a1382110566dd4a834a951a09d34eae0d8 (diff) | |
download | abrt-6b9950f592cc646ce01dced25cd88b2f3c46034b.tar.gz abrt-6b9950f592cc646ce01dced25cd88b2f3c46034b.tar.xz abrt-6b9950f592cc646ce01dced25cd88b2f3c46034b.zip |
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 <dvlasenk@redhat.com>
-rw-r--r-- | src/gui-gtk/main.c | 24 |
1 files changed, 18 insertions, 6 deletions
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, |