summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2009-11-22 16:43:04 (GMT)
committerChristian Pointner <equinox@helsinki.at>2009-11-22 16:43:04 (GMT)
commitb85d531c1090bae4b7d2390abb71b5b2373a513d (patch)
treeea989b337f794e0e38cc7a648cf6a413708a1b89
parentdaed3944256cc529f1908bfa8a5e5cacbe1123c8 (diff)
ignoring add request for paths already beeing watched
-rw-r--r--rhdropbox.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/rhdropbox.c b/rhdropbox.c
index 3c16ba6..5a6c2ee 100644
--- a/rhdropbox.c
+++ b/rhdropbox.c
@@ -123,12 +123,18 @@ int process_watch(int inotify_fd, read_buffer_t* buffer, watch_list_t* watch_lst
int process_cmd_add_remove(cmd_id_t cmd_id, const char* path, int fd, int inotify_fd, watch_list_t* watch_lst)
{
int wd = 0;
- if(cmd_id == ADD)
- wd = inotify_add_watch(inotify_fd, path, IN_CLOSE_WRITE | IN_DELETE_SELF | IN_MOVE_SELF | IN_ONLYDIR);
+ int tmp_fd = watch_list_find_fd(watch_lst, path);
+ if(cmd_id == ADD) {
+ if(tmp_fd < 0)
+ wd = inotify_add_watch(inotify_fd, path, IN_CLOSE_WRITE | IN_DELETE_SELF | IN_MOVE_SELF | IN_ONLYDIR);
+ else {
+ log_printf(DEBUG, "cmd_add_remove: path already in watch list");
+ return 0;
+ }
+ }
else if(cmd_id == REMOVE) {
- int fd = watch_list_find_fd(watch_lst, path);
- if(fd >= 0)
- wd = inotify_rm_watch(inotify_fd, fd);
+ if(tmp_fd >= 0)
+ wd = inotify_rm_watch(inotify_fd, tmp_fd);
else {
log_printf(ERROR, "cmd_add_remove path not found in watch list");
send_response(fd, "Error: path not found in watch list");