dynamic use of tosync stack.

This commit is contained in:
Axel Kittenberger 2008-11-24 18:40:44 +00:00
parent d5c65b03bd
commit 101d89610a
2 changed files with 13 additions and 13 deletions

View File

@ -39,11 +39,6 @@
#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_NORMAL 2
#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.
*/
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.
@ -537,12 +537,9 @@ bool append_tosync_watch(int watch) {
}
}
if (tosync_pos + 1 == MAX_TOSYNC) {
// TODO lsyncd does not have to fail in that case,
// it simply could resync everything.
printlogf(LOG_ERROR, "Utter fail! Tosync stack exceeded (max is %d).",
MAX_TOSYNC);
exit(LSYNCD_INTERNALFAIL);
if (tosync_pos + 1 >= tosync_size) {
tosync_size *= 2;
tosync = s_realloc(tosync, tosync_size*sizeof(int));
}
tosync[tosync_pos++] = watch;
@ -1732,6 +1729,9 @@ int main(int argc, char **argv)
dir_watch_size = 2;
dir_watches = s_calloc(dir_watch_size, sizeof(struct dir_watch));
tosync_size = 2;
tosync = s_calloc(tosync_size, sizeof(int));
// add all watches
for (i = 0; i < dir_conf_n; i++) {
printlogf(LOG_NORMAL, "watching %s", dir_confs[i].source);

View File

@ -33,7 +33,7 @@ This is a default config file template for lsyncd.
<binary filename="/usr/bin/rsync"/>
<!--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)
binary.