aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-13 10:07:46 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-13 10:55:49 +0300
commita9d38e5de5cceb667bec3db15fed68f7e8d96a8b (patch)
tree3dae7f0670f5308b321cf84b5fd9501e98f5a9ba /src/wydawca.c
parenta9da878ff22f980cea3bf3102113d7f2e65f61e9 (diff)
downloadwydawca-a9d38e5de5cceb667bec3db15fed68f7e8d96a8b.tar.gz
wydawca-a9d38e5de5cceb667bec3db15fed68f7e8d96a8b.tar.bz2
Fix triplet processing in daemon mode.
* src/watcher.c (fopenat_ro): New function. * src/verify.c (fill_project_name): Use fopenat_ro. * src/gpg.c (recursive_rmdir): return silently if the directory does not exist. (verify_directive_signature): Use fopenat_ro. * src/job.c: Change state definitions from bitmask to enum. * src/triplet.c (triplet_processor): A pointer to the spool is passed in proc_data. Process only triplets with this spool. (triplet_processor): Modify accordingly. Facilitate writing tests for daemon mode. * src/wydawca.c (cron_option,daemon_mode): Remove. (wy_mode, wy_mode_option): New variables. (main): Use wy_mode to determine operating mode. * src/wydawca.h (daemon_mode): Remove extern. (wy_mode): New extern. * src/cmdline.opt: New option --daemon. * src/config.c: Change handling of the "daemon" statement. * src/net.c: Test hook: if WYDAWCA_NOTIFY_PARENT=1 send SIGUSR1 to parent after setting up the listener. * doc/wydawca.texi: Describe the --daemon option. Testsuite: 1. Place source and destination directories in the working directory for each particular test. Thus the spool cleanup function becomes unnecessary. 2. Add tests for wydawca daemon mode (inotify). * configure.ac (WY_INOTIFY): New substitution variable for use in testsuite. * tests/wyasync.c: New source. Auxiliary program to test wydawca daemon mode. * tests/wyinit.c: New source. Extract source and destination directory names from the wydawca configuration file and create missing directories. * tests/Makefile.am: Build wyasync and wyinit. (TESTSUITE_AT): Add inotify-ok.at * tests/atlocal.in (WY_INOTIFY): New variable. (wydawca_init_testdirs): Remove. (wydawca_clean_testdirs): Remove. (wydawca_config): Call wyinit to initialize spools and destinatiuon directories. (wydawca_upload): Change source directory. * tests/etc/mailstats.cfin: Put mail.out in CWD. * tests/etc/notify.cfin: Likewise. * tests/etc/wydawca.cfin: Add pidfile statement in case wydawca is run as daemon. Place all source and destination directories in CWD. * tests/testsuite.at (AT_WYDAWCA_DAEMON): New macro. * tests/inotify-ok.at: New test. * tests/check-fail.at: Update. * tests/check-notify.at: Update. * tests/check-ok.at: Update. * tests/mailstats.at: Update. * tests/notify-upl.at: Update. * tests/upl11.at: Update. * tests/upl12f.at: Update. * tests/upl12t.at: Update. * tests/upload-dry.at: Update. * tests/upload.at: Update.
Diffstat (limited to 'src/wydawca.c')
-rw-r--r--src/wydawca.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/wydawca.c b/src/wydawca.c
index 4450bac..d83ccab 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -36,13 +36,16 @@ unsigned long print_stats; /* Print final statistics output */
time_t file_sweep_time = 0;
char *tar_command_name = "tar";
int archive_signatures = 1; /* Archive sig files by default */
-int lint_mode = 0;
+
+int lint_mode;
+
+int wy_mode = WY_MODE_NORMAL;
+int wy_mode_option = -1;
+
int preprocess_only = 0;
-int cron_option = 0;
int foreground_option = -1;
int single_process_option = -1;
-int daemon_mode = 0;
int foreground;
int single_process;
time_t wakeup_interval;
@@ -353,7 +356,7 @@ main(int argc, char **argv)
wy_debug(4, (_("using GPGME version %s"), p));
if (argc) {
- if (daemon_mode) {
+ if (wy_mode == WY_MODE_DAEMON) {
wy_log(LOG_CRIT, _("extra arguments in daemon mode"));
exit(EX_UNAVAILABLE);
} else {
@@ -384,17 +387,28 @@ main(int argc, char **argv)
exit(0);
if (wy_dry_run || selected_spools())
- cron_option = 1;
- if (cron_option)
- daemon_mode = 0;
+ wy_mode_option = WY_MODE_CRON;
+ if (wy_mode_option != -1)
+ wy_mode = wy_mode_option;
if (foreground_option >= 0)
foreground = foreground_option;
if (single_process_option >= 0)
single_process = single_process_option;
- if (wy_log_to_stderr == -1)
- wy_log_to_stderr = !daemon_mode || foreground;
-
+ if (wy_log_to_stderr == -1) {
+ switch (wy_mode) {
+ case WY_MODE_NORMAL:
+ wy_log_to_stderr = 1;
+ break;
+ case WY_MODE_CRON:
+ wy_log_to_stderr = 0;
+ break;
+ case WY_MODE_DAEMON:
+ wy_log_to_stderr = foreground;
+ break;
+ }
+ }
+
grecs_log_to_stderr = wy_log_to_stderr;
if (!wy_log_to_stderr) {
openlog(wy_syslog_tag, LOG_PID, wy_log_facility);
@@ -419,7 +433,7 @@ main(int argc, char **argv)
wy_log(LOG_NOTICE, _("wydawca (%s) started"), PACKAGE_STRING);
scan_all_spools(uidc, uidv);
- if (daemon_mode)
+ if (wy_mode == WY_MODE_DAEMON)
wydawca_daemon();
else
logstats();

Return to:

Send suggestions and report system problems to the System administrator.