Skip to content

Commit

Permalink
Add --no-epoll option to disable epoll usage on Linux [#61 state:reso…
Browse files Browse the repository at this point in the history
…lved]
  • Loading branch information
macournoyer committed Jul 14, 2008
1 parent 729b76a commit 37fbf1d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
@@ -1,5 +1,6 @@
== 1.0.0 The Big release
* Add --force (-f) option to force stopping of a daemonized server, fixes [#72 state:resolved]
* Add --no-epoll option to disable epoll usage on Linux [#61 state:resolved]
* Add --force (-f) option to force stopping of a daemonized server [#72 state:resolved]
* Update halycon adapter loader [mtodd]

== 0.8.2 Double Margarita release
Expand Down
5 changes: 4 additions & 1 deletion lib/thin/backends/base.rb
Expand Up @@ -30,6 +30,9 @@ def threaded?; @threaded end
# Number of persistent connections currently opened
attr_accessor :persistent_connection_count

# Disable the use of epoll under Linux
attr_accessor :no_epoll

def initialize
@connections = []
@timeout = Server::DEFAULT_TIMEOUT
Expand Down Expand Up @@ -72,7 +75,7 @@ def stop!
# so you can do crazy stuff that require godlike powers here.
def config
# See http://rubyeventmachine.com/pub/rdoc/files/EPOLL.html
EventMachine.epoll
EventMachine.epoll unless @no_epoll

# Set the maximum number of socket descriptors that the server may open.
# The process needs to have required privilege to set it higher the 1024 on
Expand Down
1 change: 1 addition & 0 deletions lib/thin/controllers/controller.rb
Expand Up @@ -49,6 +49,7 @@ def start
server.maximum_connections = @options[:max_conns]
server.maximum_persistent_connections = @options[:max_persistent_conns]
server.threaded = @options[:threaded]
server.no_epoll = @options[:no_epoll]

# Detach the process, after this line the current process returns
server.daemonize if @options[:daemonize]
Expand Down
1 change: 1 addition & 0 deletions lib/thin/runner.rb
Expand Up @@ -111,6 +111,7 @@ def parser
"(default: #{@options[:max_persistent_conns]})") { |num| @options[:max_persistent_conns] = num.to_i }
opts.on( "--threaded", "Call the Rack application in threads " +
"[experimental]") { @options[:threaded] = true }
opts.on( "--no-epoll", "Disable the use of epoll") { @options[:no_epoll] = true } if Thin.linux?

opts.separator ""
opts.separator "Common options:"
Expand Down
11 changes: 11 additions & 0 deletions spec/backends/tcp_server_spec.rb
Expand Up @@ -5,6 +5,17 @@
@backend = Backends::TcpServer.new('0.0.0.0', 3333)
end

it "should not use epoll" do
@backend.no_epoll = true
EventMachine.should_not_receive(:epoll)
@backend.config
end

it "should use epoll" do
EventMachine.should_receive(:epoll)
@backend.config
end

it "should connect" do
EventMachine.run do
@backend.connect
Expand Down

0 comments on commit 37fbf1d

Please sign in to comment.