Changeset 10504


Ignore:
Timestamp:
Apr 21, 2010, 1:31:23 AM (8 years ago)
Author:
charles
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/watch.c

    r10390 r10504  
    7575    DIR * odir;
    7676    w->inotify_fd = inotify_init( );
    77     tr_inf( "Using inotify to watch directory \"%s\"", w->dir );
    78     i = inotify_add_watch( w->inotify_fd, w->dir, DTR_INOTIFY_MASK );
     77
     78    if( w->inotify_fd < 0 )
     79    {
     80        i = -1;
     81    }
     82    else
     83    {
     84        tr_inf( "Using inotify to watch directory \"%s\"", w->dir );
     85        i = inotify_add_watch( w->inotify_fd, w->dir, DTR_INOTIFY_MASK );
     86    }
    7987
    8088    if( i < 0 )
    8189    {
    82         tr_err( "Unable to watch \"%s\": %s", w->dir, strerror (errno) );
     90        tr_err( "Unable to watch \"%s\": %s", w->dir, strerror( errno ) );
    8391    }
    8492    else if(( odir = opendir( w->dir )))
     
    106114watchdir_free_impl( dtr_watchdir * w )
    107115{
    108     inotify_rm_watch( w->inotify_fd, DTR_INOTIFY_MASK );
    109     close( w->inotify_fd );
     116    if( w->inotify_fd >= 0 )
     117    {
     118        inotify_rm_watch( w->inotify_fd, DTR_INOTIFY_MASK );
     119
     120        close( w->inotify_fd );
     121    }
    110122}
    111123static void
Note: See TracChangeset for help on using the changeset viewer.