Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR inotify: fix fundamental error when inotify filename is re-regist…
…ered
  • Loading branch information
perexg committed Oct 21, 2015
1 parent 1dfec60 commit 6e95d6c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/dvr/dvr.h
Expand Up @@ -685,6 +685,7 @@ void dvr_inotify_init ( void );
void dvr_inotify_done ( void );
void dvr_inotify_add ( dvr_entry_t *de );
void dvr_inotify_del ( dvr_entry_t *de );
int dvr_inotify_count( void );

/**
* Cutpoints support
Expand Down
29 changes: 23 additions & 6 deletions src/dvr/dvr_inotify.c
Expand Up @@ -56,6 +56,7 @@ static int _str_cmp ( void *a, void *b )
return strcmp(((dvr_inotify_entry_t*)a)->path, ((dvr_inotify_entry_t*)b)->path);
}


/**
* Initialise threads
*/
Expand Down Expand Up @@ -107,12 +108,13 @@ void dvr_inotify_add ( dvr_entry_t *de )
dvr_inotify_entry_skel->path = dirname(path);

e = RB_INSERT_SORTED(&_inot_tree, dvr_inotify_entry_skel, link, _str_cmp);
if (!e) {
e = dvr_inotify_entry_skel;
SKEL_USED(dvr_inotify_entry_skel);
e->path = strdup(e->path);
e->fd = inotify_add_watch(_inot_fd, e->path, EVENT_MASK);
}
if (e)
return;

e = dvr_inotify_entry_skel;
SKEL_USED(dvr_inotify_entry_skel);
e->path = strdup(e->path);
e->fd = inotify_add_watch(_inot_fd, e->path, EVENT_MASK);

LIST_INSERT_HEAD(&e->entries, de, de_inotify_link);

Expand Down Expand Up @@ -151,6 +153,21 @@ void dvr_inotify_del ( dvr_entry_t *de )
}
}

/*
* return count of registered entries (for debugging)
*/
int dvr_inotify_count ( void )
{
dvr_entry_t *det = NULL;
dvr_inotify_entry_t *e;
int count = 0;
lock_assert(&global_lock);
RB_FOREACH(e, &_inot_tree, link)
LIST_FOREACH(det, &e->entries, de_inotify_link)
count++;
return count;
}

/*
* Find inotify entry
*/
Expand Down

0 comments on commit 6e95d6c

Please sign in to comment.