From 0e12584423cc728a865e1adfaa841bc639faba8d Mon Sep 17 00:00:00 2001 From: William Douglas Date: Fri, 22 Apr 2011 15:15:49 -0700 Subject: [PATCH] Change behavior to avoid rerunning gdb each time we try scan corefiles Signed-off-by: William Douglas --- coredump.c | 11 ++++++++++- corewatcher.h | 2 +- submit.c | 26 ++++++++++++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/coredump.c b/coredump.c index fbafdd1..f9cbe2c 100644 --- a/coredump.c +++ b/coredump.c @@ -526,6 +526,7 @@ int scan_dmesg(void __unused *unused) DIR *dir; struct dirent *entry; char path[PATH_MAX*2]; + struct oops *oq; dir = opendir("/tmp/"); if (!dir) @@ -554,15 +555,23 @@ int scan_dmesg(void __unused *unused) fprintf(stderr, "+ scanning %s...\n", core_folder); do { + skip: + memset(path, 0, PATH_MAX*2); + oq = get_oops_queue(); entry = readdir(dir); if (!entry) break; if (!strstr(entry->d_name, ".processed")) continue; sprintf(path, "%s%s", core_folder, entry->d_name); + while (oq) { + if (!(strcmp(oq->filename, path))) + goto skip; + oq = oq->next; + } fprintf(stderr, "+ Looking at %s\n", path); process_corefile(path); - } while(entry); + } while(1); closedir(dir); if (opted_in >= 2) diff --git a/corewatcher.h b/corewatcher.h index b8a634d..3b90fc1 100644 --- a/corewatcher.h +++ b/corewatcher.h @@ -57,7 +57,7 @@ extern void clear_queue(void); extern int scan_dmesg(void * unused); extern void read_config_file(char *filename); - +extern struct oops *get_oops_queue(void); extern void ask_permission(char *detail_folder); extern void dbus_ask_permission(char *detail_folder); extern void dbus_say_thanks(char *url); diff --git a/submit.c b/submit.c index f2066c1..7c8173b 100644 --- a/submit.c +++ b/submit.c @@ -62,6 +62,11 @@ static struct oops *queued_backtraces; static int newoops; static int unsubmittedoops; +struct oops *get_oops_queue(void) +{ + return queued_backtraces; +} + static unsigned int checksum(char *ptr) { unsigned int temp = 0; @@ -220,7 +225,8 @@ void submit_queue_with_url(struct oops *queue, char *wsubmit_url, char *proxy) checksums[submitted++] = oops->checksum; dbus_say_thanks(result_url); - } + } else + queue_backtrace(oops); count++; dup: @@ -243,7 +249,7 @@ void submit_queue_with_url(struct oops *queue, char *wsubmit_url, char *proxy) void submit_queue(void) { - int i, n; + int i, n, submitted = 0; struct oops *queue, *oops, *next; CURL *handle; pxProxyFactory *pf; @@ -278,6 +284,7 @@ void submit_queue(void) } if (!curl_easy_perform(handle)) { submit_queue_with_url(queue, submit_url[i], proxy); + submitted = 1; break; } for (n = 0; proxies[n]; n++) @@ -287,12 +294,15 @@ void submit_queue(void) px_proxy_factory_free(pf); - oops = queue; - while (oops) { - next = oops->next; - FREE_OOPS(oops); - oops = next; - } + if (submitted) { + oops = queue; + while (oops) { + next = oops->next; + FREE_OOPS(oops); + oops = next; + } + } else + queued_backtraces = queue; curl_easy_cleanup(handle); } -- 2.7.4