Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make ZMQ::LINGER time configurable on sockets

  • Loading branch information...
commit af1a2f0653d36e055762eb65ae9a00068c71cef7 1 parent 449af21
Martin Rehfeld authored
Showing with 8 additions and 8 deletions.
  1. +7 −7 lib/mongrel2/connection.rb
  2. +1 −1  lib/rack/handler/mongrel2.rb
14 lib/mongrel2/connection.rb
View
@@ -9,19 +9,19 @@ class ConnectionDiedError < StandardError; end
class Connection
CTX = ZMQ::Context.new(1)
- def initialize(uuid, sub, pub)
- @uuid, @sub, @pub = uuid, sub, pub
+ def initialize(options)
+ @uuid, @sub, @pub = options[:uuid], options[:recv], options[:send]
# Connect to receive requests
@reqs = CTX.socket(ZMQ::PULL)
- @reqs.connect(sub)
- @reqs.setsockopt(ZMQ::LINGER, 0)
+ @reqs.connect(@sub)
+ @reqs.setsockopt(ZMQ::LINGER, options[:recv_linger] || 0)
# Connect to send responses
@resp = CTX.socket(ZMQ::PUB)
- @resp.connect(pub)
- @resp.setsockopt(ZMQ::IDENTITY, uuid)
- @resp.setsockopt(ZMQ::LINGER, 0)
+ @resp.connect(@pub)
+ @resp.setsockopt(ZMQ::IDENTITY, @uuid)
+ @resp.setsockopt(ZMQ::LINGER, options[:send_linger] || 0)
end
def recv
2  lib/rack/handler/mongrel2.rb
View
@@ -11,7 +11,7 @@ def self.run(app, options = {})
raise ArgumentError.new('Must specify :recv') if options[:send].nil?
raise ArgumentError.new('Must specify :uuid') if options[:uuid].nil?
- conn = ::Mongrel2::Connection.new(options[:uuid], options[:recv], options[:send])
+ conn = ::Mongrel2::Connection.new(options)
running = true
Please sign in to comment.
Something went wrong with that request. Please try again.