Skip to content
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

fix TLS crash by removing obsolete twitter-stream patch #140

Open
wants to merge 3 commits 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 earthquake.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency "twitter-stream"
s.add_runtime_dependency "twitter-stream", "~> 0.1.16"
s.add_runtime_dependency "notify"
s.add_runtime_dependency "i18n"
s.add_runtime_dependency "activesupport"
Expand Down
2 changes: 1 addition & 1 deletion lib/earthquake/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def self._eval_as_ruby_string(text)
default_stream = {
method: "POST",
host: "userstream.twitter.com",
path: "/2/user.json",
path: "/1.1/user.json",
ssl: true,
}

Expand Down
16 changes: 2 additions & 14 deletions lib/earthquake/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ def default_config
secure: true,
output_interval: 1,
history_size: 1000,
api: { :host => 'userstream.twitter.com', :path => '/2/user.json', :ssl => true },
api: { :host => 'userstream.twitter.com', :path => '/1.1/user.json', :ssl => true },
confirm_type: :y,
expand_url: false,
thread_indent: " ",
no_data_timeout: 30
}
end

Expand Down Expand Up @@ -144,27 +143,17 @@ def start(options = {})
end

EM.add_periodic_timer(config[:output_interval]) do
if @last_data_received_at && Time.now - @last_data_received_at > config[:no_data_timeout]
reconnect
end
if Readline.line_buffer.nil? || Readline.line_buffer.empty?
sync { output }
end
end

reconnect unless options[:'no-stream'] == true
start_stream(config[:api]) unless options[:'no-stream'] == true

trap('INT') { stop }
end
end

def reconnect
item_queue.clear
start_stream(config[:api])
rescue EventMachine::ConnectionError => e
# ignore
end

def start_stream(options)
stop_stream

Expand All @@ -178,7 +167,6 @@ def start_stream(options)
@stream = ::Twitter::JSONStream.connect(options)

@stream.each_item do |item|
@last_data_received_at = Time.now # for reconnect when no data
item_queue << JSON.parse(item)
end

Expand Down
21 changes: 0 additions & 21 deletions lib/earthquake/ext.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
module Twitter
class JSONStream
protected
def reconnect_after timeout
@reconnect_callback.call(timeout, @reconnect_retries) if @reconnect_callback

if timeout == 0
start_tls if @options[:ssl]
reconnect @options[:host], @options[:port]
else
EM.add_timer(timeout) do
start_tls if @options[:ssl]
reconnect @options[:host], @options[:port]
end
end
rescue EventMachine::ConnectionError => e
# ignore
end
end
end

class String
def c(*codes)
codes = codes.flatten.map { |code|
Expand Down