sensu-spawn 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0c207ed2ac9ac3440eb9fcb2d40f9a11daa3439
4
- data.tar.gz: f0c98e79a8ec031bb11d93cfd14f61e525971024
3
+ metadata.gz: 1801d4320cdbd3204d53c55be6ca9e9015e3add6
4
+ data.tar.gz: 0b43c57912c8b1312a1aecf6a4d68de67517a459
5
5
  SHA512:
6
- metadata.gz: 3f9dcc76d8e151696d8b037a44e65fb44f15754e87fb0dce5d3f5eb1abf5b8e4f2b5c6043f6a7ac7d6e46d12e01bead6c673df09d898b749f528ee535f8b6307
7
- data.tar.gz: 5f6a65c22f6528d99078957addfff394b81ed47a812a43717aeecb78292c764b17d8bc29a9e8e3d5f879b0c84a7564a36dd00d9924d9d2d85f2d7e3b7653c7c8
6
+ metadata.gz: 59f4e684cdb4003ed7c560a0467c584176ecd97c343bb038701b08103476fd574d6aea97864d3bf5e860aee05340f4733c62c8472a87f319b2cfb6472814a15b
7
+ data.tar.gz: dce51d92a0f2a5c31ec031a0f5369e15357347d4cede3799d8bd7a4cd0f9b134f7bd632c445d9afb3a35bf062b54f132141584b66210df6f3727241ebd0e45e6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.4.0 - 2015-09-09
2
+
3
+ ### Fixes
4
+
5
+ Added a mutex `synchronize()` around ChildProcess Unix POSIX spawn
6
+ (`start()`), as it is not thread safe, allowing safe execution on
7
+ Ruby runtimes with real threads (JRuby).
8
+
1
9
  ## 1.3.0 - 2015-07-09
2
10
 
3
11
  ### Other
data/lib/sensu/spawn.rb CHANGED
@@ -5,6 +5,7 @@ gem "childprocess", "0.5.6"
5
5
  require "eventmachine"
6
6
  require "em/worker"
7
7
  require "childprocess"
8
+ require "rbconfig"
8
9
  require "ffi"
9
10
 
10
11
  begin
@@ -15,6 +16,8 @@ rescue LoadError; end
15
16
 
16
17
  module Sensu
17
18
  module Spawn
19
+ @@mutex = Mutex.new
20
+
18
21
  class << self
19
22
  # Spawn a child process. A maximum of 12 processes will be
20
23
  # spawned at a time. The EventMachine reactor (loop) must be
@@ -74,6 +77,9 @@ module Sensu
74
77
  # Create a child process, return its output (STDERR & STDOUT),
75
78
  # and exit status. The child process will have its own process
76
79
  # group, may accept data via STDIN, and have a timeout.
80
+ # ChildProcess Unix POSIX spawn (`start()`) is not thread safe,
81
+ # so a mutex is used to allow safe execution on Ruby runtimes
82
+ # with real threads (JRuby).
77
83
  #
78
84
  # The child process timeout functionality needs to be re-worked,
79
85
  # as it currenty allows for a deadlock, when the child output is
@@ -87,7 +93,9 @@ module Sensu
87
93
  def child_process(command, options={})
88
94
  child, reader, writer = build_child_process(command)
89
95
  child.duplex = true if options[:data]
90
- child.start
96
+ @@mutex.synchronize do
97
+ child.start
98
+ end
91
99
  writer.close
92
100
  if options[:data]
93
101
  child.io.stdin.write(options[:data])
data/sensu-spawn.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-spawn"
5
- spec.version = "1.3.0"
5
+ spec.version = "1.4.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu spawn process library"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-em