aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-22 21:39:23 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-12-22 21:54:43 +0200
commit67a64a6a7809c183516740696e15ab88f82d7ef0 (patch)
treeb58f30a8cee98bac7c9f4bc8236c86eefdadb4ef /src/wydawca.h
parent2c28190e77ce38b6437a2be8337680f77f58d37a (diff)
downloadwydawca-67a64a6a7809c183516740696e15ab88f82d7ef0.tar.gz
wydawca-67a64a6a7809c183516740696e15ab88f82d7ef0.tar.bz2
Implement inotify support.
* configure.ac: New option --with-inotify. Bye default, use inotify if it is present. * src/watcher.c: New file. Implements inotify watcher. * src/Makefile.am [COND_INOTIFY] (wydawca_SOURCES): Add watcher.c * src/diskio.c (dir_get_path): New function. * src/job.c (job) <spool>: Remove const qualifier. All uses changed. (inotify_spool): New pseudo-spool. (fake_spool): Remove static qualifier. (wydawca_scanner): Support for inotify spools. * src/net.c (open_listener): Don't exit if the listener address is not set. (wydawca_listener): Listen on the listener socket and on the inotify descriptor. If none is set, bail out. * src/process.c (for_each_spool) (file_info_cleanup) (spool_cwd_add_new_file,spool_add_new_file): New functions. (scan_spool_unlocked): Use spool_cwd_add_new_file. Don't initialize dictionaries here: it will be done in spool_commit_triplets. (spool_open_dictionaries): New function. (close_dictionaries): Rename to spool_close_dictionaries. Clear dict_inited. * src/triplet.c (hash_triplet_compare): Compare spools as well. (register_file): Likewise. (triplet_lookup): New function. (check_triplet_state): New argument: noauth. All uses updated. (enumerate_triplets): Rename to spool_commit_triplets. Call spool_open_dictionaries. (count_processable_triplets,triplet_remove_file): New functions. * src/verify.c (verify_directive_file): New argument: noauth. All uses updated. * src/vtab.c (reg): Initialize get_path member. (get_path): New function. * src/wydawca.c (main): Set print_version_hook. * src/wydawca.h (virt_tab) <get_path>: New method. (spool) <dict_inited>: New member. (fake_spool, inotify_spool): New externs. (spool_add_new_file, spool_cwd_add_new_file) (spool_open_dictionaries, spool_close_dictionaries) (for_each_spool, count_processable_triplets) (triplet_remove_file, get_path): New protos. (enumerate_triplets): Rename to spool_commit_triplets. (verify_directive_file): Take two arguments.
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index 5de1f3e..722fc9b 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -202,12 +202,13 @@ struct file_triplet
#define TRIPLET_GID(t) ((t)->file[file_directive].sb.st_gid)
struct virt_tab
{
+ const char *(*get_path) (struct spool *sp);
int (*test_url) (mu_url_t url, grecs_locus_t *loc);
int (*move_file) (struct file_triplet *trp, enum file_type file_id);
int (*archive_file) (struct file_triplet *trp, const char *file_name);
int (*symlink_file) (struct file_triplet *trp,
const char *wanted_src,
const char *wanted_dst);
@@ -226,12 +227,13 @@ struct spool
const char *dest_dir; /* Directory part of the above */
struct virt_tab vtab; /* Virtual method table */
time_t file_sweep_time; /* Remove invalid/unprocessed files
after this amount of time */
struct dictionary *dictionary[dictionary_count];
+ int dict_inited;
struct archive_descr archive; /* Archivation data */
struct notification *notification;
char *check_script;
};
#define ASGN_SPOOL(spool, trp, faction) \
@@ -369,12 +371,15 @@ extern char *wydawca_gpg_homedir;
extern char *default_check_script;
extern char *temp_homedir;
extern unsigned min_directive_version;
extern unsigned max_directive_version;
+extern struct spool fake_spool;
+extern struct spool inotify_spool;
+
#define UPDATE_STATS(what) \
do \
{ \
if (what >= MAX_STAT) abort(); \
wydawca_stat[what]++; \
} \
@@ -406,25 +411,37 @@ enum exec_result
};
enum exec_result wydawca_exec (int argc, const char **argv, int *retcode);
/* Directory scanning and registering */
-int scan_spool (const struct spool *spool, int uc, uid_t *uv);
+int scan_spool (struct spool *spool, int uc, uid_t *uv);
int scan_all_spools (int, uid_t *);
void spool_create_timers (void);
+int spool_add_new_file (const struct spool *spool, const char *name,
+ int uc, uid_t *uv);
+int spool_cwd_add_new_file (const struct spool *spool, const char *name,
+ int uc, uid_t *uv);
+int spool_open_dictionaries (struct spool *spool);
+void spool_close_dictionaries (struct spool *spool);
+
+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 enumerate_triplets (const struct spool *);
+void spool_commit_triplets (struct spool *);
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,
struct file_triplet *trp);
+void triplet_remove_file (struct spool *spool, const char *name);
+
/* General-purpose dictionary support */
struct dictionary *dictionary_new (enum dictionary_id id,
enum dictionary_type type);
int dictionary_init (struct dictionary *dict);
int dictionary_done (struct dictionary *dict);
void *dictionary_open (struct dictionary *dict);
@@ -439,13 +456,13 @@ int dictionary_quote_string (struct dictionary *dict, void *handle,
const char *input, char **poutput, size_t *psize);
unsigned dictionary_num_rows (struct dictionary *dict);
unsigned dictionary_num_cols (struct dictionary *dict);
/* Verification functions */
-int verify_directive_file (struct file_triplet *trp);
+int verify_directive_file (struct file_triplet *trp, int noath);
int verify_directive_signature (struct file_triplet *trp);
int verify_detached_signature (struct file_triplet *trp);
int fill_project_name (struct file_triplet *trp);
struct uploader_info *uploader_find_frp (struct uploader_info *list,
const char *frp);
@@ -482,27 +499,25 @@ int assert_string_arg (grecs_locus_t *, enum grecs_callback_command,
const grecs_value_t *);
/* vtab.c */
int url_to_vtab (mu_url_t url, struct virt_tab *vtab);
-int
-move_file (struct file_triplet *trp, enum file_type file_id);
-int
-archive_file (struct file_triplet *trp, const char *file_name);
-int
-symlink_file (struct file_triplet *trp,
- const char *wanted_src, const char *wanted_dst);
-int
-rmsymlink_file (struct file_triplet *trp, const char *file_name);
+const char *get_path (struct spool *sp);
+int move_file (struct file_triplet *trp, enum file_type file_id);
+int archive_file (struct file_triplet *trp, const char *file_name);
+int symlink_file (struct file_triplet *trp,
+ const char *wanted_src, const char *wanted_dst);
+int rmsymlink_file (struct file_triplet *trp, const char *file_name);
/* diskio.c */
char *concat_dir (const char *base, const char *name, size_t *pbaselen);
int copy_file (const char *file, const char *dst_file);
+const char *dir_get_path (struct spool *sp);
int dir_test_url (mu_url_t url, grecs_locus_t *locus);
int dir_move_file (struct file_triplet *trp, enum file_type file_id);
int dir_archive_file (struct file_triplet *trp, const char *reldir);
int dir_symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst);
int dir_rmsymlink_file (struct file_triplet *trp, const char *file_name);
@@ -535,13 +550,13 @@ void report_init (void);
void report_add (const char *fmt, ...);
void report_finish (void);
extern char *report_string;
/* job.c */
-void schedule_job (const struct spool *spool, uid_t uid);
+void schedule_job (struct spool *spool, uid_t uid);
void job_init (void);
void job_queue_runner (void);
/* profile.c */
void check_pidfile (void);
@@ -585,6 +600,14 @@ void txtacc_grow (struct txtacc *acc, const char *buf, size_t size);
{ \
char __ch = c; \
txtacc_grow (acc, &__ch, 1); \
} \
while (0)
char *txtacc_finish (struct txtacc *acc, int steal);
+
+#ifdef WITH_INOTIFY
+int watcher_init (void);
+int watcher_run (int);
+#else
+# define watcher_init() -1
+# define watcher_run(c)
+#endif

Return to:

Send suggestions and report system problems to the System administrator.