[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] [PATCH] Inotify support for Maildirs. (FIRST DRAFT)



Extra note: the ruby-inotify plugin appears to be braindead
on at least Ruby 1.8.7 for Ubuntu Precise, and will spin-loop.  If
sup is chomping 15% CPU on idle, try this patch on ruby-inotify

Reported here: https://github.com/ruby-building-blocks/ruby-inotify/issues/8

diff --git a/lib/inotify/inotify_native.rb b/lib/inotify/inotify_native.rb
index 66db2b4..27d1043 100644
--- a/lib/inotify/inotify_native.rb
+++ b/lib/inotify/inotify_native.rb
@@ -115,7 +115,7 @@ require 'ffi'
     # each_event() provides an easy way to loop over all events as they occur
     def each_event
       loop do
-        ready = IO.select([@io], nil, nil, nil)
+        ready = IO.select([@io])
         event = self.read_event
         yield event
       end


Excerpts from Edward Z. Yang's message of Mon Sep 03 14:09:57 -0400 2012:
> OK, cracked a fix; you need this extra patch:
> 
> commit f9ea07f3c4982ab46d8171fdba8eabc3af00c840
> Author: Edward Z. Yang <ezyang@mit.edu>
> Date:   Mon Sep 3 14:09:34 2012 -0400
> 
>     sync_back after writing to index, not before.
>     
>     Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
> 
> diff --git a/lib/sup/index.rb b/lib/sup/index.rb
> index 13798d6..4b533a7 100644
> --- a/lib/sup/index.rb
> +++ b/lib/sup/index.rb
> @@ -657,10 +657,6 @@ EOS
>    end
>  
>    def sync_message m, overwrite
> -    ## TODO: we should not save the message if the sync_back failed
> -    ## since it would overwrite the location field
> -    m.sync_back
> -
>      doc = synchronize { find_doc(m.id) }
>      existed = doc != nil
>      doc ||= Xapian::Document.new
> @@ -703,6 +699,10 @@ EOS
>        @xapian.replace_document docid, doc
>      end
>  
> +    # sync_back must be after label update, so that inotify gets
> +    # fresh data from the index
> +    m.sync_back
> +
>      m.labels.each { |l| LabelManager << l }
>      true
>    end
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel