about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-05 16:33:04 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-06 07:16:55 +0000
commitea6831e1eaeeb862afa7ed9213e2d9bc0180e706 (patch)
tree34079935b061a9f855ffe2aee49c736a4faf8867
parented7669ced3aba5c0ba6f5fbee9411546b32c96df (diff)
downloadrainbows-ea6831e1eaeeb862afa7ed9213e2d9bc0180e706.tar.gz
No need to split it out when there's only a single
class using it.
-rw-r--r--lib/rainbows.rb1
-rw-r--r--lib/rainbows/client.rb24
-rw-r--r--lib/rainbows/timed_read.rb28
3 files changed, 23 insertions, 30 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb
index c99b465..5d9c02f 100644
--- a/lib/rainbows.rb
+++ b/lib/rainbows.rb
@@ -49,7 +49,6 @@ module Rainbows
   autoload :RackInput, 'rainbows/rack_input'
   autoload :Response, 'rainbows/response'
   autoload :ProcessClient, 'rainbows/process_client'
-  autoload :TimedRead, 'rainbows/timed_read'
   autoload :Client, 'rainbows/client'
   autoload :Base, 'rainbows/base'
   autoload :Sendfile, 'rainbows/sendfile'
diff --git a/lib/rainbows/client.rb b/lib/rainbows/client.rb
index 8425e9e..3d92da1 100644
--- a/lib/rainbows/client.rb
+++ b/lib/rainbows/client.rb
@@ -3,6 +3,28 @@
 
 # this class is used for most synchronous concurrency models
 class Rainbows::Client < Kgio::Socket
-  include Rainbows::TimedRead
+  def read_expire
+    Time.now + Rainbows.keepalive_timeout
+  end
+
+  def kgio_wait_readable
+    IO.select([self], nil, nil, Rainbows.keepalive_timeout)
+  end
+
+  # used for reading headers (respecting keepalive_timeout)
+  def timed_read(buf)
+    expire = nil
+    begin
+      case rv = kgio_tryread(16384, buf)
+      when :wait_readable
+        return if expire && expire < Time.now
+        expire ||= read_expire
+        kgio_wait_readable
+      else
+        return rv
+      end
+    end while true
+  end
+
   include Rainbows::ProcessClient
 end
diff --git a/lib/rainbows/timed_read.rb b/lib/rainbows/timed_read.rb
deleted file mode 100644
index 72cabbb..0000000
--- a/lib/rainbows/timed_read.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- encoding: binary -*-
-# :enddoc:
-module Rainbows::TimedRead
-  G = Rainbows::G # :nodoc:
-
-  def read_expire
-    Time.now + Rainbows.keepalive_timeout
-  end
-
-  def kgio_wait_readable
-    IO.select([self], nil, nil, Rainbows.keepalive_timeout)
-  end
-
-  # used for reading headers (respecting keepalive_timeout)
-  def timed_read(buf)
-    expire = nil
-    begin
-      case rv = kgio_tryread(16384, buf)
-      when :wait_readable
-        return if expire && expire < Time.now
-        expire ||= read_expire
-        kgio_wait_readable
-      else
-        return rv
-      end
-    end while true
-  end
-end