diff -Nru whoopsie-0.2.76build1/data/whoopsie.path whoopsie-0.2.77/data/whoopsie.path --- whoopsie-0.2.76build1/data/whoopsie.path 1970-01-01 00:00:00.000000000 +0000 +++ whoopsie-0.2.77/data/whoopsie.path 2022-02-22 21:32:23.000000000 +0000 @@ -0,0 +1,8 @@ +[Unit] +Description=Start whoopsie on modification of the /var/crash directory + +[Path] +PathChanged=/var/crash + +[Install] +WantedBy=multi-user.target diff -Nru whoopsie-0.2.76build1/data/whoopsie.service whoopsie-0.2.77/data/whoopsie.service --- whoopsie-0.2.76build1/data/whoopsie.service 2018-04-06 17:44:14.000000000 +0000 +++ whoopsie-0.2.77/data/whoopsie.service 2022-02-22 21:32:23.000000000 +0000 @@ -1,12 +1,9 @@ [Unit] -Description=crash report submission daemon +Description=crash report submission After=network-online.target Wants=network-online.target [Service] Environment="CRASH_DB_URL=https://daisy.ubuntu.com" -ExecStart=/usr/bin/whoopsie -f -Restart=always - -[Install] -WantedBy=multi-user.target +ExecStart=/usr/bin/whoopsie -f --no-polling +Restart=no diff -Nru whoopsie-0.2.76build1/debian/changelog whoopsie-0.2.77/debian/changelog --- whoopsie-0.2.76build1/debian/changelog 2021-10-07 10:26:25.000000000 +0000 +++ whoopsie-0.2.77/debian/changelog 2022-02-22 22:37:37.000000000 +0000 @@ -1,3 +1,15 @@ +whoopsie (0.2.77) jammy; urgency=medium + + [ Olivier Gayot ] + * Added the --no-polling switch so that whoopsie can process existing files + and exit directly (LP: #1424768) + * Don't try to process files when we know we're offline. Eventually, we + would just be ignoring each report ; which would result in useless CPU and + IO usage. + * Actually move to path-based activation (LP: #1424768) + + -- Brian Murray Tue, 22 Feb 2022 14:37:37 -0800 + whoopsie (0.2.76build1) impish; urgency=medium * No-change rebuild to build packages with zstd compression. diff -Nru whoopsie-0.2.76build1/Makefile whoopsie-0.2.77/Makefile --- whoopsie-0.2.76build1/Makefile 2019-07-01 18:41:25.000000000 +0000 +++ whoopsie-0.2.77/Makefile 2022-02-22 21:32:23.000000000 +0000 @@ -64,6 +64,7 @@ install -d $(DESTDIR)/lib/systemd/system install -m644 data/whoopsie.conf $(DATA)/init install -m644 data/whoopsie.service $(DESTDIR)/lib/systemd/system + install -m644 data/whoopsie.path $(DESTDIR)/lib/systemd/system install -d $(DESTDIR)/usr/share/apport/package-hooks install -m644 data/whoopsie.py $(DESTDIR)/usr/share/apport/package-hooks install -d $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH) diff -Nru whoopsie-0.2.76build1/src/whoopsie.c whoopsie-0.2.77/src/whoopsie.c --- whoopsie-0.2.76build1/src/whoopsie.c 2021-03-06 01:02:24.000000000 +0000 +++ whoopsie-0.2.77/src/whoopsie.c 2022-02-22 21:32:23.000000000 +0000 @@ -97,9 +97,16 @@ #ifndef TEST static int assume_online = 0; + +/* + * Tells whether whoopsie will exit right after processing existing files. + */ +static int use_polling = 1; + static GOptionEntry option_entries[] = { { "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Run in the foreground", NULL }, { "assume-online", 'a', 0, G_OPTION_ARG_NONE, &assume_online, "Always assume there is a route to $CRASH_DB_URL.", NULL }, + { "no-polling", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &use_polling, "Process existing files and exit. Implies --assume-online.", NULL }, { NULL } }; #endif @@ -794,7 +801,16 @@ return success; } -gboolean +static gboolean +process_existing_files_if_online (const char* report_dir) +{ + if (online_state) { + process_existing_files (report_dir); + } + return G_SOURCE_CONTINUE; +} + +void process_existing_files (const char* report_dir) { GDir* dir = NULL; @@ -826,7 +842,7 @@ g_free (upload_file); g_free (crash_file); continue; - } else if (online_state && parse_and_upload_report (crash_file)) { + } else if (parse_and_upload_report (crash_file)) { if (!mark_handled (crash_file, last_uploaded_oopsid)) { log_msg ("Unable to mark report as seen (%s) removing it.\n", crash_file); g_unlink (crash_file); @@ -837,8 +853,6 @@ g_free (crash_file); } g_dir_close (dir); - - return G_SOURCE_CONTINUE; } void daemonize (void) @@ -1067,6 +1081,16 @@ sigaction (SIGINT, &action, NULL); } +static void +start_polling (void) +{ + g_timeout_add_seconds (PROCESS_OUTSTANDING_TIMEOUT, + (GSourceFunc) process_existing_files_if_online, (gpointer) report_dir); + + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); +} + int main (int argc, char** argv) { @@ -1077,6 +1101,18 @@ setup_signals (); parse_arguments (&argc, &argv); + if (!use_polling) { + /* + * In non polling mode, we exit after the first invocation of + * process_existing_files. + * Since we start the process with online_status already set to TRUE, + * the first invocation of process_existing_files will always ignore + * the assume_online variable. Therefore, assume_online is irrelevant + * in non polling mode. + */ + assume_online = TRUE; + } + if (!foreground) { open_log (); log_msg ("whoopsie " VERSION " starting up.\n"); @@ -1148,12 +1184,12 @@ if (!assume_online) monitor_connectivity (crash_db_url, network_changed); - process_existing_files (report_dir); - g_timeout_add_seconds (PROCESS_OUTSTANDING_TIMEOUT, - (GSourceFunc) process_existing_files, (gpointer) report_dir); + /* As long as we keep online_state to TRUE by default, this initial call + * happens unconditionally. */ + process_existing_files_if_online (report_dir); - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); + if (use_polling) + start_polling (); unmonitor_directory (monitor, check_online_then_upload); if (!assume_online) diff -Nru whoopsie-0.2.76build1/src/whoopsie.h whoopsie-0.2.77/src/whoopsie.h --- whoopsie-0.2.76build1/src/whoopsie.h 2021-03-06 01:02:24.000000000 +0000 +++ whoopsie-0.2.77/src/whoopsie.h 2022-02-22 21:32:23.000000000 +0000 @@ -25,7 +25,7 @@ gsize get_report_max_size (void); void destroy_key_and_value (gpointer key, gpointer value, gpointer user_data); void drop_privileges (GError** error); -gboolean process_existing_files (const char* report_dir); +void process_existing_files (const char* report_dir); extern char* last_uploaded_oopsid; #endif /* WHOOPSIE_H */