log-courier 1.6 → 1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/log-courier/client.rb +1 -2
- data/lib/log-courier/client_tcp.rb +11 -5
- data/lib/log-courier/event_queue.rb +12 -4
- data/lib/log-courier/server.rb +1 -3
- data/lib/log-courier/server_tcp.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87c60888250cf6ee377f74118e6a3c0fecc21146
|
4
|
+
data.tar.gz: bfdebc1639702ab97613b840a1e28c4b41b3cb6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae7a9880faa41b0ceb6af7ce7cf79011b23327b5cc5277434cebce4238fcaaede498dbcc061017d3f4439dc2f1cb2be36a74939992d81645799f1a41e5f2b6b
|
7
|
+
data.tar.gz: d5978e30451e8d96ef5bec62844e591195b24fbdc9d31902402408723bb18d575ec53dac4c84a6de62fa067f00704ea526a836ff37dbb6002cbf483dca9637b3
|
data/lib/log-courier/client.rb
CHANGED
@@ -103,7 +103,6 @@ module LogCourier
|
|
103
103
|
}.merge!(options)
|
104
104
|
|
105
105
|
@logger = @options[:logger]
|
106
|
-
@logger['plugin'] = 'output/courier' unless @logger.nil?
|
107
106
|
|
108
107
|
case @options[:transport]
|
109
108
|
when 'tcp', 'tls'
|
@@ -440,7 +439,7 @@ module LogCourier
|
|
440
439
|
fail ProtocolError, "ACKN message size invalid (#{message.length})" if message.length != 20
|
441
440
|
|
442
441
|
# Grab nonce
|
443
|
-
nonce, sequence = message.unpack('
|
442
|
+
nonce, sequence = message.unpack('a16N')
|
444
443
|
|
445
444
|
if !@logger.nil? && @logger.debug?
|
446
445
|
nonce_str = nonce.each_byte.map do |b|
|
@@ -65,10 +65,16 @@ module LogCourier
|
|
65
65
|
@send_paused = false
|
66
66
|
|
67
67
|
@send_thread = Thread.new do
|
68
|
-
|
68
|
+
begin
|
69
|
+
run_send io_control
|
70
|
+
rescue ShutdownSignal
|
71
|
+
end
|
69
72
|
end
|
70
73
|
@recv_thread = Thread.new do
|
71
|
-
|
74
|
+
begin
|
75
|
+
run_recv io_control
|
76
|
+
rescue ShutdownSignal
|
77
|
+
end
|
72
78
|
end
|
73
79
|
return
|
74
80
|
end
|
@@ -146,7 +152,7 @@ module LogCourier
|
|
146
152
|
io_control << ['F']
|
147
153
|
return
|
148
154
|
rescue ShutdownSignal
|
149
|
-
|
155
|
+
raise
|
150
156
|
rescue StandardError, NativeException => e
|
151
157
|
@logger.warn e, :hint => 'Unknown write error' unless @logger.nil?
|
152
158
|
io_control << ['F']
|
@@ -189,8 +195,8 @@ module LogCourier
|
|
189
195
|
io_control << ['F']
|
190
196
|
return
|
191
197
|
rescue ShutdownSignal
|
192
|
-
|
193
|
-
rescue => e
|
198
|
+
raise
|
199
|
+
rescue StandardError, NativeException => e
|
194
200
|
@logger.warn e, :hint => 'Unknown read error' unless @logger.nil?
|
195
201
|
io_control << ['F']
|
196
202
|
return
|
@@ -135,14 +135,18 @@ module LogCourier
|
|
135
135
|
# Returns +true+ if the queue is empty.
|
136
136
|
#
|
137
137
|
def empty?
|
138
|
-
@
|
138
|
+
@mutex.synchronize do
|
139
|
+
return @que.empty?
|
140
|
+
end
|
139
141
|
end
|
140
142
|
|
141
143
|
#
|
142
144
|
# Removes all objects from the queue.
|
143
145
|
#
|
144
146
|
def clear
|
145
|
-
@
|
147
|
+
@mutex.synchronize do
|
148
|
+
@que.clear
|
149
|
+
end
|
146
150
|
self
|
147
151
|
end
|
148
152
|
|
@@ -150,7 +154,9 @@ module LogCourier
|
|
150
154
|
# Returns the length of the queue.
|
151
155
|
#
|
152
156
|
def length
|
153
|
-
@
|
157
|
+
@mutex.synchronize do
|
158
|
+
return @que.length
|
159
|
+
end
|
154
160
|
end
|
155
161
|
|
156
162
|
#
|
@@ -162,7 +168,9 @@ module LogCourier
|
|
162
168
|
# Returns the number of threads waiting on the queue.
|
163
169
|
#
|
164
170
|
def num_waiting
|
165
|
-
@
|
171
|
+
@mutex.synchronize do
|
172
|
+
return @num_waiting + @num_enqueue_waiting
|
173
|
+
end
|
166
174
|
end
|
167
175
|
|
168
176
|
private
|
data/lib/log-courier/server.rb
CHANGED
@@ -40,7 +40,6 @@ module LogCourier
|
|
40
40
|
}.merge!(options)
|
41
41
|
|
42
42
|
@logger = @options[:logger]
|
43
|
-
@logger['plugin'] = 'input/courier' unless @logger.nil?
|
44
43
|
|
45
44
|
case @options[:transport]
|
46
45
|
when 'tcp', 'tls'
|
@@ -55,7 +54,6 @@ module LogCourier
|
|
55
54
|
|
56
55
|
# Grab the port back and update the logger context
|
57
56
|
@port = @server.port
|
58
|
-
@logger['port'] = @port unless @logger.nil?
|
59
57
|
|
60
58
|
# Load the json adapter
|
61
59
|
@json_adapter = MultiJson.adapter.instance
|
@@ -191,7 +189,7 @@ module LogCourier
|
|
191
189
|
# Full pipeline, partial ack
|
192
190
|
# NOTE: comm.send can raise a Timeout::Error of its own
|
193
191
|
@logger.debug 'Partially acknowledging message', :nonce => nonce_str.join, :sequence => sequence if !@logger.nil? && @logger.debug?
|
194
|
-
comm.send 'ACKN', [nonce, sequence].pack('
|
192
|
+
comm.send 'ACKN', [nonce, sequence].pack('a*N')
|
195
193
|
ack_timeout = Time.now.to_i + 5
|
196
194
|
retry
|
197
195
|
end
|
@@ -34,7 +34,13 @@ module LogCourier
|
|
34
34
|
# Save the peer
|
35
35
|
def accept
|
36
36
|
sock = super
|
37
|
-
|
37
|
+
# Prevent reverse lookup by passing false
|
38
|
+
begin
|
39
|
+
peer = sock.peeraddr(false)
|
40
|
+
rescue ArgumentError
|
41
|
+
# Logstash <= 1.5.0 has a patch that blocks parameters (elastic/logstash#3364)
|
42
|
+
peer = sock.peeraddr
|
43
|
+
end
|
38
44
|
@peer = "#{peer[2]}:#{peer[1]}"
|
39
45
|
return sock
|
40
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log-courier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Woods
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cabin
|