return;
queue_backtrace(ptr);
- printf("-%s-\n", ptr);
+ fprintf(stderr, "---[start of coredump]---\n%s\n---[end of coredump]---\n", ptr);
sprintf(newfile,"%s.processed", filename);
if (do_unlink)
unlink(filename);
if (!dir)
return 1;
- printf("Scanning..\n");
+ fprintf(stderr, "+ scanning..\n");
do {
entry = readdir(dir);
if (!entry)
if (strncmp(entry->d_name, "core.", 5))
continue;
sprintf(path, "/tmp/%s", entry->d_name);
- printf("Looking at %s\n", path);
+ fprintf(stderr, "+ Looking at %s\n", path);
process_corefile(path);
} while (entry);
{ "nodaemon", 0, NULL, 'n' },
{ "debug", 0, NULL, 'd' },
{ "always", 0, NULL, 'a' },
+ { "test", 0, NULL, 't' },
{ "help", 0, NULL, 'h' },
{ 0, 0, NULL, 0 }
};
static void usage(const char *name)
{
- printf("Usage: %s [OPTIONS...]\n", name);
- printf(" -n, --nodaemon Do not daemonize, run in foreground\n");
- printf(" -d, --debug Enable debug mode\n");
- printf(" -a, --always Always send core dumps\n");
- printf(" -h, --help Display this help message\n");
+ fprintf(stderr, "Usage: %s [OPTIONS...]\n", name);
+ fprintf(stderr, " -n, --nodaemon Do not daemonize, run in foreground\n");
+ fprintf(stderr, " -d, --debug Enable debug mode\n");
+ fprintf(stderr, " -a, --always Always send core dumps\n");
+ fprintf(stderr, " -t, --test Do not send anything\n");
+ fprintf(stderr, " -h, --help Display this help message\n");
}
static DBusHandlerResult got_message(
GMainLoop *loop;
DBusError error;
int godaemon = 1;
+ int debug = 0;
/*
* Signal the kernel that we're not timing critical
switch(c) {
case 'n':
- printf("Not running as daemon\n");
+ fprintf(stderr, "+ Not running as daemon\n");
godaemon = 0;
break;
case 'd':
- printf("Starting corewatcher in debug mode\n");
- godaemon = 0;
- testmode = 1;
+ fprintf(stderr, "+ Starting corewatcher in debug mode\n");
+ debug = 1;
break;
case 'a':
- printf("Sending All report\n");
+ fprintf(stderr, "+ Sending All reports\n");
opted_in = 2;
break;
+ case 't':
+ fprintf(stderr, "+ Test mode enabled: not sending anything\n");
+ break;
case 'h':
usage(argv[0]);
return EXIT_SUCCESS;
}
if (!opted_in && !testmode) {
- fprintf(stderr, " [Inactive by user preference]\n");
+ fprintf(stderr, "+ Inactive by user preference\n");
return EXIT_SUCCESS;
}
*/
if (godaemon && daemon(0, 0)) {
- printf("corewatcher failed to daemonize.. exiting \n");
+ fprintf(stderr, "corewatcher failed to daemonize.. exiting \n");
return EXIT_FAILURE;
}
sched_yield();
dbus_connection_add_filter(bus, got_message, NULL, NULL);
}
- if (!testmode)
+ if (!debug)
sleep(20);
/* we scan dmesg before /var/log/messages; dmesg is a more accurate source normally */
dbus_bus_remove_match(bus, "type='signal',interface='org.corewatcher.submit.ping'", &error);
dbus_bus_remove_match(bus, "type='signal',interface='org.corewatcher.submit.permission'", &error);
free(submit_url);
- printf("Exiting from testmode\n");
+ fprintf(stderr, "+ Exiting from testmode\n");
return EXIT_SUCCESS;
}
while (oops) {
struct oops *next;
- printf("Submit text is:\n---[start of oops]---\n%s\n---[end of oops]---\n", oops->text);
+ fprintf(stderr, "+ Submit text is:\n---[start of oops]---\n%s\n---[end of oops]---\n", oops->text);
next = oops->next;
free(oops->text);
free(oops);
int result;
struct oops *oops;
struct oops *queue;
+ CURL *handle;
int count = 0;
memset(result_url, 0, 4096);
return;
}
+ handle = curl_easy_init();
+ curl_easy_setopt(handle, CURLOPT_URL, submit_url);
+
queue = queued_backtraces;
queued_backtraces = NULL;
barrier();
+
oops = queue;
while (oops) {
- CURL *handle;
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
struct oops *next;
- handle = curl_easy_init();
-
- printf("DEBUG SUBMIT URL is %s \n", submit_url);
- curl_easy_setopt(handle, CURLOPT_URL, submit_url);
-
/* set up the POST data */
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "backtracedata",
result = curl_easy_perform(handle);
curl_formfree(post);
- curl_easy_cleanup(handle);
next = oops->next;
free(oops->text);
free(oops);
count++;
}
+ curl_easy_cleanup(handle);
+
if (count && !testmode)
write_logfile(count);