puma 3.6.0 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59a23e7e6ba37bf306a2ae94c314daa0abf2f592
4
- data.tar.gz: c9228af1cebabc34902fd222965a4c851efd84e0
3
+ metadata.gz: 87918f1205dd9605cd8198bcd466597af1ed4c72
4
+ data.tar.gz: 59a5c11d9424f550c702a018a6e6ca10cb44318b
5
5
  SHA512:
6
- metadata.gz: 91433445f3ec432dfe5dd29361c06d8726e6c253351d2a66906442329edc6fe7e6b4dc47f120786a7a1adc11aae6b650ce7f0f6e829f63979ee8aa738d33e0ca
7
- data.tar.gz: 2aea9f4334fdf09dd1ff5ff8b6a71a61ad0ef5527f3e08d98a73b17cf940d85c56e5bae6221ea4ddc09d8b12cc368359227462b3fc93a372da0327041300c397
6
+ metadata.gz: b40c7149a0ce6d7a8374239bd2ad3c877bf448f19ea321517ff639f8a10ceef73fae6223b57d88e4301e742607144f8c91a9486d898f12a102d184bd51375b3b
7
+ data.tar.gz: 29af2339e95062708ae7445f64fad0076e1805fab766deebff3c337d374a6014500bc89decc1ee6117a6323e4d2b9aba77d3ea4056e2dccf75f299cf6bb03391
@@ -1,3 +1,21 @@
1
+ === 3.6.1 / 2016-11-21
2
+
3
+ * 8 bug fixes:
4
+
5
+ * Fix Puma start in init.d script.
6
+ * Fix default SSL mode back to none. Fixes #1036
7
+ * Fixed the issue of @listeners getting nil io, fix rails restart (#1120)
8
+ * More gracefully deal with SSL sessions. Fixes #1002
9
+ * Prevent short term thread churn.
10
+ * Provide write as <<. Fixes #1089
11
+ * Fix access priorities of each level in LeveledOptions - fixes TTIN.
12
+ * Stub description files updated for init.d.
13
+
14
+ * 2 new project committers:
15
+
16
+ * Nate Berkopec (@nateberkopec)
17
+ * Richard Schneeman (@schneems)
18
+
1
19
  === 3.6.0 / 2016-07-24
2
20
 
3
21
  * 12 bug fixes:
@@ -3,6 +3,8 @@ require 'mkmf'
3
3
  dir_config("puma_http11")
4
4
 
5
5
  unless ENV["DISABLE_SSL"]
6
+ dir_config("openssl")
7
+
6
8
  if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
7
9
  %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
8
10
 
@@ -327,6 +327,33 @@ VALUE engine_extract(VALUE self) {
327
327
  return Qnil;
328
328
  }
329
329
 
330
+ VALUE engine_shutdown(VALUE self) {
331
+ ms_conn* conn;
332
+ int ok, err;
333
+ char buf[512];
334
+
335
+ Data_Get_Struct(self, ms_conn, conn);
336
+
337
+ ERR_clear_error();
338
+
339
+ ok = SSL_shutdown(conn->ssl);
340
+ if (ok == 0) {
341
+ return Qfalse;
342
+ }
343
+
344
+ return Qtrue;
345
+ }
346
+
347
+ VALUE engine_init(VALUE self) {
348
+ ms_conn* conn;
349
+ int ok, err;
350
+ char buf[512];
351
+
352
+ Data_Get_Struct(self, ms_conn, conn);
353
+
354
+ return SSL_in_init(conn->ssl) ? Qtrue : Qfalse;
355
+ }
356
+
330
357
  VALUE engine_peercert(VALUE self) {
331
358
  ms_conn* conn;
332
359
  X509* cert;
@@ -394,6 +421,10 @@ void Init_mini_ssl(VALUE puma) {
394
421
  rb_define_method(eng, "write", engine_write, 1);
395
422
  rb_define_method(eng, "extract", engine_extract, 0);
396
423
 
424
+ rb_define_method(eng, "shutdown", engine_shutdown, 0);
425
+
426
+ rb_define_method(eng, "init?", engine_init, 0);
427
+
397
428
  rb_define_method(eng, "peercert", engine_peercert, 0);
398
429
  }
399
430
 
@@ -102,7 +102,7 @@ module Puma
102
102
  io = add_tcp_listener uri.host, uri.port, opt, bak
103
103
  end
104
104
 
105
- @listeners << [str, io]
105
+ @listeners << [str, io] if io
106
106
  when "unix"
107
107
  path = "#{uri.host}#{uri.path}".gsub("%20", " ")
108
108
 
@@ -206,7 +206,7 @@ module Puma
206
206
  io = add_ssl_listener uri.host, uri.port, ctx
207
207
  end
208
208
 
209
- @listeners << [str, io]
209
+ @listeners << [str, io] if io
210
210
  else
211
211
  logger.error "Invalid URI: #{str}"
212
212
  end
@@ -30,7 +30,7 @@ module Puma
30
30
  end
31
31
 
32
32
  def [](key)
33
- @set.each do |o|
33
+ @set.reverse_each do |o|
34
34
  if o.key? key
35
35
  return o[key]
36
36
  end
@@ -100,10 +100,10 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "3.6.0".freeze
103
+ PUMA_VERSION = VERSION = "3.6.1".freeze
104
104
  CODE_NAME = "Sleepy Sunday Serenity".freeze
105
105
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
106
-
106
+
107
107
  FAST_TRACK_KA_TIMEOUT = 0.2
108
108
 
109
109
  # The default number of seconds for another request within a persistent
@@ -264,11 +264,13 @@ module Puma
264
264
  end
265
265
 
266
266
  def ssl_bind(host, port, opts)
267
+ verify = opts.fetch(:verify_mode, 'none')
268
+
267
269
  if defined?(JRUBY_VERSION)
268
270
  keystore_additions = "keystore=#{opts[:keystore]}&keystore-pass=#{opts[:keystore_pass]}"
269
- bind "ssl://#{host}:#{port}?cert=#{opts[:cert]}&key=#{opts[:key]}&#{keystore_additions}&verify_mode=#{opts[:verify_mode] || 'peer'}"
271
+ bind "ssl://#{host}:#{port}?cert=#{opts[:cert]}&key=#{opts[:key]}&#{keystore_additions}&verify_mode=#{verify}"
270
272
  else
271
- bind "ssl://#{host}:#{port}?cert=#{opts[:cert]}&key=#{opts[:key]}&verify_mode=#{opts[:verify_mode] || 'peer'}"
273
+ bind "ssl://#{host}:#{port}?cert=#{opts[:cert]}&key=#{opts[:key]}&verify_mode=#{verify}"
272
274
  end
273
275
  end
274
276
 
@@ -75,13 +75,45 @@ module Puma
75
75
  end
76
76
 
77
77
  alias_method :syswrite, :write
78
+ alias_method :<<, :write
78
79
 
79
80
  def flush
80
81
  @socket.flush
81
82
  end
82
83
 
83
84
  def close
84
- @socket.close
85
+ begin
86
+ # Try to setup (so that we can then close them) any
87
+ # partially initialized sockets.
88
+ while @engine.init?
89
+ # Don't let this socket hold this loop forever.
90
+ # If it can't send more packets within 1s, then
91
+ # give up.
92
+ return unless IO.select([@socket], nil, nil, 1)
93
+ begin
94
+ read_nonblock(1024)
95
+ rescue Errno::EAGAIN
96
+ end
97
+ end
98
+
99
+ done = @engine.shutdown
100
+
101
+ while true
102
+ enc = @engine.extract
103
+ @socket.write enc
104
+
105
+ notify = @socket.sysread(1024)
106
+
107
+ @engine.inject notify
108
+ done = @engine.shutdown
109
+
110
+ break if done
111
+ end
112
+ rescue IOError, SystemCallError
113
+ # nothing
114
+ ensure
115
+ @socket.close
116
+ end
85
117
  end
86
118
 
87
119
  def peeraddr
@@ -57,7 +57,7 @@ module Puma
57
57
 
58
58
  @min_threads = 0
59
59
  @max_threads = 16
60
- @auto_trim_time = 1
60
+ @auto_trim_time = 30
61
61
  @reaping_time = 1
62
62
 
63
63
  @thread = nil
@@ -358,7 +358,7 @@ module Puma
358
358
 
359
359
  graceful_shutdown if @status == :stop || @status == :restart
360
360
  if queue_requests
361
- @reactor.clear! if @status == :restart
361
+ @reactor.clear!
362
362
  @reactor.shutdown
363
363
  end
364
364
  rescue Exception => e
@@ -209,7 +209,7 @@ module Puma
209
209
  end
210
210
  end
211
211
 
212
- def auto_trim!(timeout=5)
212
+ def auto_trim!(timeout=30)
213
213
  @auto_trim = AutoTrim.new(self, timeout)
214
214
  @auto_trim.start!
215
215
  end
@@ -5,9 +5,9 @@
5
5
  # Required-Stop: $remote_fs $syslog
6
6
  # Default-Start: 2 3 4 5
7
7
  # Default-Stop: 0 1 6
8
- # Short-Description: Example initscript
9
- # Description: This file should be used to construct scripts to be
10
- # placed in /etc/init.d.
8
+ # Short-Description: Puma web server
9
+ # Description: A ruby web server built for concurrency http://puma.io
10
+ # initscript to be placed in /etc/init.d.
11
11
  ### END INIT INFO
12
12
 
13
13
  # Author: Darío Javier Cravero <dario@exordo.com>
@@ -39,17 +39,7 @@ do_start() {
39
39
  log_daemon_msg "=> Running the jungle..."
40
40
  for i in $JUNGLE; do
41
41
  dir=`echo $i | cut -d , -f 1`
42
- user=`echo $i | cut -d , -f 2`
43
- config_file=`echo $i | cut -d , -f 3`
44
- if [ "$config_file" = "" ]; then
45
- config_file="$dir/config/puma.rb"
46
- fi
47
- log_file=`echo $i | cut -d , -f 4`
48
- if [ "$log_file" = "" ]; then
49
- log_file="$dir/log/puma.log"
50
- fi
51
- environment=`echo $i | cut -d , -f 5`
52
- do_start_one $dir $user $config_file $log_file $environment
42
+ do_start_one $dir
53
43
  done
54
44
  }
55
45
 
@@ -59,28 +49,41 @@ do_start_one() {
59
49
  PID=`cat $PIDFILE`
60
50
  # If the puma isn't running, run it, otherwise restart it.
61
51
  if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
62
- do_start_one_do $1 $2 $3 $4 $5
52
+ do_start_one_do $1
63
53
  else
64
54
  do_restart_one $1
65
55
  fi
66
56
  else
67
- do_start_one_do $1 $2 $3 $4 $5
57
+ do_start_one_do $1
68
58
  fi
69
59
  }
70
60
 
71
61
  do_start_one_do() {
72
- log_daemon_msg "--> Woke up puma $1"
73
- log_daemon_msg "user $2"
74
- log_daemon_msg "log to $4"
62
+ i=`grep $1 $CONFIG`
63
+ dir=`echo $i | cut -d , -f 1`
64
+ user=`echo $i | cut -d , -f 2`
65
+ config_file=`echo $i | cut -d , -f 3`
66
+ if [ "$config_file" = "" ]; then
67
+ config_file="$dir/config/puma.rb"
68
+ fi
69
+ log_file=`echo $i | cut -d , -f 4`
70
+ if [ "$log_file" = "" ]; then
71
+ log_file="$dir/log/puma.log"
72
+ fi
73
+ environment=`echo $i | cut -d , -f 5`
74
+
75
+ log_daemon_msg "--> Woke up puma $dir"
76
+ log_daemon_msg "user $user"
77
+ log_daemon_msg "log to $log_file"
75
78
 
76
- if [ ! -z "$5" ]; then
77
- for e in $(echo "$5" | tr ';' '\n'); do
79
+ if [ ! -z "$environment" ]; then
80
+ for e in $(echo "$environment" | tr ';' '\n'); do
78
81
  log_daemon_msg "environment $e"
79
82
  v=${e%%\=*} ; eval "$e" ; export $v
80
83
  done
81
84
  fi
82
85
 
83
- start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA -- $1 $3 $4
86
+ start-stop-daemon --verbose --start --chdir $dir --chuid $user --background --exec $RUNPUMA -- $dir $config_file $log_file
84
87
  }
85
88
 
86
89
  #
@@ -135,8 +138,6 @@ do_restart() {
135
138
  #
136
139
  do_restart_one() {
137
140
  PIDFILE=$1/tmp/puma/pid
138
- i=`grep $1 $CONFIG`
139
- dir=`echo $i | cut -d , -f 1`
140
141
 
141
142
  if [ -e $PIDFILE ]; then
142
143
  log_daemon_msg "--> About to restart puma $1"
@@ -144,17 +145,7 @@ do_restart_one() {
144
145
  # TODO Check if process exist
145
146
  else
146
147
  log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
147
- user=`echo $i | cut -d , -f 2`
148
- config_file=`echo $i | cut -d , -f 3`
149
- if [ "$config_file" = "" ]; then
150
- config_file="$dir/config/puma.rb"
151
- fi
152
- log_file=`echo $i | cut -d , -f 4`
153
- if [ "$log_file" = "" ]; then
154
- log_file="$dir/log/puma.log"
155
- fi
156
- environment=`echo $i | cut -d , -f 5`
157
- do_start_one $dir $user $config_file $log_file $environment
148
+ do_start_one $1
158
149
  fi
159
150
  return 0
160
151
  }
@@ -174,26 +165,14 @@ do_phased_restart() {
174
165
  #
175
166
  do_phased_restart_one() {
176
167
  PIDFILE=$1/tmp/puma/pid
177
- i=`grep $1 $CONFIG`
178
- dir=`echo $i | cut -d , -f 1`
179
168
 
180
169
  if [ -e $PIDFILE ]; then
181
170
  log_daemon_msg "--> About to restart puma $1"
182
171
  kill -s USR1 `cat $PIDFILE`
183
172
  # TODO Check if process exist
184
173
  else
185
- log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
186
- user=`echo $i | cut -d , -f 2`
187
- config_file=`echo $i | cut -d , -f 3`
188
- if [ "$config_file" = "" ]; then
189
- config_file="$dir/config/puma.rb"
190
- fi
191
- log_file=`echo $i | cut -d , -f 4`
192
- if [ "$log_file" = "" ]; then
193
- log_file="$dir/log/puma.log"
194
- fi
195
- environment=`echo $i | cut -d , -f 5`
196
- do_start_one $dir $user $config_file $log_file $environment
174
+ log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
175
+ do_start_one $1
197
176
  fi
198
177
  return 0
199
178
  }
@@ -339,16 +318,7 @@ case "$1" in
339
318
  else
340
319
  i=`grep $2 $CONFIG`
341
320
  dir=`echo $i | cut -d , -f 1`
342
- user=`echo $i | cut -d , -f 2`
343
- config_file=`echo $i | cut -d , -f 3`
344
- if [ "$config_file" = "" ]; then
345
- config_file="$dir/config/puma.rb"
346
- fi
347
- log_file=`echo $i | cut -d , -f 4`
348
- if [ "$log_file" = "" ]; then
349
- log_file="$dir/log/puma.log"
350
- fi
351
- do_start_one $dir $user $config_file $log_file
321
+ do_start_one $dir
352
322
  fi
353
323
  case "$?" in
354
324
  0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.15'
67
+ version: '3.14'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.15'
74
+ version: '3.14'
75
75
  description: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server
76
76
  for Ruby/Rack applications. Puma is intended for use in both development and production
77
77
  environments. In order to get the best throughput, it is highly recommended that