1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 08:43:27 +00:00

(trunk daemon) #3158 "Possible crash when using inotify" -- fixed in trunk for 2.00

This commit is contained in:
Charles Kerr 2010-04-21 01:31:23 +00:00
parent 717a1788c6
commit a0bc78a6dd

View file

@ -74,12 +74,20 @@ watchdir_new_impl( dtr_watchdir * w )
int i; int i;
DIR * odir; DIR * odir;
w->inotify_fd = inotify_init( ); 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 ) 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 ))) else if(( odir = opendir( w->dir )))
{ {
@ -105,8 +113,12 @@ watchdir_new_impl( dtr_watchdir * w )
static void static void
watchdir_free_impl( dtr_watchdir * w ) watchdir_free_impl( dtr_watchdir * w )
{ {
inotify_rm_watch( w->inotify_fd, DTR_INOTIFY_MASK ); if( w->inotify_fd >= 0 )
close( w->inotify_fd ); {
inotify_rm_watch( w->inotify_fd, DTR_INOTIFY_MASK );
close( w->inotify_fd );
}
} }
static void static void
watchdir_update_impl( dtr_watchdir * w ) watchdir_update_impl( dtr_watchdir * w )