aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-01-01 19:48:33 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-01-01 20:53:41 +0200
commit66775034166ac35bda383ef41213c95021b37b64 (patch)
tree5a64f2e45955acc5758977c6de0740ba34707d65 /src/wydawca.h
parentfad678ec27c7f37da83ddf3ba3a96196a962c238 (diff)
downloadwydawca-66775034166ac35bda383ef41213c95021b37b64.tar.gz
wydawca-66775034166ac35bda383ef41213c95021b37b64.tar.bz2
Avoid processing same triplet twice.release-2.2
* src/wydawca.h (file_triplet) <jq_prev,jq_next,job>: New members. (spool_commit_triplets,schedule_job): Update signature. (count_processable_triplets): Remove. (link_processable_triplets): New proto. (remove_triplet): New proto. (triplet_jq_unlink): New proto. * src/job.c (job) <triplet_list>: New member. (triplet_jq_unlink,jq_clear): New functions. (procspool): Create and stop spool timers. (wydawca_scanner): Call spool_create_timers. (schedule_job): Additional argument specifies triplets to process. Initialize job->triplet_list; (job_queue_runner): Call jq_clear. * src/net.c (handle_connection): Update call to schedule_job. * src/process.c (spool_cwd_add_new_file): Update call to spool_commit_triplets. * src/triplet.c (remove_triplet): Now extern. Takes two args. All uses updated. (spool_commit_triplets): Additional argument specifies triplets to process. (count_processable_triplets): Remove. (link_processable_triplets): New function. * src/watcher.c: Use link_processable_triplets to obtain a doubly-linked list of triplets to process. Pass it to schedule_job.
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index 3a90ea1..9e4b2be 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -170,11 +170,25 @@ struct file_triplet {
const 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 here */
+ char *blurb; /* Block of directives: directive[i] points
+ here */
char *tmp; /* Temporary storage */
size_t tmpsize; /* Size of memory allocated in tmp */
struct 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: */
struct file_triplet *prev, *next;
+ /* 2) "job queue", a list of triplets processed by the same job: */
+ struct file_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 */
size_t uploader_count;
struct uploader_info *uploader_list;
@@ -401,9 +415,9 @@ 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 *);
+void spool_commit_triplets(struct spool *, struct file_triplet *);
+struct file_triplet *link_processable_triplets(void);
size_t count_collected_triplets(void);
-size_t count_processable_triplets(void);
char *triplet_expand_param(const char *tmpl, struct file_triplet *trp);
char *triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
@@ -412,6 +426,7 @@ char *triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
void triplet_remove_file(struct spool *spool, const char *name);
time_t triplet_sweep(void);
+int remove_triplet(struct file_triplet *trp, int check);
/* General-purpose dictionary support */
struct dictionary *dictionary_new(enum dictionary_id id,
@@ -517,9 +532,10 @@ void report_finish(void);
extern char *report_string;
/* job.c */
-void schedule_job(struct spool *spool, uid_t uid);
+void schedule_job(struct spool *spool, uid_t uid, struct file_triplet *tp);
void job_init(void);
void job_queue_runner(time_t min_timeout);
+void triplet_jq_unlink(struct file_triplet *tp);
/* profile.c */
void check_pidfile(void);

Return to:

Send suggestions and report system problems to the System administrator.