aboutsummaryrefslogtreecommitdiff
path: root/src/net.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-10 13:39:09 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-10 13:39:09 +0300
commit73b72a1071e8b0e152e66ebdbc3698a2ec7a0512 (patch)
tree8f1c762ac4077191f9d68fb9c15d6d9d04f57946 /src/net.c
parentbfddf0449bf95fa53c06bf58ddc42c03c6bb8afd (diff)
downloadwydawca-73b72a1071e8b0e152e66ebdbc3698a2ec7a0512.tar.gz
wydawca-73b72a1071e8b0e152e66ebdbc3698a2ec7a0512.tar.bz2
Scan configured spools before entering daemon loop.
This ensures that eventual submissions that may have occurred during daemon restarts will be duly processed. * src/wydawca.h (fake_spool, inotify_spool): Remove pseudo-spools. (dictionaries_close): New proto. (job_schedule): New proto. (job_schedule_all, job_schedule_triplet) (job_schedule_spool): New inline functions. * src/job.c (struct job): New member "type". Move spool and uid to union v. Each job can have either triplet list or (spool,uid) pair, but not both. (fake_spool, inotify_spool): Remove. New member "printable". (job_locate): Rewrite. (wydawca_scanner): Rewrite. (job_destroy): New function. (schedule_job): Remove. (job_schedule): New function. (job_printable): New function. (all functions): Use job_printable to identify jobs in diagnostic messages. * src/net.c (handle_connection): Use job_schedule_spool or job_schedule_all depending on the request. * src/process.c (dictionaries_close): New function. (scan_all_spools): Don't close dictionaries. * src/watcher.c (process_event): Initiate the job using job_schedule_triplet(). * src/wydawca.c (main): Don't allow extra arguments in daemon mode. Call scan_all_spools before entering wydawca_daemon to register existing files. Close dictionaries before closing modules.
Diffstat (limited to 'src/net.c')
-rw-r--r--src/net.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/net.c b/src/net.c
index 7ce6e89..3ba1e78 100644
--- a/src/net.c
+++ b/src/net.c
@@ -84,7 +84,7 @@ trim_crlf(char *s)
}
void
-handle_connection(FILE * in, FILE * out)
+handle_connection(FILE *in, FILE *out)
{
char *buf = NULL;
size_t buflen = 0;
@@ -125,13 +125,19 @@ handle_connection(FILE * in, FILE * out)
*p++ = 0;
while (*p && (*p == ' ' || *p == '\t'))
p++;
- } else
- p = "";
+ } else {
+ wy_log(LOG_ERR, "protocol error");
+ free(buf);
+ return;
+ }
pw = getpwnam(buf);
- if (pw)
- schedule_job(spool, pw->pw_uid, NULL);
- else
+ if (pw) {
+ if (spool)
+ job_schedule_spool(spool, pw->pw_uid);
+ else
+ job_schedule_all();
+ } else
wy_log(LOG_ERR, "no such user: %s", buf);
free(buf);
}

Return to:

Send suggestions and report system problems to the System administrator.