mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-09 09:50:28 +00:00
dynamic use of tosync stack.
This commit is contained in:
parent
d5c65b03bd
commit
101d89610a
24
lsyncd.c
24
lsyncd.c
@ -39,11 +39,6 @@
|
|||||||
|
|
||||||
#define INOTIFY_BUF_LEN (512 * (sizeof(struct inotify_event) + 16))
|
#define INOTIFY_BUF_LEN (512 * (sizeof(struct inotify_event) + 16))
|
||||||
|
|
||||||
/**
|
|
||||||
* Utterly fail if tosync list exceeds this.
|
|
||||||
*/
|
|
||||||
#define MAX_TOSYNC 1024
|
|
||||||
|
|
||||||
#define LOG_DEBUG 1
|
#define LOG_DEBUG 1
|
||||||
#define LOG_NORMAL 2
|
#define LOG_NORMAL 2
|
||||||
#define LOG_ERROR 3
|
#define LOG_ERROR 3
|
||||||
@ -258,7 +253,12 @@ int dir_conf_n = 0;
|
|||||||
/**
|
/**
|
||||||
* A stack of offset pointers to dir_watches to directories to sync.
|
* A stack of offset pointers to dir_watches to directories to sync.
|
||||||
*/
|
*/
|
||||||
int tosync[MAX_TOSYNC];
|
int *tosync = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of ints allocaetd for tosync stack
|
||||||
|
*/
|
||||||
|
int tosync_size = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pointer of the current tosync position.
|
* The pointer of the current tosync position.
|
||||||
@ -537,12 +537,9 @@ bool append_tosync_watch(int watch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tosync_pos + 1 == MAX_TOSYNC) {
|
if (tosync_pos + 1 >= tosync_size) {
|
||||||
// TODO lsyncd does not have to fail in that case,
|
tosync_size *= 2;
|
||||||
// it simply could resync everything.
|
tosync = s_realloc(tosync, tosync_size*sizeof(int));
|
||||||
printlogf(LOG_ERROR, "Utter fail! Tosync stack exceeded (max is %d).",
|
|
||||||
MAX_TOSYNC);
|
|
||||||
exit(LSYNCD_INTERNALFAIL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tosync[tosync_pos++] = watch;
|
tosync[tosync_pos++] = watch;
|
||||||
@ -1732,6 +1729,9 @@ int main(int argc, char **argv)
|
|||||||
dir_watch_size = 2;
|
dir_watch_size = 2;
|
||||||
dir_watches = s_calloc(dir_watch_size, sizeof(struct dir_watch));
|
dir_watches = s_calloc(dir_watch_size, sizeof(struct dir_watch));
|
||||||
|
|
||||||
|
tosync_size = 2;
|
||||||
|
tosync = s_calloc(tosync_size, sizeof(int));
|
||||||
|
|
||||||
// add all watches
|
// add all watches
|
||||||
for (i = 0; i < dir_conf_n; i++) {
|
for (i = 0; i < dir_conf_n; i++) {
|
||||||
printlogf(LOG_NORMAL, "watching %s", dir_confs[i].source);
|
printlogf(LOG_NORMAL, "watching %s", dir_confs[i].source);
|
||||||
|
@ -33,7 +33,7 @@ This is a default config file template for lsyncd.
|
|||||||
<binary filename="/usr/bin/rsync"/>
|
<binary filename="/usr/bin/rsync"/>
|
||||||
|
|
||||||
<!--uncomment to create a file containing pid of the daemon-->
|
<!--uncomment to create a file containing pid of the daemon-->
|
||||||
<!--pidfile filename="/tmp/pid"/-->
|
<!--pidfile filename="/var/run/lsyncd.pid"/-->
|
||||||
|
|
||||||
<!--this specifies the arguments handled to the rsync (or other)
|
<!--this specifies the arguments handled to the rsync (or other)
|
||||||
binary.
|
binary.
|
||||||
|
Loading…
Reference in New Issue
Block a user