aboutsummaryrefslogtreecommitdiff
path: root/src/wydawca.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-16 19:54:23 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-16 20:03:29 +0300
commita6cc8f5fcbcbf4c707149940de2ee9a33220c34d (patch)
tree3b0da6ae669a58779c9f40503191e6808a60e1b9 /src/wydawca.h
parent2cc5b63b5f90d2dd9b05f50ac28e379d417f1a8c (diff)
downloadwydawca-a6cc8f5fcbcbf4c707149940de2ee9a33220c34d.tar.gz
wydawca-a6cc8f5fcbcbf4c707149940de2ee9a33220c34d.tar.bz2
Rewrite as a multi-threaded program.
* NEWS: Update. * configure.ac: Version 3.1.95 * src/Makefile.am (wydawca_SOURCES): Remove job.c (LDADD): Link with libpthread. * src/job.c: Remove. * src/config.c: Remove the wakeup-interval statement. * src/net.c (wydawca_listener): Rewrite as a thread function wy_thr_listen. * src/timer.c (timer_get): Use thread-specific storage. (timer_get_count): Remove. * src/triplet.c: Rewrite using multi-thread model. * src/wydawca.c: Likewise. * src/wydawca.h: Update. * tests/check-fail.at: Update expected output. * tests/check-notify.at: Likewise. * tests/inotify-ok.at: Likewise. * tests/inotify-rmsymlink.at: Likewise. * tests/inotify-symlink.at: Likewise. * tests/inotify-unatt00.at: Likewise. * tests/inotify-unatt01.at: Likewise. * tests/upl12f.at: Likewise. * tests/upload-dry.at: Likewise. `
Diffstat (limited to 'src/wydawca.h')
-rw-r--r--src/wydawca.h63
1 files changed, 23 insertions, 40 deletions
diff --git a/src/wydawca.h b/src/wydawca.h
index 6cc71f1..476f77c 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -44,6 +44,7 @@
#include <fnmatch.h>
#include <regex.h>
#include <gpgme.h>
+#include <pthread.h>
#include <mailutils/types.h>
#include <mailutils/errno.h>
@@ -187,7 +188,7 @@ struct wy_triplet {
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;
- struct job *job;
+ struct triplet_list *list;
/* User data */
struct wy_user *uploader_list;
struct wy_user *uploader;
@@ -305,7 +306,6 @@ extern int syslog_include_prio; /* Syslog priority indication */
extern time_t file_sweep_time; /* Unlink stale file after this amount of time
*/
extern char *tar_command_name; /* Name of the tar command */
-extern unsigned wydawca_stat[WY_MAX_STAT];
extern unsigned long print_stats;
extern int archive_signatures;
@@ -324,7 +324,6 @@ enum {
};
extern int wy_mode;
-extern time_t wakeup_interval;
extern int foreground;
extern int single_process;
extern struct grecs_sockaddr listen_sockaddr;
@@ -341,11 +340,26 @@ extern int inotify_enable;
extern struct notification *default_notification;
+typedef unsigned WY_STAT_COUNTER;
+WY_STAT_COUNTER *wy_get_stat_array(void);
+
+static inline WY_STAT_COUNTER *
+wy_get_stat_slot(int what)
+{
+ return wy_get_stat_array() + what;
+}
+
+static inline WY_STAT_COUNTER
+wy_get_stat_counter(int what)
+{
+ return *wy_get_stat_slot(what);
+}
+
static inline void
increase_stat_counter(int what)
{
if (what >= WY_MAX_STAT) abort();
- wydawca_stat[what]++;
+ ++*wy_get_stat_slot(what);
}
int stat_mask_p(unsigned long mask);
@@ -394,8 +408,7 @@ char *triplet_expand_dictionary_query(struct dictionary *dict,
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 remove_triplet(struct wy_triplet *trp);
void triplet_enqueue(struct wy_triplet *trp);
void triplet_commit(struct wy_triplet *trp);
void triplet_gpgme_ctx_release(struct wy_triplet *trp);
@@ -513,45 +526,12 @@ void report_add(const char *fmt, ...);
void report_finish(void);
extern char *report_string;
-/* job.c */
-/* Wydawca job types */
-enum job_type {
- JOB_TRIPLET, /* Process a list of complete triplets */
- JOB_SPOOL, /* Scan single spool */
- JOB_ALL_SPOOLS /* Scan all spools */
-};
-
-void job_schedule(int type, void *data);
-
-static inline void
-job_schedule_all(void)
-{
- job_schedule(JOB_ALL_SPOOLS, NULL);
-}
-
-static inline void
-job_schedule_triplet(struct wy_triplet *tp)
-{
- job_schedule(JOB_TRIPLET, tp);
-}
-
-static inline void
-job_schedule_spool(struct spool *spool)
-{
- job_schedule(JOB_SPOOL, spool);
-}
-
-void job_init(void);
-void job_queue_runner(time_t min_timeout);
-void job_queue_wait(void);
-
-
/* profile.c */
void check_pidfile(void);
void remove_pidfile(void);
/* net.c */
-void wydawca_listener(void);
+void *wy_thr_listen(void *);
void trim_crlf(char *s);
#define LOCK_OK 0
@@ -583,3 +563,6 @@ int watcher_run(int);
int wy_stat_expansion(char **ret, char const *name, size_t len);
FILE *fopenat_ro(int dirfd, char const *name);
+void *wy_thr_triplet(void *ptr);
+void *wy_thr_cleaner(void *ptr);
+void wy_triplet_wait(void);

Return to:

Send suggestions and report system problems to the System administrator.