elasticsearch/logstash — pull request #1270 by lmars (2014-04-15 16:19:22+00:00)
Title: Synchronize access to @client_threads in LogStash::Outputs::Tcp

Logstash was consistently failing with the following error when a client connected to a TCP output:

```
NoMethodError: undefined method `write' for nil:NilClass
register at /opt/logstash/lib/logstash/outputs/tcp.rb:92
each at org/jruby/RubyArray.java:1613
register at /opt/logstash/lib/logstash/outputs/tcp.rb:91
call at org/jruby/RubyProc.java:271
encode at /opt/logstash/lib/logstash/codecs/json.rb:45
receive at /opt/logstash/lib/logstash/outputs/tcp.rb:143
handle at /opt/logstash/lib/logstash/outputs/base.rb:86
initialize at (eval):21
call at org/jruby/RubyProc.java:271
output at /opt/logstash/lib/logstash/pipeline.rb:266
outputworker at /opt/logstash/lib/logstash/pipeline.rb:225
start_outputs at /opt/logstash/lib/logstash/pipeline.rb:152
```

Logstash at the time was receiving a heavy stream of events, so this is likely the result of a race condition accessing `@client_threads` which is not thread safe, so this change synchronizes access to it across threads.