Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
clsync
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2014-05-28 16:46:03 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6e698ea87c578b571729b1b7a083dfe05249ba28
6e698ea8
1 parent
b7728948
Fixed building and running on Linux after
b7728948
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
48 deletions
cluster.c
cluster.h
configure.ac
control.h
main.c
mon_inotify.c
mon_kqueue.c
sync.c
cluster.c
View file @
6e698ea
...
...
@@ -33,6 +33,7 @@
#ifdef CLUSTER_SUPPORT
#include "common.h"
#include "indexes.h"
#include "error.h"
#include "cluster.h"
#include "sync.h"
...
...
cluster.h
View file @
6e698ea
...
...
@@ -244,7 +244,7 @@ typedef int (*cluster_recvproc_funct_t)(clustercmd_t *clustercmd_p);
// Externs
extern
int
cluster_init
(
ctx_t
*
ctx_p
,
indexes_t
*
indexes_p
);
extern
int
cluster_init
(
struct
ctx
*
ctx_p
,
struct
indexes
*
indexes_p
);
extern
int
cluster_deinit
();
extern
int
cluster_lock
(
const
char
*
fpath
);
...
...
configure.ac
View file @
6e698ea
...
...
@@ -158,12 +158,14 @@ case "$with_kqueue" in
check)
AC_CHECK_FUNC([kqueue],
[
HAVE_KQUEUE=
1
HAVE_KQUEUE=
2
],
AC_CHECK_LIB([kqueue], [kqueue],
[
LDFLAGS="${LDFLAGS} -lkqueue"
HAVE_KQUEUE=1
AC_CHECK_HEADER(sys/event.h, [
LDFLAGS="${LDFLAGS} -lkqueue"
HAVE_KQUEUE=1
])
],
)
)
...
...
@@ -171,7 +173,8 @@ case "$with_kqueue" in
native)
AC_CHECK_FUNC([kqueue],
[
HAVE_KQUEUE=1
AC_CHECK_HEADER(sys/event.h, [], [AC_MSG_FAILURE([Cannot find sys/event.h])])
HAVE_KQUEUE=2
],
[
AC_MSG_FAILURE(
...
...
@@ -182,6 +185,7 @@ case "$with_kqueue" in
lib)
AC_CHECK_LIB([kqueue], [kqueue],
[
AC_CHECK_HEADER(sys/event.h, [], [AC_MSG_FAILURE([Cannot find sys/event.h])])
LDFLAGS="${LDFLAGS} -lkqueue"
HAVE_KQUEUE=1
],
...
...
@@ -193,17 +197,18 @@ case "$with_kqueue" in
;;
esac
INOTIFY_LIBS=-linotify
case "$with_inotify" in
check)
AC_CHECK_FUNC([inotify_init],
[
HAVE_INOTIFY=
1
HAVE_INOTIFY=
2
],
AC_CHECK_LIB([inotify], [inotify_init],
[
LDFLAGS="${LDFLAGS} -linotify"
HAVE_INOTIFY=1
AC_CHECK_HEADER(sys/inotify.h, [
LDFLAGS="${LDFLAGS} -linotify"
HAVE_INOTIFY=1
])
],
)
)
...
...
@@ -211,7 +216,8 @@ case "$with_inotify" in
native)
AC_CHECK_FUNC([inotify_init],
[
HAVE_INOTIFY=1
AC_CHECK_HEADER(sys/inotify.h, [], [AC_MSG_FAILURE([Cannot find sys/inotify.h])])
HAVE_INOTIFY=2
],
[
AC_MSG_FAILURE(
...
...
@@ -222,6 +228,7 @@ case "$with_inotify" in
lib)
AC_CHECK_LIB([inotify], [inotify_init],
[
AC_CHECK_HEADER(sys/inotify.h, [], [AC_MSG_FAILURE([Cannot find sys/inotify.h])])
LDFLAGS="${LDFLAGS} -linotify"
HAVE_INOTIFY=1
],
...
...
@@ -233,17 +240,18 @@ case "$with_inotify" in
;;
esac
INOTIFY_LIBS=-lbsm
case "$with_bsm" in
check)
AC_CHECK_FUNC([au_fetch_tok],
[
HAVE_BSM=
1
HAVE_BSM=
2
],
AC_CHECK_LIB([bsm], [au_fetch_tok],
[
LDFLAGS="${LDFLAGS} -lbsm"
HAVE_BSM=1
AC_CHECK_HEADER(bsm/libbsm.h, [
LDFLAGS="${LDFLAGS} -lbsm"
HAVE_BSM=1
])
],
)
)
...
...
@@ -251,6 +259,7 @@ case "$with_bsm" in
lib)
AC_CHECK_LIB([bsm], [au_fetch_tok],
[
AC_CHECK_HEADER(bsm/libbsm.h, [], [AC_MSG_FAILURE([Cannot find bsm/libbsm.h])])
LDFLAGS="${LDFLAGS} -lbsm"
HAVE_BSM=1
],
...
...
control.h
View file @
6e698ea
...
...
@@ -20,8 +20,8 @@
#ifndef __CLSYNC_CONTROL_H
#define __CLSYNC_CONTROL_H
extern
int
control_run
(
ctx_t
*
ctx_p
);
extern
int
control_cleanup
(
ctx_t
*
ctx_p
);
extern
int
control_run
(
struct
ctx
*
ctx_p
);
extern
int
control_cleanup
(
struct
ctx
*
ctx_p
);
#endif
...
...
main.c
View file @
6e698ea
...
...
@@ -120,9 +120,12 @@ static char *const threading_modes[] = {
};
static
char
*
const
notify_engines
[]
=
{
[
NE_UNDEFINED
]
=
""
,
[
NE_INOTIFY
]
=
"inotify"
,
[
NE_KQUEUE
]
=
"kqueue"
,
[
NE_FANOTIFY
]
=
"fanotify"
,
[
NE_BSM
]
=
"bsm"
,
NULL
};
static
char
*
const
output_methods
[]
=
{
...
...
@@ -460,22 +463,19 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
}
switch
(
notifyengine
)
{
#if
n
def FANOTIFY_SUPPORT
#ifdef FANOTIFY_SUPPORT
case
NE_FANOTIFY
:
#endif
#if
n
def INOTIFY_SUPPORT
#ifdef INOTIFY_SUPPORT
case
NE_INOTIFY
:
#endif
#ifdef KQUEUE_SUPPORT
case
NE_KQUEUE
:
#endif
break
;
default:
error
(
PROGRAM
" is compiled without %s subsystem support. Recompile with option
\"
--with-%s
\"
if you're planning to use it."
,
arg_orig
,
arg_orig
);
return
EINVAL
;
default:
#ifdef VERYPARANOID
critical
(
"Internal error"
);
#endif
break
;
}
ctx_p
->
flags
[
MONITOR
]
=
notifyengine
;
...
...
mon_inotify.c
View file @
6e698ea
...
...
@@ -41,7 +41,7 @@ struct recognize_event_return {
};
static
inline
uint32_t
recognize_event
(
uint32_t
event
)
{
struct
recognize_event_return
r
=
{
0
};
struct
recognize_event_return
r
=
{
{{
0
}}
};
eventobjtype_t
type
;
int
is_created
;
...
...
mon_kqueue.c
View file @
6e698ea
...
...
@@ -175,7 +175,7 @@ int kqueue_unmark(ctx_t *ctx_p, monobj_t *obj_p) {
#ifdef VERYPARANOID
if
(
obj_p
==
NULL
)
{
errno
=
EINVAL
;
return
NULL
;
return
-
1
;
}
#endif
...
...
@@ -263,7 +263,7 @@ monobj_t *kqueue_add_watch_path(ctx_t *ctx_p, indexes_t *indexes_p, const char *
#ifdef VERYPARANOID
if
(
path
==
NULL
)
{
errno
=
EINVAL
;
return
-
1
;
return
NULL
;
}
#endif
{
...
...
@@ -328,7 +328,7 @@ int kqueue_add_watch_dir(ctx_t *ctx_p, indexes_t *indexes_p, const char *const a
struct
dirent
*
entry
;
#ifdef VERYPARANOID
if
(
path
==
NULL
)
{
if
(
acc
path
==
NULL
)
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
@@ -546,6 +546,15 @@ int kqueue_handle(ctx_t *ctx_p, indexes_t *indexes_p) {
return
count
;
}
void
btree_free
(
void
*
node_p
)
{
monobj_t
*
obj_p
=
node_p
;
free
(
obj_p
->
name
);
free
(
obj_p
);
return
;
}
int
kqueue_deinit
(
ctx_t
*
ctx_p
)
{
struct
kqueue_data
*
dat
=
ctx_p
->
fsmondata
;
...
...
@@ -559,8 +568,8 @@ int kqueue_deinit(ctx_t *ctx_p) {
twalk(dat->fd_btree, btree_close);
#endif
#if __USE_GNU
tdestroy
(
dat
->
file_btree
);
tdestroy
(
dat
->
fd_btree
);
tdestroy
(
dat
->
file_btree
,
btree_free
);
tdestroy
(
dat
->
fd_btree
,
NULL
);
#else
free
(
dat
->
file_btree
);
free
(
dat
->
fd_btree
);
...
...
sync.c
View file @
6e698ea
...
...
@@ -3483,25 +3483,6 @@ int sync_run(ctx_t *ctx_p) {
if
(
ctx_p
->
listoutdir
)
srand
(
time
(
NULL
));
#ifdef ENABLE_SOCKET
// Creating control socket
if
(
ctx_p
->
socketpath
!=
NULL
)
ret
=
control_run
(
ctx_p
);
#endif
if
(
!
ctx_p
->
flags
[
ONLYINITSYNC
])
{
// Initializing FS monitor kernel subsystem in this userspace application
if
(
sync_notify_init
(
ctx_p
))
return
errno
;
// Marking file tree for FS monitor
ret
=
sync_mark_walk
(
ctx_p
,
ctx_p
->
watchdir
,
&
indexes
);
if
(
ret
)
return
ret
;
}
{
// Preparing monitor subsystem context function pointers
switch
(
ctx_p
->
flags
[
MONITOR
])
{
...
...
@@ -3533,6 +3514,25 @@ int sync_run(ctx_t *ctx_p) {
}
}
#ifdef ENABLE_SOCKET
// Creating control socket
if
(
ctx_p
->
socketpath
!=
NULL
)
ret
=
control_run
(
ctx_p
);
#endif
if
(
!
ctx_p
->
flags
[
ONLYINITSYNC
])
{
// Initializing FS monitor kernel subsystem in this userspace application
if
(
sync_notify_init
(
ctx_p
))
return
errno
;
// Marking file tree for FS monitor
ret
=
sync_mark_walk
(
ctx_p
,
ctx_p
->
watchdir
,
&
indexes
);
if
(
ret
)
return
ret
;
}
// "Infinite" loop of processling the events
ret
=
sync_loop
(
ctx_p
,
&
indexes
);
if
(
ret
)
return
ret
;
...
...
Please
register
or
login
to post a comment