# File lib/rb-inotify/notifier.rb, line 223
    def read_events
      size = 64 * Native::Event.size
      tries = 1

      begin
        data = readpartial(size)
      rescue SystemCallError => er
        # EINVAL means that there's more data to be read
        # than will fit in the buffer size
        raise er unless er.errno == EINVAL || tries == 5
        size *= 2
        tries += 1
        retry
      end

      events = []
      cookies = {}
      while ev = Event.consume(data, self)
        events << ev
        next if ev.cookie == 0
        cookies[ev.cookie] ||= []
        cookies[ev.cookie] << ev
      end
      cookies.each {|c, evs| evs.each {|ev| ev.related.replace(evs - [ev]).freeze}}
      events
    end