Showing
13 changed files
with
128 additions
and
23 deletions
@@ -16,6 +16,9 @@ clsync_SOURCES = calc.c cluster.c error.c fileutils.c glibex.c \ | @@ -16,6 +16,9 @@ clsync_SOURCES = calc.c cluster.c error.c fileutils.c glibex.c \ | ||
16 | clsync_CFLAGS = $(AM_CFLAGS) | 16 | clsync_CFLAGS = $(AM_CFLAGS) |
17 | clsync_LDFLAGS = $(AM_LDFLAGS) | 17 | clsync_LDFLAGS = $(AM_LDFLAGS) |
18 | 18 | ||
19 | +if HAVE_PTHREAD_TIMEDJOIN_NP | ||
20 | +clsync_CFLAGS += -DTHREADING_SUPPORT | ||
21 | +endif | ||
19 | if HAVE_KQUEUE | 22 | if HAVE_KQUEUE |
20 | clsync_CFLAGS += -DKQUEUE_SUPPORT | 23 | clsync_CFLAGS += -DKQUEUE_SUPPORT |
21 | clsync_SOURCES += mon_kqueue.c mon_kqueue.h | 24 | clsync_SOURCES += mon_kqueue.c mon_kqueue.h |
@@ -41,8 +41,10 @@ | @@ -41,8 +41,10 @@ | ||
41 | uint32_t adler32_calc(const unsigned char *const data, uint32_t len) { // where data is the location of the data in physical | 41 | uint32_t adler32_calc(const unsigned char *const data, uint32_t len) { // where data is the location of the data in physical |
42 | // memory and len is the length of the data in bytes | 42 | // memory and len is the length of the data in bytes |
43 | 43 | ||
44 | +/* | ||
44 | if (len&3) | 45 | if (len&3) |
45 | warning("len [%i] & 3 == %i != 0. Wrong length (not a multiple of 4).", len, len&3); | 46 | warning("len [%i] & 3 == %i != 0. Wrong length (not a multiple of 4).", len, len&3); |
47 | +*/ | ||
46 | 48 | ||
47 | debug(70, "%p, %i", data, len); | 49 | debug(70, "%p, %i", data, len); |
48 | 50 |
@@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
46 | # endif | 46 | # endif |
47 | # endif | 47 | # endif |
48 | # ifndef DEFAULT_NOTIFYENGINE | 48 | # ifndef DEFAULT_NOTIFYENGINE |
49 | -# ifdef __FreeBSD__ | 49 | +# if __FreeBSD__ | __FreeBSD_kernel__ |
50 | # ifdef KQUEUE_SUPPORT | 50 | # ifdef KQUEUE_SUPPORT |
51 | # define DEFAULT_NOTIFYENGINE NE_KQUEUE | 51 | # define DEFAULT_NOTIFYENGINE NE_KQUEUE |
52 | # endif | 52 | # endif |
@@ -210,6 +210,9 @@ AC_CHECK_FUNC([getmntent], [HAVE_GETMNTENT=1]) | @@ -210,6 +210,9 @@ AC_CHECK_FUNC([getmntent], [HAVE_GETMNTENT=1]) | ||
210 | dnl searching for pivot_root | 210 | dnl searching for pivot_root |
211 | AC_CHECK_FUNC([pivot_root], [HAVE_PIVOTROOT=1]) | 211 | AC_CHECK_FUNC([pivot_root], [HAVE_PIVOTROOT=1]) |
212 | 212 | ||
213 | +dnl searching for pthread_timedjoin_np | ||
214 | +AC_CHECK_FUNC([pthread_timedjoin_np], [HAVE_PTHREAD_TIMEDJOIN_NP=1]) | ||
215 | + | ||
213 | dnl libcgroup check | 216 | dnl libcgroup check |
214 | AC_ARG_WITH(libcgroup, | 217 | AC_ARG_WITH(libcgroup, |
215 | AS_HELP_STRING(--with-libcgroup, | 218 | AS_HELP_STRING(--with-libcgroup, |
@@ -469,6 +472,7 @@ AM_CONDITIONAL([HAVE_UNSHARE], [test "x$HAVE_UNSHARE" != "x"]) | @@ -469,6 +472,7 @@ AM_CONDITIONAL([HAVE_UNSHARE], [test "x$HAVE_UNSHARE" != "x"]) | ||
469 | AM_CONDITIONAL([HAVE_SECCOMP], [test "x$HAVE_SECCOMP" != "x"]) | 472 | AM_CONDITIONAL([HAVE_SECCOMP], [test "x$HAVE_SECCOMP" != "x"]) |
470 | AM_CONDITIONAL([HAVE_TRE], [test "x$HAVE_TRE" != "x"]) | 473 | AM_CONDITIONAL([HAVE_TRE], [test "x$HAVE_TRE" != "x"]) |
471 | AM_CONDITIONAL([HAVE_LIBCGROUP], [test "x$HAVE_LIBCGROUP" != "x"]) | 474 | AM_CONDITIONAL([HAVE_LIBCGROUP], [test "x$HAVE_LIBCGROUP" != "x"]) |
475 | +AM_CONDITIONAL([HAVE_PTHREAD_TIMEDJOIN_NP], [test "x$HAVE_PTHREAD_TIMEDJOIN_NP" != "x"]) | ||
472 | 476 | ||
473 | AS_IF([test "$HAVE_KQUEUE" = '' -a "$HAVE_INOTIFY" = '' -a "$HAVE_FANOTIFY" = '' -a "$HAVE_BSM" = '' -a "$HAVE_GIO" = ''], | 477 | AS_IF([test "$HAVE_KQUEUE" = '' -a "$HAVE_INOTIFY" = '' -a "$HAVE_FANOTIFY" = '' -a "$HAVE_BSM" = '' -a "$HAVE_GIO" = ''], |
474 | [AC_MSG_FAILURE([At least one monitoring engine must be enabled! | 478 | [AC_MSG_FAILURE([At least one monitoring engine must be enabled! |
@@ -25,5 +25,14 @@ cat > rules <<EOF | @@ -25,5 +25,14 @@ cat > rules <<EOF | ||
25 | +*.* | 25 | +*.* |
26 | EOF | 26 | EOF |
27 | 27 | ||
28 | -sudo $(which clsync) -K example-cluster -c "$IPADDR" -M rsyncshell -w 2 -p safe -t 5 -W ./testdir/from -S ./clsync-synchandler-rsync.sh -R rules $@ | 28 | +case "$(uname -s)" in |
29 | + GNU/kFreeBSD) | ||
30 | + OPTS='' | ||
31 | + ;; | ||
32 | + *) | ||
33 | + OPTS='-p safe' | ||
34 | + ;; | ||
35 | +esac | ||
36 | + | ||
37 | +sudo $(which clsync) -K example-cluster -c "$IPADDR" -M rsyncshell -w 2 -t 5 -W ./testdir/from -S ./clsync-synchandler-rsync.sh -R rules $OPTS $@ | ||
29 | 38 |
@@ -7,5 +7,14 @@ cat > rules <<EOF | @@ -7,5 +7,14 @@ cat > rules <<EOF | ||
7 | +*.* | 7 | +*.* |
8 | EOF | 8 | EOF |
9 | 9 | ||
10 | -sudo $(which clsync) -K example-simple -M rsyncdirect -w2 -p safe -t5 -W ./testdir/from -R rules -D ./testdir/to $@ | 10 | +case "$(uname -s)" in |
11 | + GNU/kFreeBSD) | ||
12 | + OPTS='' | ||
13 | + ;; | ||
14 | + *) | ||
15 | + OPTS='-p safe' | ||
16 | + ;; | ||
17 | +esac | ||
18 | + | ||
19 | +sudo $(which clsync) -K example-simple -M rsyncdirect -w2 -t5 -W ./testdir/from -R rules -D ./testdir/to $OPTS $@ | ||
11 | 20 |
@@ -7,5 +7,14 @@ cat > rules <<EOF | @@ -7,5 +7,14 @@ cat > rules <<EOF | ||
7 | +*.* | 7 | +*.* |
8 | EOF | 8 | EOF |
9 | 9 | ||
10 | -sudo $(which clsync) -K example-rsync -l test -M rsyncshell -w2 -p safe -t5 -W ./testdir/from -S ./clsync-synchandler-rsyncshell.sh -R rules $@ | 10 | +case "$(uname -s)" in |
11 | + GNU/kFreeBSD) | ||
12 | + OPTS='' | ||
13 | + ;; | ||
14 | + *) | ||
15 | + OPTS='-p safe' | ||
16 | + ;; | ||
17 | +esac | ||
18 | + | ||
19 | +sudo $(which clsync) -K example-rsync -l test -M rsyncshell -w2 -t5 -W ./testdir/from -S ./clsync-synchandler-rsyncshell.sh -R rules $OPTS $@ | ||
11 | 20 |
@@ -54,6 +54,9 @@ int main() { | @@ -54,6 +54,9 @@ int main() { | ||
54 | #ifdef TRE_SUPPORT | 54 | #ifdef TRE_SUPPORT |
55 | "#define TRE_SUPPORT\n" | 55 | "#define TRE_SUPPORT\n" |
56 | #endif | 56 | #endif |
57 | +#ifdef THREADING_SUPPORT | ||
58 | + "#define THREADING_SUPPORT\n" | ||
59 | +#endif | ||
57 | #ifdef HL_LOCKS | 60 | #ifdef HL_LOCKS |
58 | "#define HL_LOCKS\n" | 61 | "#define HL_LOCKS\n" |
59 | #endif | 62 | #endif |
@@ -119,7 +119,9 @@ static const struct option long_options[] = | @@ -119,7 +119,9 @@ static const struct option long_options[] = | ||
119 | {"forbid-devices", optional_argument, NULL, FORBIDDEVICES}, | 119 | {"forbid-devices", optional_argument, NULL, FORBIDDEVICES}, |
120 | {"cgroup-group-name", required_argument, NULL, CG_GROUPNAME}, | 120 | {"cgroup-group-name", required_argument, NULL, CG_GROUPNAME}, |
121 | #endif | 121 | #endif |
122 | +#ifdef THREADING_SUPPORT | ||
122 | {"threading", required_argument, NULL, THREADING}, | 123 | {"threading", required_argument, NULL, THREADING}, |
124 | +#endif | ||
123 | {"retries", required_argument, NULL, RETRIES}, | 125 | {"retries", required_argument, NULL, RETRIES}, |
124 | {"ignore-failures", optional_argument, NULL, IGNOREFAILURES}, | 126 | {"ignore-failures", optional_argument, NULL, IGNOREFAILURES}, |
125 | {"exit-on-sync-skipping",optional_argument, NULL, EXITONSYNCSKIP}, | 127 | {"exit-on-sync-skipping",optional_argument, NULL, EXITONSYNCSKIP}, |
@@ -307,12 +309,14 @@ static char *const socketauth[] = { | @@ -307,12 +309,14 @@ static char *const socketauth[] = { | ||
307 | NULL | 309 | NULL |
308 | }; | 310 | }; |
309 | 311 | ||
312 | +#ifdef THREADING_SUPPORT | ||
310 | static char *const threading_modes[] = { | 313 | static char *const threading_modes[] = { |
311 | [PM_OFF] = "off", | 314 | [PM_OFF] = "off", |
312 | [PM_SAFE] = "safe", | 315 | [PM_SAFE] = "safe", |
313 | [PM_FULL] = "full", | 316 | [PM_FULL] = "full", |
314 | NULL | 317 | NULL |
315 | }; | 318 | }; |
319 | +#endif | ||
316 | 320 | ||
317 | #ifdef CAPABILITIES_SUPPORT | 321 | #ifdef CAPABILITIES_SUPPORT |
318 | static char *const splitting_modes[] = { | 322 | static char *const splitting_modes[] = { |
@@ -537,6 +541,9 @@ int version() { | @@ -537,6 +541,9 @@ int version() { | ||
537 | #ifdef TRE_SUPPORT | 541 | #ifdef TRE_SUPPORT |
538 | " -DTRE_SUPPORT" | 542 | " -DTRE_SUPPORT" |
539 | #endif | 543 | #endif |
544 | +#ifdef THREADING_SUPPORT | ||
545 | + " -DTHREADING_SUPPORT" | ||
546 | +#endif | ||
540 | #ifdef HL_LOCKS | 547 | #ifdef HL_LOCKS |
541 | " -DHL_LOCKS" | 548 | " -DHL_LOCKS" |
542 | #endif | 549 | #endif |
@@ -1302,6 +1309,7 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour | @@ -1302,6 +1309,7 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour | ||
1302 | case RETRIES: | 1309 | case RETRIES: |
1303 | ctx_p->retries = (unsigned int)xstrtol(arg, &ret); | 1310 | ctx_p->retries = (unsigned int)xstrtol(arg, &ret); |
1304 | break; | 1311 | break; |
1312 | +#ifdef THREADING_SUPPORT | ||
1305 | case THREADING: { | 1313 | case THREADING: { |
1306 | char *value, *arg_orig = arg; | 1314 | char *value, *arg_orig = arg; |
1307 | 1315 | ||
@@ -1320,6 +1328,7 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour | @@ -1320,6 +1328,7 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour | ||
1320 | 1328 | ||
1321 | break; | 1329 | break; |
1322 | } | 1330 | } |
1331 | +#endif | ||
1323 | case OUTPUT_METHOD: { | 1332 | case OUTPUT_METHOD: { |
1324 | char *value, *arg_orig = arg; | 1333 | char *value, *arg_orig = arg; |
1325 | 1334 | ||
@@ -1891,18 +1900,18 @@ int ctx_check(ctx_t *ctx_p) { | @@ -1891,18 +1900,18 @@ int ctx_check(ctx_t *ctx_p) { | ||
1891 | # endif | 1900 | # endif |
1892 | #endif | 1901 | #endif |
1893 | 1902 | ||
1894 | -#ifdef VERYPARANOID | ||
1895 | - if ((ctx_p->retries != 1) && ctx_p->flags[THREADING]) { | ||
1896 | - ret = errno = EINVAL; | ||
1897 | - error("\"--retries\" values should be equal to \"1\" for this \"--threading\" value."); | ||
1898 | - } | ||
1899 | -#endif | ||
1900 | - | ||
1901 | if (ctx_p->flags[STANDBYFILE] && (ctx_p->flags[MODE] == MODE_SIMPLE)) { | 1903 | if (ctx_p->flags[STANDBYFILE] && (ctx_p->flags[MODE] == MODE_SIMPLE)) { |
1902 | ret = errno = EINVAL; | 1904 | ret = errno = EINVAL; |
1903 | error("Sorry but option \"--standby-file\" cannot be used in mode \"simple\", yet."); | 1905 | error("Sorry but option \"--standby-file\" cannot be used in mode \"simple\", yet."); |
1904 | } | 1906 | } |
1905 | 1907 | ||
1908 | +#ifdef THREADING_SUPPORT | ||
1909 | +# ifdef VERYPARANOID | ||
1910 | + if ((ctx_p->retries != 1) && ctx_p->flags[THREADING]) { | ||
1911 | + ret = errno = EINVAL; | ||
1912 | + error("\"--retries\" values should be equal to \"1\" for this \"--threading\" value."); | ||
1913 | + } | ||
1914 | +# endif | ||
1906 | if (ctx_p->flags[THREADING] && ctx_p->flags[ONLYINITSYNC]) { | 1915 | if (ctx_p->flags[THREADING] && ctx_p->flags[ONLYINITSYNC]) { |
1907 | ret = errno = EINVAL; | 1916 | ret = errno = EINVAL; |
1908 | error("Conflicting options: This value of \"--threading\" cannot be used in conjunction with \"--only-initialsync\"."); | 1917 | error("Conflicting options: This value of \"--threading\" cannot be used in conjunction with \"--only-initialsync\"."); |
@@ -1924,6 +1933,7 @@ int ctx_check(ctx_t *ctx_p) { | @@ -1924,6 +1933,7 @@ int ctx_check(ctx_t *ctx_p) { | ||
1924 | ret = errno = EINVAL; | 1933 | ret = errno = EINVAL; |
1925 | error("Conflicting options: This value of \"--threading\" cannot be used in conjunction with \"--splitting=thread\"."); | 1934 | error("Conflicting options: This value of \"--threading\" cannot be used in conjunction with \"--splitting=thread\"."); |
1926 | } | 1935 | } |
1936 | +#endif | ||
1927 | if (ctx_p->flags[SKIPINITSYNC] && ctx_p->flags[EXITONNOEVENTS]) { | 1937 | if (ctx_p->flags[SKIPINITSYNC] && ctx_p->flags[EXITONNOEVENTS]) { |
1928 | ret = errno = EINVAL; | 1938 | ret = errno = EINVAL; |
1929 | error("Conflicting options: \"--skip-initialsync\" and \"--exit-on-no-events\" cannot be used together."); | 1939 | error("Conflicting options: \"--skip-initialsync\" and \"--exit-on-no-events\" cannot be used together."); |
@@ -17,7 +17,6 @@ | @@ -17,7 +17,6 @@ | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | - | ||
21 | #ifndef __PORT_HACKS_H | 20 | #ifndef __PORT_HACKS_H |
22 | #define __PORT_HACKS_H | 21 | #define __PORT_HACKS_H |
23 | 22 | ||
@@ -28,17 +27,14 @@ | @@ -28,17 +27,14 @@ | ||
28 | #include <sys/types.h> | 27 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
30 | 29 | ||
31 | -#ifndef __FreeBSD__ | 30 | +#if __FreeBSD__ || __FreeBSD_kernel__ |
32 | - typedef struct stat64 stat64_t; | 31 | +# include <sys/syslimits.h> |
33 | -#endif | ||
34 | - | ||
35 | -#ifdef __FreeBSD__ | ||
36 | 32 | ||
37 | # define O_PATH 0 | 33 | # define O_PATH 0 |
38 | 34 | ||
39 | - typedef struct stat stat64_t; | ||
40 | # include <pthread.h> | 35 | # include <pthread.h> |
41 | 36 | ||
37 | +# ifdef THREADING_SUPPORT | ||
42 | static inline int pthread_tryjoin_np(pthread_t thread, void **retval) { | 38 | static inline int pthread_tryjoin_np(pthread_t thread, void **retval) { |
43 | struct timespec abstime; | 39 | struct timespec abstime; |
44 | int rc; | 40 | int rc; |
@@ -55,11 +51,19 @@ | @@ -55,11 +51,19 @@ | ||
55 | 51 | ||
56 | return rc; | 52 | return rc; |
57 | } | 53 | } |
54 | +# endif | ||
58 | 55 | ||
56 | +# ifndef __USE_LARGEFILE64 | ||
57 | + typedef struct stat stat64_t; | ||
59 | static inline int lstat64(const char *pathname, struct stat *buf) { | 58 | static inline int lstat64(const char *pathname, struct stat *buf) { |
60 | return lstat(pathname, buf); | 59 | return lstat(pathname, buf); |
61 | } | 60 | } |
61 | +# else | ||
62 | + typedef struct stat64 stat64_t; | ||
63 | +# endif | ||
62 | 64 | ||
65 | +#else | ||
66 | + typedef struct stat64 stat64_t; | ||
63 | #endif | 67 | #endif |
64 | 68 | ||
65 | #ifdef CLSYNC_ITSELF | 69 | #ifdef CLSYNC_ITSELF |
@@ -85,7 +85,9 @@ static inline void finish_iteration(ctx_t *ctx_p) { | @@ -85,7 +85,9 @@ static inline void finish_iteration(ctx_t *ctx_p) { | ||
85 | if (ctx_p->iteration_num < ~0) // ~0 is the max value for unsigned variables | 85 | if (ctx_p->iteration_num < ~0) // ~0 is the max value for unsigned variables |
86 | ctx_p->iteration_num++; | 86 | ctx_p->iteration_num++; |
87 | 87 | ||
88 | +#ifdef THREADING_SUPPORT | ||
88 | if (!ctx_p->flags[THREADING]) | 89 | if (!ctx_p->flags[THREADING]) |
90 | +#endif | ||
89 | setenv_iteration(ctx_p->iteration_num); | 91 | setenv_iteration(ctx_p->iteration_num); |
90 | 92 | ||
91 | debug(3, "next iteration: %u/%u", | 93 | debug(3, "next iteration: %u/%u", |
@@ -198,6 +200,7 @@ threadsinfo_t *thread_info() { // TODO: optimize this | @@ -198,6 +200,7 @@ threadsinfo_t *thread_info() { // TODO: optimize this | ||
198 | return &threadsinfo; | 200 | return &threadsinfo; |
199 | } | 201 | } |
200 | 202 | ||
203 | +#ifdef THREADING_SUPPORT | ||
201 | #define thread_info_lock() _thread_info_lock(__FUNCTION__) | 204 | #define thread_info_lock() _thread_info_lock(__FUNCTION__) |
202 | static inline threadsinfo_t *_thread_info_lock(const char *const function_name) { | 205 | static inline threadsinfo_t *_thread_info_lock(const char *const function_name) { |
203 | threadsinfo_t *threadsinfo_p = thread_info(); | 206 | threadsinfo_t *threadsinfo_p = thread_info(); |
@@ -498,6 +501,7 @@ int thread_cleanup(ctx_t *ctx_p) { | @@ -498,6 +501,7 @@ int thread_cleanup(ctx_t *ctx_p) { | ||
498 | debug(3, "done."); | 501 | debug(3, "done."); |
499 | return thread_info_unlock(0); | 502 | return thread_info_unlock(0); |
500 | } | 503 | } |
504 | +#endif | ||
501 | 505 | ||
502 | volatile state_t *state_p = NULL; | 506 | volatile state_t *state_p = NULL; |
503 | volatile int exitcode = 0; | 507 | volatile int exitcode = 0; |
@@ -549,6 +553,7 @@ int exec_argv(char **argv, int *child_pid) { | @@ -549,6 +553,7 @@ int exec_argv(char **argv, int *child_pid) { | ||
549 | return exitcode; | 553 | return exitcode; |
550 | } | 554 | } |
551 | 555 | ||
556 | +#ifdef THREADING_SUPPORT | ||
552 | static inline int thread_exit(threadinfo_t *threadinfo_p, int exitcode ) { | 557 | static inline int thread_exit(threadinfo_t *threadinfo_p, int exitcode ) { |
553 | int err=0; | 558 | int err=0; |
554 | threadinfo_p->exitcode = exitcode; | 559 | threadinfo_p->exitcode = exitcode; |
@@ -580,6 +585,7 @@ static inline int thread_exit(threadinfo_t *threadinfo_p, int exitcode ) { | @@ -580,6 +585,7 @@ static inline int thread_exit(threadinfo_t *threadinfo_p, int exitcode ) { | ||
580 | debug(3, "thread %p is sending signal to sighandler to call GC", threadinfo_p->pthread); | 585 | debug(3, "thread %p is sending signal to sighandler to call GC", threadinfo_p->pthread); |
581 | return pthread_kill(pthread_sighandler, SIGUSR_THREAD_GC); | 586 | return pthread_kill(pthread_sighandler, SIGUSR_THREAD_GC); |
582 | } | 587 | } |
588 | +#endif | ||
583 | 589 | ||
584 | static inline void so_call_sync_finished(int n, api_eventinfo_t *ei) { | 590 | static inline void so_call_sync_finished(int n, api_eventinfo_t *ei) { |
585 | int i = 0; | 591 | int i = 0; |
@@ -602,6 +608,7 @@ static inline void so_call_sync_finished(int n, api_eventinfo_t *ei) { | @@ -602,6 +608,7 @@ static inline void so_call_sync_finished(int n, api_eventinfo_t *ei) { | ||
602 | return; | 608 | return; |
603 | } | 609 | } |
604 | 610 | ||
611 | +#ifdef THREADING_SUPPORT | ||
605 | int so_call_sync_thread(threadinfo_t *threadinfo_p) { | 612 | int so_call_sync_thread(threadinfo_t *threadinfo_p) { |
606 | debug(3, "thread_num == %i; threadinfo_p == %p; i_p->pthread %p; thread %p", | 613 | debug(3, "thread_num == %i; threadinfo_p == %p; i_p->pthread %p; thread %p", |
607 | threadinfo_p->thread_num, threadinfo_p, threadinfo_p->pthread, pthread_self()); | 614 | threadinfo_p->thread_num, threadinfo_p, threadinfo_p->pthread, pthread_self()); |
@@ -642,11 +649,14 @@ int so_call_sync_thread(threadinfo_t *threadinfo_p) { | @@ -642,11 +649,14 @@ int so_call_sync_thread(threadinfo_t *threadinfo_p) { | ||
642 | 649 | ||
643 | return rc; | 650 | return rc; |
644 | } | 651 | } |
652 | +#endif | ||
645 | 653 | ||
646 | static inline int so_call_sync(ctx_t *ctx_p, indexes_t *indexes_p, int n, api_eventinfo_t *ei) { | 654 | static inline int so_call_sync(ctx_t *ctx_p, indexes_t *indexes_p, int n, api_eventinfo_t *ei) { |
647 | debug(2, "n == %i", n); | 655 | debug(2, "n == %i", n); |
648 | 656 | ||
657 | +#ifdef THREADING_SUPPORT | ||
649 | if (!SHOULD_THREAD(ctx_p)) { | 658 | if (!SHOULD_THREAD(ctx_p)) { |
659 | +#endif | ||
650 | int rc=0, ret=0, err=0; | 660 | int rc=0, ret=0, err=0; |
651 | int try_n=0, try_again; | 661 | int try_n=0, try_again; |
652 | state_t status = STATE_UNKNOWN; | 662 | state_t status = STATE_UNKNOWN; |
@@ -691,6 +701,7 @@ static inline int so_call_sync(ctx_t *ctx_p, indexes_t *indexes_p, int n, api_ev | @@ -691,6 +701,7 @@ static inline int so_call_sync(ctx_t *ctx_p, indexes_t *indexes_p, int n, api_ev | ||
691 | 701 | ||
692 | so_call_sync_finished(n, ei); | 702 | so_call_sync_finished(n, ei); |
693 | return ret; | 703 | return ret; |
704 | +#ifdef THREADING_SUPPORT | ||
694 | } | 705 | } |
695 | 706 | ||
696 | threadinfo_t *threadinfo_p = thread_new(); | 707 | threadinfo_t *threadinfo_p = thread_new(); |
@@ -716,7 +727,7 @@ static inline int so_call_sync(ctx_t *ctx_p, indexes_t *indexes_p, int n, api_ev | @@ -716,7 +727,7 @@ static inline int so_call_sync(ctx_t *ctx_p, indexes_t *indexes_p, int n, api_ev | ||
716 | } | 727 | } |
717 | debug(3, "thread %p", threadinfo_p->pthread); | 728 | debug(3, "thread %p", threadinfo_p->pthread); |
718 | return 0; | 729 | return 0; |
719 | - | 730 | +#endif |
720 | } | 731 | } |
721 | 732 | ||
722 | static inline int so_call_rsync_finished(ctx_t *ctx_p, const char *inclistfile, const char *exclistfile) { | 733 | static inline int so_call_rsync_finished(ctx_t *ctx_p, const char *inclistfile, const char *exclistfile) { |
@@ -747,6 +758,7 @@ static inline int so_call_rsync_finished(ctx_t *ctx_p, const char *inclistfile, | @@ -747,6 +758,7 @@ static inline int so_call_rsync_finished(ctx_t *ctx_p, const char *inclistfile, | ||
747 | return ret0 == 0 ? ret1 : ret0; | 758 | return ret0 == 0 ? ret1 : ret0; |
748 | } | 759 | } |
749 | 760 | ||
761 | +#ifdef THREADING_SUPPORT | ||
750 | int so_call_rsync_thread(threadinfo_t *threadinfo_p) { | 762 | int so_call_rsync_thread(threadinfo_t *threadinfo_p) { |
751 | debug(3, "thread_num == %i; threadinfo_p == %p; i_p->pthread %p; thread %p", | 763 | debug(3, "thread_num == %i; threadinfo_p == %p; i_p->pthread %p; thread %p", |
752 | threadinfo_p->thread_num, threadinfo_p, threadinfo_p->pthread, pthread_self()); | 764 | threadinfo_p->thread_num, threadinfo_p, threadinfo_p->pthread, pthread_self()); |
@@ -791,11 +803,14 @@ int so_call_rsync_thread(threadinfo_t *threadinfo_p) { | @@ -791,11 +803,14 @@ int so_call_rsync_thread(threadinfo_t *threadinfo_p) { | ||
791 | 803 | ||
792 | return rc; | 804 | return rc; |
793 | } | 805 | } |
806 | +#endif | ||
794 | 807 | ||
795 | static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char *inclistfile, const char *exclistfile) { | 808 | static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char *inclistfile, const char *exclistfile) { |
796 | debug(2, "inclistfile == \"%s\"; exclistfile == \"%s\"", inclistfile, exclistfile); | 809 | debug(2, "inclistfile == \"%s\"; exclistfile == \"%s\"", inclistfile, exclistfile); |
797 | 810 | ||
811 | +#ifdef THREADING_SUPPORT | ||
798 | if (!SHOULD_THREAD(ctx_p)) { | 812 | if (!SHOULD_THREAD(ctx_p)) { |
813 | +#endif | ||
799 | debug(3, "ctx_p->handler_funct.rsync == %p", ctx_p->handler_funct.rsync); | 814 | debug(3, "ctx_p->handler_funct.rsync == %p", ctx_p->handler_funct.rsync); |
800 | 815 | ||
801 | // indexes_p->nonthreaded_syncing_fpath2ei_ht = g_hash_table_dup(indexes_p->fpath2ei_ht, g_str_hash, g_str_equal, free, free, (gpointer(*)(gpointer))strdup, eidup); | 816 | // indexes_p->nonthreaded_syncing_fpath2ei_ht = g_hash_table_dup(indexes_p->fpath2ei_ht, g_str_hash, g_str_equal, free, free, (gpointer(*)(gpointer))strdup, eidup); |
@@ -842,6 +857,7 @@ static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char * | @@ -842,6 +857,7 @@ static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char * | ||
842 | if ((ret_cleanup=so_call_rsync_finished(ctx_p, inclistfile, exclistfile))) | 857 | if ((ret_cleanup=so_call_rsync_finished(ctx_p, inclistfile, exclistfile))) |
843 | return rc ? rc : ret_cleanup; | 858 | return rc ? rc : ret_cleanup; |
844 | return rc; | 859 | return rc; |
860 | +#ifdef THREADING_SUPPORT | ||
845 | } | 861 | } |
846 | 862 | ||
847 | threadinfo_t *threadinfo_p = thread_new(); | 863 | threadinfo_t *threadinfo_p = thread_new(); |
@@ -868,13 +884,17 @@ static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char * | @@ -868,13 +884,17 @@ static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char * | ||
868 | } | 884 | } |
869 | debug(3, "thread %p", threadinfo_p->pthread); | 885 | debug(3, "thread %p", threadinfo_p->pthread); |
870 | return 0; | 886 | return 0; |
871 | - | 887 | +#endif |
872 | } | 888 | } |
873 | 889 | ||
874 | // === SYNC_EXEC() === { | 890 | // === SYNC_EXEC() === { |
875 | 891 | ||
876 | //#define SYNC_EXEC(...) (SHOULD_THREAD(ctx_p) ? sync_exec_thread : sync_exec )(__VA_ARGS__) | 892 | //#define SYNC_EXEC(...) (SHOULD_THREAD(ctx_p) ? sync_exec_thread : sync_exec )(__VA_ARGS__) |
893 | +#ifdef THREADING_SUPPORT | ||
877 | #define SYNC_EXEC_ARGV(...) (SHOULD_THREAD(ctx_p) ? sync_exec_argv_thread : sync_exec_argv)(__VA_ARGS__) | 894 | #define SYNC_EXEC_ARGV(...) (SHOULD_THREAD(ctx_p) ? sync_exec_argv_thread : sync_exec_argv)(__VA_ARGS__) |
895 | +#else | ||
896 | +#define SYNC_EXEC_ARGV(...) sync_exec_argv(__VA_ARGS__) | ||
897 | +#endif | ||
878 | 898 | ||
879 | #define debug_argv_dump(level, argv)\ | 899 | #define debug_argv_dump(level, argv)\ |
880 | if (unlikely(ctx_p->flags[DEBUG] >= level))\ | 900 | if (unlikely(ctx_p->flags[DEBUG] >= level))\ |
@@ -1083,6 +1103,7 @@ static inline int sync_exec(ctx_t *ctx_p, indexes_t *indexes_p, thread_callbackf | @@ -1083,6 +1103,7 @@ static inline int sync_exec(ctx_t *ctx_p, indexes_t *indexes_p, thread_callbackf | ||
1083 | } | 1103 | } |
1084 | */ | 1104 | */ |
1085 | 1105 | ||
1106 | +#ifdef THREADING_SUPPORT | ||
1086 | int __sync_exec_thread(threadinfo_t *threadinfo_p) { | 1107 | int __sync_exec_thread(threadinfo_t *threadinfo_p) { |
1087 | char **argv = threadinfo_p->argv; | 1108 | char **argv = threadinfo_p->argv; |
1088 | ctx_t *ctx_p = threadinfo_p->ctx_p; | 1109 | ctx_t *ctx_p = threadinfo_p->ctx_p; |
@@ -1166,6 +1187,7 @@ static inline int sync_exec_thread(ctx_t *ctx_p, indexes_t *indexes_p, thread_ca | @@ -1166,6 +1187,7 @@ static inline int sync_exec_thread(ctx_t *ctx_p, indexes_t *indexes_p, thread_ca | ||
1166 | return sync_exec_argv_thread(ctx_p, indexes_p, callback, callback_arg_p, argv); | 1187 | return sync_exec_argv_thread(ctx_p, indexes_p, callback, callback_arg_p, argv); |
1167 | } | 1188 | } |
1168 | */ | 1189 | */ |
1190 | +#endif | ||
1169 | 1191 | ||
1170 | // } === SYNC_EXEC() === | 1192 | // } === SYNC_EXEC() === |
1171 | 1193 | ||
@@ -1627,7 +1649,9 @@ int sync_initialsync(const char *path, ctx_t *ctx_p, indexes_t *indexes_p, inits | @@ -1627,7 +1649,9 @@ int sync_initialsync(const char *path, ctx_t *ctx_p, indexes_t *indexes_p, inits | ||
1627 | NULL, | 1649 | NULL, |
1628 | argv); | 1650 | argv); |
1629 | 1651 | ||
1652 | +#ifdef THREADING_SUPPORT | ||
1630 | if (!SHOULD_THREAD(ctx_p)) // If it's a thread then it will free the argv in GC. If not a thread then we have to free right here. | 1653 | if (!SHOULD_THREAD(ctx_p)) // If it's a thread then it will free the argv in GC. If not a thread then we have to free right here. |
1654 | +#endif | ||
1631 | argv_free(argv); | 1655 | argv_free(argv); |
1632 | 1656 | ||
1633 | return sync_initialsync_finish(ctx_p, initsync, ret); | 1657 | return sync_initialsync_finish(ctx_p, initsync, ret); |
@@ -1914,7 +1938,9 @@ static inline int sync_dosync_exec(ctx_t *ctx_p, indexes_t *indexes_p, const cha | @@ -1914,7 +1938,9 @@ static inline int sync_dosync_exec(ctx_t *ctx_p, indexes_t *indexes_p, const cha | ||
1914 | NULL, NULL, | 1938 | NULL, NULL, |
1915 | argv); | 1939 | argv); |
1916 | 1940 | ||
1941 | +#ifdef THREADING_SUPPORT | ||
1917 | if (!SHOULD_THREAD(ctx_p)) // If it's a thread then it will free the argv in GC. If not a thread then we have to free right here. | 1942 | if (!SHOULD_THREAD(ctx_p)) // If it's a thread then it will free the argv in GC. If not a thread then we have to free right here. |
1943 | +#endif | ||
1918 | argv_free(argv); | 1944 | argv_free(argv); |
1919 | return rc; | 1945 | return rc; |
1920 | 1946 | ||
@@ -2254,9 +2280,13 @@ int _sync_islocked(threadinfo_t *threadinfo_p, void *_fpath) { | @@ -2254,9 +2280,13 @@ int _sync_islocked(threadinfo_t *threadinfo_p, void *_fpath) { | ||
2254 | } | 2280 | } |
2255 | 2281 | ||
2256 | static inline int sync_islocked(const char *const fpath) { | 2282 | static inline int sync_islocked(const char *const fpath) { |
2283 | +#ifdef THREADING_SUPPORT | ||
2257 | int rc = threads_foreach(_sync_islocked, STATE_RUNNING, (void *)fpath); | 2284 | int rc = threads_foreach(_sync_islocked, STATE_RUNNING, (void *)fpath); |
2258 | debug(3, "<%s>: %u", fpath, rc); | 2285 | debug(3, "<%s>: %u", fpath, rc); |
2259 | return rc; | 2286 | return rc; |
2287 | +#else | ||
2288 | + return 0; | ||
2289 | +#endif | ||
2260 | } | 2290 | } |
2261 | 2291 | ||
2262 | void _sync_idle_dosync_collectedevents(gpointer fpath_gp, gpointer evinfo_gp, gpointer arg_gp) { | 2292 | void _sync_idle_dosync_collectedevents(gpointer fpath_gp, gpointer evinfo_gp, gpointer arg_gp) { |
@@ -2740,7 +2770,9 @@ int sync_idle_dosync_collectedevents_commitpart(struct dosync_arg *dosync_arg_p) | @@ -2740,7 +2770,9 @@ int sync_idle_dosync_collectedevents_commitpart(struct dosync_arg *dosync_arg_p) | ||
2740 | callback_arg_p, | 2770 | callback_arg_p, |
2741 | argv); | 2771 | argv); |
2742 | 2772 | ||
2773 | +#ifdef THREADING_SUPPORT | ||
2743 | if (!SHOULD_THREAD(ctx_p)) // If it's a thread then it will free the argv in GC. If not a thread then we have to free right here. | 2774 | if (!SHOULD_THREAD(ctx_p)) // If it's a thread then it will free the argv in GC. If not a thread then we have to free right here. |
2775 | +#endif | ||
2744 | argv_free(argv); | 2776 | argv_free(argv); |
2745 | return rc; | 2777 | return rc; |
2746 | } | 2778 | } |
@@ -3009,11 +3041,14 @@ int apievinfo2rsynclist(indexes_t *indexes_p, FILE *listfile, int n, api_eventin | @@ -3009,11 +3041,14 @@ int apievinfo2rsynclist(indexes_t *indexes_p, FILE *listfile, int n, api_eventin | ||
3009 | } | 3041 | } |
3010 | 3042 | ||
3011 | int sync_idle(ctx_t *ctx_p, indexes_t *indexes_p) { | 3043 | int sync_idle(ctx_t *ctx_p, indexes_t *indexes_p) { |
3044 | + int ret; | ||
3012 | 3045 | ||
3013 | // Collecting garbage | 3046 | // Collecting garbage |
3014 | 3047 | ||
3015 | - int ret=thread_gc(ctx_p); | 3048 | +#ifdef THREADING_SUPPORT |
3049 | + ret=thread_gc(ctx_p); | ||
3016 | if(ret) return ret; | 3050 | if(ret) return ret; |
3051 | +#endif | ||
3017 | 3052 | ||
3018 | // Checking if we can sync | 3053 | // Checking if we can sync |
3019 | 3054 | ||
@@ -3094,6 +3129,7 @@ int notify_wait(ctx_t *ctx_p, indexes_t *indexes_p) { | @@ -3094,6 +3129,7 @@ int notify_wait(ctx_t *ctx_p, indexes_t *indexes_p) { | ||
3094 | delay = MAX(delay, synctime_delay); | 3129 | delay = MAX(delay, synctime_delay); |
3095 | delay = delay > 0 ? delay : 0; | 3130 | delay = delay > 0 ? delay : 0; |
3096 | 3131 | ||
3132 | +#ifdef THREADING_SUPPORT | ||
3097 | if (ctx_p->flags[THREADING]) { | 3133 | if (ctx_p->flags[THREADING]) { |
3098 | time_t _thread_nextexpiretime = thread_nextexpiretime(); | 3134 | time_t _thread_nextexpiretime = thread_nextexpiretime(); |
3099 | debug(3, "thread_nextexpiretime == %i", _thread_nextexpiretime); | 3135 | debug(3, "thread_nextexpiretime == %i", _thread_nextexpiretime); |
@@ -3105,6 +3141,7 @@ int notify_wait(ctx_t *ctx_p, indexes_t *indexes_p) { | @@ -3105,6 +3141,7 @@ int notify_wait(ctx_t *ctx_p, indexes_t *indexes_p) { | ||
3105 | delay = MIN(delay, thread_expiredelay); | 3141 | delay = MIN(delay, thread_expiredelay); |
3106 | } | 3142 | } |
3107 | } | 3143 | } |
3144 | +#endif | ||
3108 | 3145 | ||
3109 | if ((!delay) || (ctx_p->state != STATE_RUNNING)) | 3146 | if ((!delay) || (ctx_p->state != STATE_RUNNING)) |
3110 | return 0; | 3147 | return 0; |