redmine

Continuing the last commit

... ... @@ -17,10 +17,11 @@ INC := $(shell pkg-config --cflags glib-2.0) $(INC)
INSTDIR = $(DESTDIR)$(PREFIX)
objs=\
sync.o\
cluster.o\
main.o\
output.o\
fileutils.o\
sync.o\
malloc.o
binary=clsync
... ...
... ... @@ -28,6 +28,9 @@ by "lsyncd" project ("https://github.com/axkibe/lsyncd"). So I called it
"clsync", that should be interpreted as "lsync, but on c" due to "lsyncd" that
written on "LUA" and may be used for the same purposes.
UPD: Also I was have to add somekind of clustering support. It's multicast
notifing subsystem to prevent loops on bidirection syncing. So "clsync" also
can be interpreted as "cluster live sync". ;)
2. Motivation
-------------
... ...
... ... @@ -17,12 +17,26 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common.h"
#include "cluster.h"
#include "output.h"
#include "malloc.h"
int cluster_init() {
int cluster_init(options_t *options_p) {
return 0;
}
int cluster_deinit(options_t *options_p) {
return 0;
}
int cluster_send(options_t *options_p, indexes_t *indexes_p) {
return 0;
}
int cluster_deinit() {
int cluster_recv(options_t *options_p, indexes_t *indexes_p) {
return 0;
}
... ...
... ... @@ -17,6 +17,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
extern int cluster_init();
extern int cluster_deinit();
extern int cluster_init(options_t *options_p);
extern int cluster_deinit(options_t *options_p);
extern int cluster_send(options_t *options_p, indexes_t *indexes_p);
extern int cluster_recv(options_t *options_p, indexes_t *indexes_p);
... ...
... ... @@ -16,5 +16,6 @@ Description: live sync tool based on inotify, written in GNU C
Clsync recursively watches for source directory and executes external
program to sync the changes. Clsync is adapted to use together with rsync.
This utility is much more lightweight than competitors and supports such
features as separate queue for big files, regex file filter and
multi-threading.
features as separate queue for big files, regex file filter,
multi-threading and multicast notifing clsync instances on another nodes
to prevent loop syncing.
... ...
... ... @@ -21,6 +21,7 @@
#include "output.h"
#include "sync.h"
#include "malloc.h"
#include "cluster.h"
#define VERSION_MAJ 0
#define VERSION_MIN 0
... ... @@ -325,6 +326,15 @@ int main(int argc, char *argv[]) {
ret = EINVAL;
}
if(options.cluster_iface == NULL) {
int _ret;
_ret = cluster_init();
if(_ret) {
printf_e("Error: Cannot initialize cluster subsystem.\n");
ret = _ret;
}
}
{
size_t size = options.watchdirlen + 2;
char *newwatchdir = xmalloc(size);
... ... @@ -409,6 +419,15 @@ int main(int argc, char *argv[]) {
if(ret == 0)
ret = sync_run(&options);
if(options.cluster_iface == NULL) {
int _ret;
_ret = cluster_deinit();
if(_ret) {
printf_e("Error: Cannot deinitialize cluster subsystem.\n");
ret = _ret;
}
}
main_cleanup(&options);
if(options.watchdirsize)
... ...