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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 813517c74af76579fc2d9b1f036f4bc603a3659d
4
- data.tar.gz: 720e7e6ccb21d339ef1dfed8959d7322bfb11b1d
3
+ metadata.gz: 87c60888250cf6ee377f74118e6a3c0fecc21146
4
+ data.tar.gz: bfdebc1639702ab97613b840a1e28c4b41b3cb6f
5
5
  SHA512:
6
- metadata.gz: 5f43f87cdc3652b8976cd6ac6770db9c3ca32a44f19650526b5e541d530ef381d89954bfb7730d011c3c7871f398cf23e7c9e2cc63f820373ad896cecff098e6
7
- data.tar.gz: 0a281f7bacbbb72f95600fbf8419c093073dfadae36814e08536edfc377d6c57eb7848f0629db3b548012b020912b1af8c72885b7b0e5445295c0a6f7aca017b
6
+ metadata.gz: fae7a9880faa41b0ceb6af7ce7cf79011b23327b5cc5277434cebce4238fcaaede498dbcc061017d3f4439dc2f1cb2be36a74939992d81645799f1a41e5f2b6b
7
+ data.tar.gz: d5978e30451e8d96ef5bec62844e591195b24fbdc9d31902402408723bb18d575ec53dac4c84a6de62fa067f00704ea526a836ff37dbb6002cbf483dca9637b3
@@ -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('A16N')
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
- run_send io_control
68
+ begin
69
+ run_send io_control
70
+ rescue ShutdownSignal
71
+ end
69
72
  end
70
73
  @recv_thread = Thread.new do
71
- run_recv io_control
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
- return
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
- return
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
- @que.empty?
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
- @que.clear
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
- @que.length
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
- @num_waiting + @num_enqueue_waiting
171
+ @mutex.synchronize do
172
+ return @num_waiting + @num_enqueue_waiting
173
+ end
166
174
  end
167
175
 
168
176
  private
@@ -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('A*N')
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
- peer = sock.peeraddr(:numeric)
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.6'
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-22 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cabin