1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/lib/puma
Shannon Skipper 3896e2aa12 Fix thread spawning edge case.
Rapidly adding work to the ThreadPool can result in many jobs making it onto `@todo` before one of the jobs gets the mutex lock to decrement `@waiting`. So `@waiting == 0` isn't true and no thread is spawned even though there's work piling up, e.g.:

```ruby
require 'puma/thread_pool'

pool = Puma::ThreadPool.new(1, 3) { sleep 2 }

3.times { pool << 1 }

sleep 1

pool.spawned #=> 1 # When 3 is expected
```

Checking if `@waiting < @todo.size` shows that there's more work to do than threads waiting even if `@waiting` hasn't been decremented to `0` and also covers the base case where `@waiting == 0` and `@tudo.size == 1`.

An alternate option would be just adding the new check without removing the old one, something like `(@waiting == 0 or @waiting < @todo.size)`, but I don't think it's necessary unless for some kind of performance reason.
2014-08-19 22:36:34 -07:00
..
app Fix typo in phased-restart response 2013-08-06 15:47:40 -04:00
accept_nonblock.rb Vastly improve IO perf on 1.9.3 2012-08-11 15:09:09 -07:00
binder.rb Add SSL support for JRuby 2014-05-05 14:30:15 -07:00
capistrano.rb fallback from phased restart to start when not started 2014-04-10 12:35:00 +04:00
cli.rb Implement SIGHUP for logs reopening 2014-07-27 17:31:15 +03:00
client.rb only send 408 if in the data phase. 2014-01-30 17:37:38 -05:00
cluster.rb Implement SIGHUP for logs reopening 2014-07-27 17:31:15 +03:00
compat.rb Fix String#byteslice for Ruby 1.9.1, 1.9.2 2013-09-30 22:30:20 +09:00
configuration.rb allow changing of worker_timeout in config file 2014-03-26 12:37:06 +01:00
const.rb Bump to 2.9.0 2014-07-12 17:58:53 -07:00
control_cli.rb Merge remote-tracking branch 'origin/pr/336' 2013-08-08 16:10:26 -07:00
daemon_ext.rb Keep STDOUT/STDERR the right mode. Fixes #422 2013-12-05 09:51:39 -08:00
delegation.rb Standardize "block" usage 2013-07-03 09:25:48 -05:00
detect.rb Cleanup the JRuby specific fix 2012-08-10 19:36:01 -07:00
events.rb Add hook's and wire up a state hook 2013-09-13 09:56:39 -07:00
io_buffer.rb Conditionalize the jruby IOBuffer 2012-08-11 22:14:52 -07:00
java_io_buffer.rb Conditionalize the jruby IOBuffer 2012-08-11 22:14:52 -07:00
jruby_restart.rb Keep jruby daemon mode from retrying on a hot restart 2013-08-13 16:05:51 -07:00
minissl.rb Add SSL support for JRuby 2014-05-05 14:30:15 -07:00
null_io.rb Remove StringIO dependency from NullIO 2012-04-30 14:55:16 -04:00
rack_default.rb Default Rack handler helper 2013-02-09 20:27:05 -08:00
rack_patch.rb Improve the logging output when hijack is used. Fixes #332 2013-07-18 12:55:40 -07:00
reactor.rb only send 408 if in the data phase. 2014-01-30 17:37:38 -05:00
runner.rb Show the ruby version in use 2014-01-25 14:26:59 -08:00
server.rb Use fast_write because we can't trust syswrite 2014-07-12 17:49:44 -07:00
single.rb Return success status to the invoking environment 2013-08-21 07:25:25 +02:00
tcp_logger.rb Add experimental tcp mode (aka lopez express mode) 2013-08-07 16:39:08 -07:00
thread_pool.rb Fix thread spawning edge case. 2014-08-19 22:36:34 -07:00
util.rb Add missing file 2013-02-04 22:39:19 -08:00