title: FSEvents mysteriously fails to deliver events in some folders
body: <p>this is killing me, and I'm not sure I know how to approach debugging it.</p>
  
  <p>I'm using Mac FSEvents API to monitor a given folder on the file system. However, occasionally, some folders stop sending any notification events. So far, this has only happened for folders inside ~/Dropbox, and has affected just a few users of my app (and also regularly affects me as well).</p>
  
  <p>The crazy part is that the way to 'cure' the file system is to do:</p>
  
  <pre><code>mv ~/Dropbox/some/stuck/folder ~/Dropbox/some/stuck/folder.0
  mkdir ~/Dropbox/some/stuck/folder
  mv ~/Dropbox/some/stuck/folder.0/* ~/Dropbox/some/stuck/folder/
  rmdir ~/Dropbox/some/stuck/folder.0
  </code></pre>
  
  <p>After running these commands, the folder gets unstuck and starts sending events! It takes a few tries to find which of the parent folders is the culprit, but it's always some folder inside Dropbox. (Quitting Dropbox or rebooting does not cure it.)</p>
  
  <p>I'm doing nothing special in my code. Monitoring is started using:</p>
  
  <pre><code>FSEventStreamContext context;
  context.version = 0;
  context.info = self;
  context.retain = NULL;
  context.release = NULL;
  context.copyDescription = NULL;
  
  _streamRef = FSEventStreamCreate(nil,
                                   (FSEventStreamCallback)FSMonitorEventStreamCallback,
                                   &amp;context,
                                   (CFArrayRef)paths,
                                   kFSEventStreamEventIdSinceNow,
                                   0.25,
                                   kFSEventStreamCreateFlagUseCFTypes);
  if (!_streamRef) {
      NSLog(@"Failed to start monitoring of %@ (FSEventStreamCreate error)", _path);
  }
  
  FSEventStreamScheduleWithRunLoop(_streamRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
  if (!FSEventStreamStart(_streamRef)) {
      NSLog(@"Failed to start monitoring of %@ (FSEventStreamStart error)", _path);
  }
  </code></pre>
  
  <p>and the callback looks like this (not that it matters):</p>
  
  <pre><code>static void FSMonitorEventStreamCallback(ConstFSEventStreamRef streamRef, FSMonitor *monitor, size_t numEvents, NSArray *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
      for (int i = 0; i &lt; numEvents; i++) {
          NSString *path = [eventPaths objectAtIndex:i];
          FSEventStreamEventFlags flags = eventFlags[i];
          [monitor sendChangeEventWithPath:path flags:flags];
      }
  }
  </code></pre>
  
  <p>Happens on both 10.6 and 10.7. No fancy stuff like FileVault is active.</p>
  
  <p>This does look like an OS bug to me, but I haven't found any mentions of this problem on the web.</p>
  
  <p>Questions are:</p>
  
  <p>1) Have you ever experienced something like this? Any findings?</p>
  
  <p>2) What would be the steps to further diagnose this before using a tech support incident?</p>