clsync
Loading...
Searching...
No Matches
sync.h
Go to the documentation of this file.
1/*
2 clsync - file tree sync utility based on fanotify and inotify
3
4 Copyright (C) 2013 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <glib.h> // GHashTable
21
22
28
30struct threadinfo {
32 uint32_t iteration;
35 char **argv;
36 pthread_t pthread;
41 time_t starttime;
42 time_t expiretime;
44
45 GHashTable *fpath2ei_ht; // file path -> event information
46
47 int try_n;
48
49 // for so-synchandler
50 int n;
52};
53typedef struct threadinfo threadinfo_t;
54
56 pthread_mutex_t mutex[PTHREAD_MUTEX_MAX];
57 pthread_cond_t cond [PTHREAD_MUTEX_MAX];
60 int used;
62 threadinfo_t **threadsstack; // stack of threadinfo_t to be used on thread_new()
64};
66
67
68extern int sync_run ( struct ctx *ctx );
69extern int sync_dump ( struct ctx *ctx, const char *const dest_dir );
70extern int sync_term ( int exitcode );
71extern int threads_foreach ( int ( *funct ) ( threadinfo_t *, void * ), state_t state, void *arg );
73extern time_t thread_nextexpiretime();
75(
76 int fsmon_d,
77
78 struct ctx *ctx_p,
79 struct indexes *indexes_p,
80
81 const char *path_full,
82 const char *path_rel,
83
84 stat64_t *lst_p,
85
86 eventobjtype_t objtype_old,
87 eventobjtype_t objtype_new,
88
89 uint32_t event_mask,
90 int event_wd,
91 mode_t st_mode,
92 off_t st_size,
93
94 char **path_buf_p,
95 size_t *path_buf_len_p,
96
97 struct eventinfo *evinfo
98);
99extern int sync_prequeue_unload ( struct ctx *ctx_p, struct indexes *indexes_p );
100extern const char *sync_parameter_get ( const char *variable_name, void *_dosync_arg_p );
101extern pthread_t pthread_sighandler;
102
enum eventobjtype eventobjtype_t
Definition clsync.h:37
@ PTHREAD_MUTEX_MAX
Definition common.h:156
enum state_enum state_t
Definition ctx.h:272
ctx_t * ctx_p
Definition mon_kqueue.c:85
struct stat64 stat64_t
Definition port-hacks.h:65
Definition ctx.h:315
state_t state
Definition sync.h:39
int try_n
Definition sync.h:47
GHashTable * fpath2ei_ht
Definition sync.h:45
uint32_t iteration
Definition sync.h:32
int exitcode
Definition sync.h:37
api_eventinfo_t * ei
Definition sync.h:51
int child_pid
Definition sync.h:43
int n
Definition sync.h:50
pthread_t pthread
Definition sync.h:36
int thread_num
Definition sync.h:31
time_t starttime
Definition sync.h:41
char ** argv
Definition sync.h:35
time_t expiretime
Definition sync.h:42
thread_callbackfunct_arg_t * callback_arg
Definition sync.h:34
ctx_t * ctx_p
Definition sync.h:40
thread_callbackfunct_t callback
Definition sync.h:33
int errcode
Definition sync.h:38
threadinfo_t ** threadsstack
Definition sync.h:62
int allocated
Definition sync.h:59
threadinfo_t * threads
Definition sync.h:61
pthread_mutex_t mutex[PTHREAD_MUTEX_MAX]
Definition sync.h:56
int used
Definition sync.h:60
int stacklen
Definition sync.h:63
char mutex_init
Definition sync.h:58
pthread_cond_t cond[PTHREAD_MUTEX_MAX]
Definition sync.h:57
volatile int exitcode
Definition sync.c:547
int sync_term(int exitcode)
Definition sync.c:3991
pthread_t pthread_sighandler
Definition sync.c:59
int(* thread_callbackfunct_t)(ctx_t *ctx_p, thread_callbackfunct_arg_t *arg_p)
Definition sync.h:29
int threads_foreach(int(*funct)(threadinfo_t *, void *), state_t state, void *arg)
const char * sync_parameter_get(const char *variable_name, void *_dosync_arg_p)
Definition sync.c:1548
int sync_prequeue_unload(struct ctx *ctx_p, struct indexes *indexes_p)
Definition sync.c:2564
int sync_dump(struct ctx *ctx, const char *const dest_dir)
Definition sync.c:3773
threadsinfo_t * thread_info()
Definition sync.c:190
int sync_prequeue_loadmark(int fsmon_d, struct ctx *ctx_p, struct indexes *indexes_p, const char *path_full, const char *path_rel, stat64_t *lst_p, eventobjtype_t objtype_old, eventobjtype_t objtype_new, uint32_t event_mask, int event_wd, mode_t st_mode, off_t st_size, char **path_buf_p, size_t *path_buf_len_p, struct eventinfo *evinfo)
Definition sync.c:2143
int sync_run(struct ctx *ctx)
Definition sync.c:3998
time_t thread_nextexpiretime()