Changeset 371 for trunk/src/sh_inotify.c


Ignore:
Timestamp:
Oct 31, 2011, 9:42:22 PM (13 years ago)
Author:
katerina
Message:

Patch for ticket #265 (inotify support).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_inotify.c

    r369 r371  
    213213ssize_t sh_inotify_read(char * buffer, size_t count)
    214214{
     215  ssize_t len = -1;
     216  int     ifd = sh_inotify_getfd();
     217
     218  do {
     219    len = read (ifd, buffer, count);
     220  } while (len < 0 && (errno == EINTR || errno == EAGAIN));
     221
     222  return len;
     223}
     224
     225ssize_t sh_inotify_read_timeout(char * buffer, size_t count, int timeout)
     226{
    215227  ssize_t len;
    216228  int     ifd = sh_inotify_getfd();
    217229
    218   do {
    219     len = read (ifd, buffer, count);
    220   } while (len < 0 || errno == EINTR);
     230  len = sl_read_timeout_fd (ifd, buffer, count, timeout, SL_FALSE);
    221231
    222232  return len;
    223233}
     234
    224235
    225236static void sh_inotify_free_watch(void * item)
     
    287298    {
    288299      listcursor->curnode = listcursor->curnode->next;
    289       return listcursor->curnode->watch;
     300      if (listcursor->curnode)
     301        return listcursor->curnode->watch;
     302      else
     303        return NULL;
    290304    }
    291305
     
    512526  int ifd = sh_get_inotify_fd();
    513527
    514   extern void sh_fInotify_report_add(char * path, int class, unsigned long check_mask);
     528  extern void sh_fInotify_report_add(char * path,
     529                                     int class, unsigned long check_mask);
    515530
    516531  sh_dummy_litem = (void*) &litem;
     
    520535  SH_MUTEX_LOCK(mutex_list_dormant);
    521536 
    522   for (litem = sh_inotify_list_first(&listcursor, save); litem;
    523        litem = sh_inotify_list_next(&listcursor, save))
     537  litem = sh_inotify_list_first(&listcursor, save);
     538
     539  while (litem)
    524540    {
    525541    have_next:
     
    545561            }
    546562        }
     563      litem = sh_inotify_list_next(&listcursor, save);
    547564    }
    548565  SH_MUTEX_UNLOCK(mutex_list_dormant);
     
    725742      /* -- Blocking read on inotify file descriptor
    726743       */
    727       sh_inotify_read(buffer, sizeof(buffer));
     744      len = sh_inotify_read(buffer, sizeof(buffer));
    728745
    729746      if (len > 0)
Note: See TracChangeset for help on using the changeset viewer.