<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,6 +9,7 @@ module Mongrel
       @port = port
       @mutex = Mutex.new
       @titles = []
+      @request_threads = []
       @queue_length = 0
       @request_count = 0
     end
@@ -40,11 +41,26 @@ module Mongrel
         mutex.synchronize do
           @queue_length -= 1
           @request_count += 1
-          self.title = titles.pop || &quot;xxx&quot;
+          @request_threads.delete(Thread.current)
+          set_request_list_title
         end
       end
     end
     
+    def set_request_list_title(excluding = nil)
+      if @request_threads.empty?
+        set_idle
+      else
+        if defined?(Rails)
+          # find the first awake/critical thread and put it in the front
+          running_thread = @request_threads.detect {|thread| thread.status == &quot;run&quot; &amp;&amp; excluding != thread }
+          @request_threads.unshift(@request_threads.delete(running_thread)) if running_thread
+          # this isn't exact, but it works for most situations
+        end
+        self.title = &quot;handling #{@request_threads.collect {|t| t[:request_str]}.join(', ')}&quot;
+      end
+    end
+
     # Reports process as being idle.
     def set_idle
       self.title = &quot;idle&quot;
@@ -62,7 +78,9 @@ module Mongrel
       method = params['REQUEST_METHOD']
       path = params['REQUEST_PATH']
       path = &quot;#{path[0, 60]}...&quot; if path.length &gt; 60
-      self.title = &quot;handling #{address}: #{method} #{path}&quot;
+      Thread.current[:request_str] = &quot;#{address}: #{method} #{path}&quot;
+      @request_threads.push(Thread.current)
+      set_request_list_title(Thread.current)
     end
     
     # Returns current title</diff>
      <filename>lib/mongrel_proctitle.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c99122b8f4004cdcf8846304ce9f6f44a713d217</id>
    </parent>
  </parents>
  <author>
    <name>Arya Asemanfar</name>
    <email>arya@seriousbusiness.com</email>
  </author>
  <url>http://github.com/arya/mongrel_proctitle/commit/f553dea913f8a425d9a712fc328835abf57e5305</url>
  <id>f553dea913f8a425d9a712fc328835abf57e5305</id>
  <committed-date>2009-02-09T18:57:02-08:00</committed-date>
  <authored-date>2009-02-09T18:57:02-08:00</authored-date>
  <message>fixed proctitle to:
  1) show the request it is currently handling instead of the most recent one received
  2) to show a list of the requests in queue</message>
  <tree>c1a34cf2f6d1ab41d54827145d406391ac372038</tree>
  <committer>
    <name>Arya Asemanfar</name>
    <email>arya@seriousbusiness.com</email>
  </committer>
</commit>
