mirror of
https://github.com/transmission/transmission
synced 2024-12-24 00:34:04 +00:00
(trunk daemon) #3158 "Possible crash when using inotify" -- fixed in trunk for 2.00
This commit is contained in:
parent
717a1788c6
commit
a0bc78a6dd
1 changed files with 17 additions and 5 deletions
|
@ -74,12 +74,20 @@ watchdir_new_impl( dtr_watchdir * w )
|
|||
int i;
|
||||
DIR * odir;
|
||||
w->inotify_fd = inotify_init( );
|
||||
tr_inf( "Using inotify to watch directory \"%s\"", w->dir );
|
||||
i = inotify_add_watch( w->inotify_fd, w->dir, DTR_INOTIFY_MASK );
|
||||
|
||||
if( w->inotify_fd < 0 )
|
||||
{
|
||||
i = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_inf( "Using inotify to watch directory \"%s\"", w->dir );
|
||||
i = inotify_add_watch( w->inotify_fd, w->dir, DTR_INOTIFY_MASK );
|
||||
}
|
||||
|
||||
if( i < 0 )
|
||||
{
|
||||
tr_err( "Unable to watch \"%s\": %s", w->dir, strerror (errno) );
|
||||
tr_err( "Unable to watch \"%s\": %s", w->dir, strerror( errno ) );
|
||||
}
|
||||
else if(( odir = opendir( w->dir )))
|
||||
{
|
||||
|
@ -105,8 +113,12 @@ watchdir_new_impl( dtr_watchdir * w )
|
|||
static void
|
||||
watchdir_free_impl( dtr_watchdir * w )
|
||||
{
|
||||
inotify_rm_watch( w->inotify_fd, DTR_INOTIFY_MASK );
|
||||
close( w->inotify_fd );
|
||||
if( w->inotify_fd >= 0 )
|
||||
{
|
||||
inotify_rm_watch( w->inotify_fd, DTR_INOTIFY_MASK );
|
||||
|
||||
close( w->inotify_fd );
|
||||
}
|
||||
}
|
||||
static void
|
||||
watchdir_update_impl( dtr_watchdir * w )
|
||||
|
|
Loading…
Reference in a new issue