8000 there are bugs in if-statements using `and`. by mephistobooks · Pull Request #967 · eventmachine/eventmachine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

there are bugs in if-statements using and. #967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/em/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def start_tls args={}
fail_if_no_peer_cert = args[:fail_if_no_peer_cert]

[priv_key_path, cert_chain_path].each do |file|
next if file.nil? or file.empty?
next if file.nil? || file.empty?
raise FileNotFoundException,
"Could not find #{file} for start_tls" unless File.exist? file
end
Expand Down
8 changes: 4 additions & 4 deletions lib/em/iterator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def concurrency=(val)
old = @concurrency
@concurrency = val

spawn_workers if val > old and @started and !@ended
spawn_workers if val > old && @started && !@ended
end
attr_reader :concurrency

Expand All @@ -97,14 +97,14 @@ def concurrency=(val)
#
def each(foreach=nil, after=nil, &blk)
raise ArgumentError, 'proc or block required for iteration' unless foreach ||= blk
raise RuntimeError, 'cannot iterate over an iterator more than once' if @started or @ended
raise RuntimeError, 'cannot iterate over an iterator more than once' if @started || @ended

@started = true
@pending = 0
@workers = 0

all_done = proc{
after.call if after and @ended and @pending == 0
after.call if after && @ended && @pending == 0
}

@process_next = proc{
Expand Down Expand Up @@ -225,7 +225,7 @@ def next
#
def spawn_workers
EM.next_tick(start_worker = proc{
if @workers < @concurrency and !@ended
if @workers < @concurrency && !@ended
8000 # p [:spawning_worker, :workers=, @workers, :concurrency=, @concurrency, :ended=, @ended]
@workers += 1
@process_next.call
Expand Down
2 changes: 1 addition & 1 deletion lib/em/protocols/header_and_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def receive_line line
raise "extraneous content-length header" if @hc_content_length
@hc_content_length = $1.to_i
end
if @hc_headers.length == 1 and respond_to?(:receive_first_header_line)
if @hc_headers.length == 1 && respond_to?(:receive_first_header_line)
receive_first_header_line line
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/em/protocols/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def send_request args
end

qs = args[:query_string] || ""
if qs.length > 0 and qs[0,1] != '?'
if qs.length > 0 && qs[0,1] != '?'
qs = "?" + qs
end

Expand Down Expand Up @@ -194,7 +194,7 @@ def receive_data data
if ary.length == 2
data = ary.last
if ary.first == ""
if (@content_length and @content_length > 0) || @chunked || @connection_close
if (@content_length && @content_length > 0) || @chunked || @connection_close
@read_state = :content
else
dispatch_response
Expand Down Expand Up @@ -294,7 +294,7 @@ def dispatch_response
def unbind
if !@connected
set_deferred_status :failed, {:status => 0} # YECCCCH. Find a better way to signal no-connect/network error.
elsif (@read_state == :content and @content_length == nil)
elsif (@read_state == :content && @content_length == nil)
dispatch_response
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/em/protocols/httpclient2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def process_header
(@headers[hdr.downcase] ||= []) << val
end

if clen == nil and e =~ ClenRE
if clen == nil && e =~ ClenRE
clen = $1.dup.to_i
end
if e =~ ChunkedRE
Expand Down Expand Up @@ -293,7 +293,7 @@ def post args
#
# @private
def set_default_host_header host, port, ssl
if (ssl and port != 443) or (!ssl and port != 80)
if (ssl && port != 443) || (!ssl && port != 80)
@host_header = "#{host}:#{port}"
else
@host_header = host
Expand Down 6DB6 Expand Up @@ -548,7 +548,7 @@ def process_received_headers

clen = nil
@current_response.headers.each do |e|
if clen == nil and e =~ ClenRE
if clen == nil && e =~ ClenRE
clen = $1.dup.to_i
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/em/protocols/line_and_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def receive_data data
end

def unbind
if @lbp_mode == :binary and @lbp_binary_limit > 0
if @lbp_mode == :binary && @lbp_binary_limit > 0
if respond_to?(:receive_binary_data)
receive_binary_data( @lbp_binary_buffer[0...@lbp_binary_bytes_received] )
end
Expand Down
2 changes: 1 addition & 1 deletion lib/em/protocols/linetext2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def set_binary_mode size=nil
# be aware that they may get a short buffer.
def unbind
@lt2_mode ||= nil
if @lt2_mode == :text and @lt2_textpos > 0
if @lt2_mode == :text && @lt2_textpos > 0
receive_binary_data @lt2_textbuffer.join
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/em/protocols/memcache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def process_cmd line

# @private
def unbind
if @connected or @reconnecting
if @connected || @reconnecting
EM.add_timer(1){ reconnect @host, @port }
@connected = false
@reconnecting = true
Expand Down
2 changes: 1 addition & 1 deletion lib/em/protocols/smtpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def invoke_rcpt_to
@responder = :receive_rcpt_to_response
else
e = @rcpt_responses.select {|rr| rr.last == 2}
if e and e.length > 0
if e && e.length > 0
invoke_data
else
invoke_error
Expand Down
4 changes: 2 additions & 2 deletions lib/em/protocols/smtpserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,9 @@ def process_starttls
# path in case of delivery problems. All of that is left to the calling application.
#
def process_mail_from sender
if (@@parms[:starttls]==:required and !@state.include?(:starttls))
if (@@parms[:starttls]==:required && !@state.include?(:starttls))
send_data "550 This server requires STARTTLS before MAIL FROM\r\n"
elsif (@@parms[:auth]==:required and !@state.include?(:auth))
elsif (@@parms[:auth]==:required && !@state.include?(:auth))
send_data "550 This server requires authentication before MAIL FROM\r\n"
elsif @state.include?(:mail_from)
send_data "503 MAIL already given\r\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/em/pure_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def get_outbound_data_size
end

def heartbeat
if @inactivity_timeout and @inactivity_timeout > 0 and (@last_activity + @inactivity_timeout) < Reactor.instance.current_loop_time
if @inactivity_timeout && @inactivity_timeout > 0 && (@last_activity + @inactivity_timeout) < Reactor.instance.current_loop_time
schedule_close true
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/em/spawnable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def notify *x
# work as one would expect.
#
y = me.call(*x)
if y and y.respond_to?(:pull_out_yield_block)
if y && y.respond_to?(:pull_out_yield_block)
a,b = y.pull_out_yield_block
set_receiver a
self.notify if b
Expand Down
24 changes: 12 additions & 12 deletions lib/eventmachine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if defined?(EventMachine.library_type) and EventMachine.library_type == :pure_ruby
if defined?(EventMachine.library_type) && EventMachine.library_type == :pure_ruby
# assume 'em/pure_ruby' was loaded already
elsif RUBY_PLATFORM =~ /java/
require 'java'
Expand Down Expand Up @@ -157,7 +157,7 @@ def self.run blk=nil, tail=nil, &block
# will start without release_machine being called and will immediately throw

#
if @reactor_running and @reactor_pid != Process.pid
if @reactor_running && @reactor_pid != Process.pid
# Reactor was started in a different parent, meaning we have forked.
# Clean up reactor state so a new reactor boots up in this child.
stop_event_loop
Expand Down Expand Up @@ -590,7 +590,7 @@ def self.start_unix_domain_server filename, *args, &block
#
# def receive_data data
# @data << data
# if !@parsed and @data =~ /[\n][\r]*[\n]/m
# if !@parsed && @data =~ /[\n][\r]*[\n]/m
# @parsed = true
# puts "RECEIVED HTTP HEADER:"
# $`.each {|line| puts ">>> #{line}" }
Expand Down Expand Up @@ -747,7 +747,7 @@ def EventMachine::attach io, handler=nil, *args, &blk
def EventMachine::attach_io io, watch_mode, handler=nil, *args
klass = klass_from_handler(Connection, handler, *args)

if !watch_mode and klass.public_instance_methods.any?{|m| [:notify_readable, :notify_writable].include? m.to_sym }
if !watch_mode && klass.public_instance_methods.any?{|m| [:notify_readable, :notify_writable].include? m.to_sym }
raise ArgumentError, "notify_readable/writable with EM.attach is not supported. Use EM.watch(io){ |c| c.notify_readable = true }"
end

Expand Down Expand Up @@ -1094,10 +1094,10 @@ def self.spawn_threadpool
# callbacks have been fired.
#
def self.defers_finished?
return false if @threadpool and !@all_threads_spawned
return false if @threadqueue and not @threadqueue.empty?
return false if @resultqueue and not @resultqueue.empty?
return false if @threadpool and @threadqueue.num_waiting != @threadpool.size
return false if @threadpool && !@all_threads_spawned
return false if @threadqueue && !(@threadqueue.empty?)
return false if @resultqueue && !(@resultqueue.empty?)
return false if @threadpool && @threadqueue.num_waiting != @threadpool.size
return true
end

Expand Down Expand Up @@ -1362,7 +1362,7 @@ def self.watch_process(pid, handler=nil, *args)
#
# @param [#call] cb Global catch-all errback
def self.error_handler cb = nil, &blk
if cb or blk
if cb || blk
@error_handler = cb || blk
elsif instance_variable_defined? :@error_handler
remove_instance_variable :@error_handler
Expand Down Expand Up @@ -1485,7 +1485,7 @@ def self.event_callback conn_binding, opcode, data
c.unbind
end
# If this is an attached (but not watched) connection, close the underlying io object.
if c.instance_variable_defined?(:@io) and !c.instance_variable_get(:@watch_mode)
if c.instance_variable_defined?(:@io) && !c.instance_variable_get(:@watch_mode)
io = c.instance_variable_get(:@io)
begin
io.close
Expand Down Expand Up @@ -1573,7 +1573,7 @@ def self._open_file_for_writing filename, handler=nil

# @private
def self.klass_from_handler(klass = Connection, handler = nil, *args)
klass = if handler and handler.is_a?(Class)
klass = if handler && handler.is_a?(Class)
raise ArgumentError, "must provide module or subclass of #{klass.name}" unless klass >= handler
handler
elsif handler
Expand All @@ -1588,7 +1588,7 @@ def self.klass_from_handler(klass = Connection, handler = nil, *args)

arity = klass.instance_method(:initialize).arity
expected = arity >= 0 ? arity : -(arity + 1)
if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected)
if (arity >= 0 && args.size != expected) || (arity < 0 && args.size < expected)
raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})"
end

Expand Down
0