aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-15 08:36:13 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-15 09:15:45 +0300
commit6398c8db62d953b80fa83093a2e05f41b782f662 (patch)
tree776bc57a9e9459c52b910a3a0caa3c09b77f4c23 /src/wydawca.h
parent5b272a2b955eb426bcb6abe5be6ca4c87705f49e (diff)
downloadwydawca-6398c8db62d953b80fa83093a2e05f41b782f662.tar.gz
wydawca-6398c8db62d953b80fa83093a2e05f41b782f662.tar.bz2
When processing spool requests, handle each completed triplet in spool.
Previously wydawca used to take optional second parameter - a list of submitter UIDs. If given this list, it would process only those triplets that had been uploaded by one of these UIDs. This proved to be unnecessary. The same change is applied to the notification protocol. Only the spool name is required. The second word in the request (user name) is now silently ignored. * src/wydawca.h (struct wy_triplet): Remove const qualifier from the spool member. Remove jq_prev and jq_next pointers. (struct job_spool_id): Remove. (job_schedule_spool): Change signature. * src/job.c (struct job): Replace job_spool with a pointer to spool. (triplet_jq_unlink,jq_clear): Remove. (job_printable): Change formatting of JOB_SPOOL jobs. (job_locate): Update. (wydawca_scanner): Update. * src/net.c (handle_connection): Ignore second word in the request. * src/process.c (spool_add_new_file): Change signature. UIDs are no longer needed. Return a pointer to the affected triplet. (scan_spool): Change signature. * src/triplet.c (register_file): Return pointer to the affected triplet. (check_triplet_state): Remove the noauth parameter. (triplet_enqueue): New function. (triplet_commit): New function. (spool_commit_triplets): Remove the tplist parameter. Process all complete triplets in the spool. (link_processable_triplets): Remove. * src/verify.c (verify_directive_file): Remove the noauth parameter. * src/watcher.c (process_event): Enqueue created triplets. * src/wydawca.c (main): Don't take any UID arguments. * tests/inotify-ok.at: The version statement is printed once. Update the expected output. * tests/inotify-rmsymlink.at: Likewise. * tests/inotify-symlink.at: Likewise. * tests/inotify-unatt01.at: Likewise.
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h56
1 files changed, 14 insertions, 42 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index 784a30f..60d68c5 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -174,7 +174,7 @@ struct wy_triplet {
char *name; /* Triplet base name */
struct file_info file[FILE_TYPE_COUNT]; /* Components */
unsigned version; /* Protocol version */
- const struct spool *spool; /* Owning spool */
+ struct spool *spool; /* Owning spool */
char *relative_dir; /* Directory relative to spool->dest_dir */
char **directive; /* Decoded directive pairs (key: value\0) */
char *blurb; /* Block of directives: directive[i] points
@@ -182,19 +182,10 @@ struct wy_triplet {
char *tmp; /* Temporary storage */
size_t tmpsize; /* Size of memory allocated in tmp */
struct grecs_txtacc *acc; /* Text accumulator for string allocation */
- /* Triplets are joined in two doubly-linked lists:
- 1) a cronological list, with prev pointing to a triplet older
- than this one, and next pointing to a triplet newer than it: */
+ /* Triplets are joined in a doubly-linked list in chronological order.
+ The prev member points to a triplet older than this one, and next
+ points to a triplet newer than it: */
struct wy_triplet *prev, *next;
- /* 2) "job queue", a list of triplets processed by the same job: */
- struct wy_triplet *jq_prev, *jq_next;
- /* The job queue is used only when triplets are processed by
- the inotify watcher. In that case, the job member points to
- the job processing this request. When the job terminates, all
- requests belonging to it are removed from the table to avoid them
- being processed by subsequent jobs.
- If started as a cron job, or awoken by a TCP listener, both
- job and jq_prev, jq_next are NULL. */
struct job *job;
/* User data */
struct wy_user *uploader_list;
@@ -254,17 +245,6 @@ struct spool {
struct notification *notification;
char *check_script;
};
-
-#define ASGN_SPOOL(spool, trp, faction) do { \
- spool = (trp)->spool; \
- if (!spool) { \
- wy_log (LOG_CRIT, \
- _("INTERNAL ERROR at %s:%d: " \
- "spool not defined for %s"), \
- __FILE__, __LINE__, (trp)->name); \
- faction; \
- } \
- } while (0)
struct notification {
struct notification *next;
@@ -388,12 +368,11 @@ enum exec_result {
enum exec_result wydawca_exec(int argc, const char **argv, int *retcode);
/* Directory scanning and registering */
-int scan_spool(struct spool *spool, int uc, uid_t * uv);
-int scan_all_spools(int, uid_t *);
+int scan_spool(struct spool *spool);
+int scan_all_spools(void);
void spool_create_timers(void);
-int spool_add_new_file(const struct spool *spool, const char *name,
- int uc, uid_t * uv);
+struct wy_triplet *spool_add_new_file(struct spool *spool, const char *name);
int spool_open_dictionaries(struct spool *spool);
void spool_close_dictionaries(struct spool *spool);
@@ -402,8 +381,8 @@ void file_info_cleanup(struct file_info *finfo);
int for_each_spool(int (*fun) (struct spool *, void *), void *data);
void register_spool(struct spool *spool);
struct spool *wydawca_find_spool(const char *name);
-void register_file(struct file_info *finfo, const struct spool *spool);
-void spool_commit_triplets(struct spool *, struct wy_triplet *);
+struct wy_triplet *register_file(struct file_info *finfo, struct spool *spool);
+void spool_commit_triplets(struct spool *);
struct wy_triplet *link_processable_triplets(void);
size_t count_collected_triplets(void);
@@ -415,6 +394,8 @@ void triplet_remove_file(struct spool *spool, const char *name);
time_t triplet_sweep(void);
int remove_triplet(struct wy_triplet *trp, int check);
+void triplet_enqueue(struct wy_triplet *trp);
+void triplet_commit(struct wy_triplet *trp);
/* General-purpose dictionary support */
struct dictionary *dictionary_new(enum dictionary_id id,
@@ -439,7 +420,7 @@ unsigned dictionary_num_cols(struct dictionary *dict);
void dictionaries_close(void);
/* Verification functions */
-int verify_directive_file(struct wy_triplet *trp, int noath);
+int verify_directive_file(struct wy_triplet *trp);
int verify_directive_signature(struct wy_triplet *trp);
int verify_detached_signature(struct wy_triplet *trp);
int fill_project_name(struct wy_triplet *trp);
@@ -537,11 +518,6 @@ enum job_type {
JOB_ALL_SPOOLS /* Scan all spools */
};
-struct job_spool_id {
- struct spool *spool;
- uid_t uid;
-};
-
void job_schedule(int type, void *data);
static inline void
@@ -557,17 +533,13 @@ job_schedule_triplet(struct wy_triplet *tp)
}
static inline void
-job_schedule_spool(struct spool *spool, uid_t uid)
+job_schedule_spool(struct spool *spool)
{
- struct job_spool_id jid;
- jid.spool = spool;
- jid.uid = uid;
- job_schedule(JOB_SPOOL, &jid);
+ job_schedule(JOB_SPOOL, spool);
}
void job_init(void);
void job_queue_runner(time_t min_timeout);
-void triplet_jq_unlink(struct wy_triplet *tp);
/* profile.c */
void check_pidfile(void);

Return to:

Send suggestions and report system problems to the System administrator.