puma 3.12.1 → 5.6.4
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 +4 -4
- data/History.md +1553 -447
- data/LICENSE +23 -20
- data/README.md +175 -63
- data/bin/puma-wild +3 -9
- data/docs/architecture.md +59 -21
- data/docs/compile_options.md +21 -0
- data/docs/deployment.md +69 -58
- data/docs/fork_worker.md +33 -0
- data/docs/images/puma-connection-flow-no-reactor.png +0 -0
- data/docs/images/puma-connection-flow.png +0 -0
- data/docs/images/puma-general-arch.png +0 -0
- data/docs/jungle/README.md +9 -0
- data/{tools → docs}/jungle/rc.d/README.md +1 -1
- data/{tools → docs}/jungle/rc.d/puma +2 -2
- data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
- data/docs/kubernetes.md +66 -0
- data/docs/nginx.md +1 -1
- data/docs/plugins.md +22 -12
- data/docs/rails_dev_mode.md +28 -0
- data/docs/restart.md +47 -22
- data/docs/signals.md +13 -11
- data/docs/stats.md +142 -0
- data/docs/systemd.md +95 -120
- data/ext/puma_http11/PumaHttp11Service.java +2 -2
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/extconf.rb +51 -1
- data/ext/puma_http11/http11_parser.c +105 -117
- data/ext/puma_http11/http11_parser.h +1 -1
- data/ext/puma_http11/http11_parser.java.rl +22 -38
- data/ext/puma_http11/http11_parser.rl +4 -2
- data/ext/puma_http11/http11_parser_common.rl +4 -4
- data/ext/puma_http11/mini_ssl.c +319 -96
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +84 -99
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +120 -65
- data/ext/puma_http11/puma_http11.c +35 -51
- data/lib/puma/app/status.rb +68 -49
- data/lib/puma/binder.rb +234 -137
- data/lib/puma/cli.rb +28 -18
- data/lib/puma/client.rb +343 -230
- data/lib/puma/cluster/worker.rb +173 -0
- data/lib/puma/cluster/worker_handle.rb +94 -0
- data/lib/puma/cluster.rb +247 -232
- data/lib/puma/commonlogger.rb +2 -2
- data/lib/puma/configuration.rb +61 -51
- data/lib/puma/const.rb +42 -21
- data/lib/puma/control_cli.rb +109 -67
- data/lib/puma/detect.rb +29 -2
- data/lib/puma/dsl.rb +615 -123
- data/lib/puma/error_logger.rb +104 -0
- data/lib/puma/events.rb +55 -31
- data/lib/puma/io_buffer.rb +7 -5
- data/lib/puma/jruby_restart.rb +0 -58
- data/lib/puma/json_serialization.rb +96 -0
- data/lib/puma/launcher.rb +182 -69
- data/lib/puma/minissl/context_builder.rb +81 -0
- data/lib/puma/minissl.rb +161 -61
- data/lib/puma/null_io.rb +13 -1
- data/lib/puma/plugin/tmp_restart.rb +2 -0
- data/lib/puma/plugin.rb +7 -13
- data/lib/puma/queue_close.rb +26 -0
- data/lib/puma/rack/builder.rb +3 -5
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +85 -316
- data/lib/puma/request.rb +472 -0
- data/lib/puma/runner.rb +48 -55
- data/lib/puma/server.rb +303 -695
- data/lib/puma/single.rb +11 -67
- data/lib/puma/state_file.rb +47 -8
- data/lib/puma/systemd.rb +46 -0
- data/lib/puma/thread_pool.rb +132 -82
- data/lib/puma/util.rb +21 -7
- data/lib/puma.rb +54 -0
- data/lib/rack/handler/puma.rb +5 -6
- data/tools/Dockerfile +16 -0
- data/tools/trickletest.rb +0 -1
- metadata +45 -29
- data/ext/puma_http11/io_buffer.c +0 -155
- data/lib/puma/accept_nonblock.rb +0 -23
- data/lib/puma/compat.rb +0 -14
- data/lib/puma/convenient.rb +0 -25
- data/lib/puma/daemon_ext.rb +0 -33
- data/lib/puma/delegation.rb +0 -13
- data/lib/puma/java_io_buffer.rb +0 -47
- data/lib/puma/rack/backports/uri/common_193.rb +0 -33
- data/lib/puma/tcp_logger.rb +0 -41
- data/tools/jungle/README.md +0 -19
- data/tools/jungle/init.d/README.md +0 -61
- data/tools/jungle/init.d/puma +0 -421
- data/tools/jungle/init.d/run-puma +0 -18
- data/tools/jungle/upstart/README.md +0 -61
- data/tools/jungle/upstart/puma-manager.conf +0 -31
- data/tools/jungle/upstart/puma.conf +0 -69
data/lib/puma.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Standard libraries
|
2
4
|
require 'socket'
|
3
5
|
require 'tempfile'
|
@@ -8,16 +10,68 @@ require 'stringio'
|
|
8
10
|
|
9
11
|
require 'thread'
|
10
12
|
|
13
|
+
require 'puma/puma_http11'
|
14
|
+
require 'puma/detect'
|
15
|
+
require 'puma/json_serialization'
|
16
|
+
|
11
17
|
module Puma
|
12
18
|
autoload :Const, 'puma/const'
|
13
19
|
autoload :Server, 'puma/server'
|
14
20
|
autoload :Launcher, 'puma/launcher'
|
15
21
|
|
22
|
+
# at present, MiniSSL::Engine is only defined in extension code (puma_http11),
|
23
|
+
# not in minissl.rb
|
24
|
+
HAS_SSL = const_defined?(:MiniSSL, false) && MiniSSL.const_defined?(:Engine, false)
|
25
|
+
|
26
|
+
HAS_UNIX_SOCKET = Object.const_defined? :UNIXSocket
|
27
|
+
|
28
|
+
if HAS_SSL
|
29
|
+
require 'puma/minissl'
|
30
|
+
else
|
31
|
+
module MiniSSL
|
32
|
+
# this class is defined so that it exists when Puma is compiled
|
33
|
+
# without ssl support, as Server and Reactor use it in rescue statements.
|
34
|
+
class SSLError < StandardError ; end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.ssl?
|
39
|
+
HAS_SSL
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.abstract_unix_socket?
|
43
|
+
@abstract_unix ||=
|
44
|
+
if HAS_UNIX_SOCKET
|
45
|
+
begin
|
46
|
+
::UNIXServer.new("\0puma.temp.unix").close
|
47
|
+
true
|
48
|
+
rescue ArgumentError # darwin
|
49
|
+
false
|
50
|
+
end
|
51
|
+
else
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# @!attribute [rw] stats_object=
|
16
57
|
def self.stats_object=(val)
|
17
58
|
@get_stats = val
|
18
59
|
end
|
19
60
|
|
61
|
+
# @!attribute [rw] stats_object
|
20
62
|
def self.stats
|
63
|
+
Puma::JSONSerialization.generate @get_stats.stats
|
64
|
+
end
|
65
|
+
|
66
|
+
# @!attribute [r] stats_hash
|
67
|
+
# @version 5.0.0
|
68
|
+
def self.stats_hash
|
21
69
|
@get_stats.stats
|
22
70
|
end
|
71
|
+
|
72
|
+
# Thread name is new in Ruby 2.3
|
73
|
+
def self.set_thread_name(name)
|
74
|
+
return unless Thread.current.respond_to?(:name=)
|
75
|
+
Thread.current.name = "puma #{name}"
|
76
|
+
end
|
23
77
|
end
|
data/lib/rack/handler/puma.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack/handler'
|
2
4
|
|
3
5
|
module Rack
|
@@ -28,9 +30,8 @@ module Rack
|
|
28
30
|
end
|
29
31
|
|
30
32
|
conf = ::Puma::Configuration.new(options, default_options) do |user_config, file_config, default_config|
|
31
|
-
user_config.quiet
|
32
|
-
|
33
33
|
if options.delete(:Verbose)
|
34
|
+
require 'rack/common_logger'
|
34
35
|
app = Rack::CommonLogger.new(app, STDOUT)
|
35
36
|
end
|
36
37
|
|
@@ -59,9 +60,7 @@ module Rack
|
|
59
60
|
conf
|
60
61
|
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
def self.run(app, options = {})
|
63
|
+
def self.run(app, **options)
|
65
64
|
conf = self.config(app, options)
|
66
65
|
|
67
66
|
events = options.delete(:Silent) ? ::Puma::Events.strings : ::Puma::Events.stdio
|
@@ -86,7 +85,7 @@ module Rack
|
|
86
85
|
"Verbose" => "Don't report each request (default: false)"
|
87
86
|
}
|
88
87
|
end
|
89
|
-
|
88
|
+
|
90
89
|
def self.set_host_port_to_config(host, port, config)
|
91
90
|
config.clear_binds! if host || port
|
92
91
|
|
data/tools/Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Use this Dockerfile to create minimal reproductions of issues
|
2
|
+
|
3
|
+
FROM ruby:3.1
|
4
|
+
|
5
|
+
# throw errors if Gemfile has been modified since Gemfile.lock
|
6
|
+
RUN bundle config --global frozen 1
|
7
|
+
|
8
|
+
WORKDIR /usr/src/app
|
9
|
+
|
10
|
+
COPY . .
|
11
|
+
RUN gem install bundler
|
12
|
+
RUN bundle install
|
13
|
+
RUN bundle exec rake compile
|
14
|
+
|
15
|
+
EXPOSE 9292
|
16
|
+
CMD bundle exec bin/puma test/rackup/hello.ru
|
data/tools/trickletest.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
11
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nio4r
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
description: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server
|
14
28
|
for Ruby/Rack applications. Puma is intended for use in both development and production
|
15
|
-
environments. It's great for highly
|
29
|
+
environments. It's great for highly parallel Ruby implementations such as Rubinius
|
16
30
|
and JRuby as well as as providing process worker support to support CRuby well.
|
17
31
|
email:
|
18
32
|
- evan@phx.io
|
@@ -30,14 +44,23 @@ files:
|
|
30
44
|
- bin/puma-wild
|
31
45
|
- bin/pumactl
|
32
46
|
- docs/architecture.md
|
47
|
+
- docs/compile_options.md
|
33
48
|
- docs/deployment.md
|
49
|
+
- docs/fork_worker.md
|
34
50
|
- docs/images/puma-connection-flow-no-reactor.png
|
35
51
|
- docs/images/puma-connection-flow.png
|
36
52
|
- docs/images/puma-general-arch.png
|
53
|
+
- docs/jungle/README.md
|
54
|
+
- docs/jungle/rc.d/README.md
|
55
|
+
- docs/jungle/rc.d/puma
|
56
|
+
- docs/jungle/rc.d/puma.conf
|
57
|
+
- docs/kubernetes.md
|
37
58
|
- docs/nginx.md
|
38
59
|
- docs/plugins.md
|
60
|
+
- docs/rails_dev_mode.md
|
39
61
|
- docs/restart.md
|
40
62
|
- docs/signals.md
|
63
|
+
- docs/stats.md
|
41
64
|
- docs/systemd.md
|
42
65
|
- ext/puma_http11/PumaHttp11Service.java
|
43
66
|
- ext/puma_http11/ext_help.h
|
@@ -47,67 +70,61 @@ files:
|
|
47
70
|
- ext/puma_http11/http11_parser.java.rl
|
48
71
|
- ext/puma_http11/http11_parser.rl
|
49
72
|
- ext/puma_http11/http11_parser_common.rl
|
50
|
-
- ext/puma_http11/io_buffer.c
|
51
73
|
- ext/puma_http11/mini_ssl.c
|
74
|
+
- ext/puma_http11/no_ssl/PumaHttp11Service.java
|
52
75
|
- ext/puma_http11/org/jruby/puma/Http11.java
|
53
76
|
- ext/puma_http11/org/jruby/puma/Http11Parser.java
|
54
77
|
- ext/puma_http11/org/jruby/puma/MiniSSL.java
|
55
78
|
- ext/puma_http11/puma_http11.c
|
56
79
|
- lib/puma.rb
|
57
|
-
- lib/puma/accept_nonblock.rb
|
58
80
|
- lib/puma/app/status.rb
|
59
81
|
- lib/puma/binder.rb
|
60
82
|
- lib/puma/cli.rb
|
61
83
|
- lib/puma/client.rb
|
62
84
|
- lib/puma/cluster.rb
|
85
|
+
- lib/puma/cluster/worker.rb
|
86
|
+
- lib/puma/cluster/worker_handle.rb
|
63
87
|
- lib/puma/commonlogger.rb
|
64
|
-
- lib/puma/compat.rb
|
65
88
|
- lib/puma/configuration.rb
|
66
89
|
- lib/puma/const.rb
|
67
90
|
- lib/puma/control_cli.rb
|
68
|
-
- lib/puma/convenient.rb
|
69
|
-
- lib/puma/daemon_ext.rb
|
70
|
-
- lib/puma/delegation.rb
|
71
91
|
- lib/puma/detect.rb
|
72
92
|
- lib/puma/dsl.rb
|
93
|
+
- lib/puma/error_logger.rb
|
73
94
|
- lib/puma/events.rb
|
74
95
|
- lib/puma/io_buffer.rb
|
75
|
-
- lib/puma/java_io_buffer.rb
|
76
96
|
- lib/puma/jruby_restart.rb
|
97
|
+
- lib/puma/json_serialization.rb
|
77
98
|
- lib/puma/launcher.rb
|
78
99
|
- lib/puma/minissl.rb
|
100
|
+
- lib/puma/minissl/context_builder.rb
|
79
101
|
- lib/puma/null_io.rb
|
80
102
|
- lib/puma/plugin.rb
|
81
103
|
- lib/puma/plugin/tmp_restart.rb
|
82
|
-
- lib/puma/
|
104
|
+
- lib/puma/queue_close.rb
|
83
105
|
- lib/puma/rack/builder.rb
|
84
106
|
- lib/puma/rack/urlmap.rb
|
85
107
|
- lib/puma/rack_default.rb
|
86
108
|
- lib/puma/reactor.rb
|
109
|
+
- lib/puma/request.rb
|
87
110
|
- lib/puma/runner.rb
|
88
111
|
- lib/puma/server.rb
|
89
112
|
- lib/puma/single.rb
|
90
113
|
- lib/puma/state_file.rb
|
91
|
-
- lib/puma/
|
114
|
+
- lib/puma/systemd.rb
|
92
115
|
- lib/puma/thread_pool.rb
|
93
116
|
- lib/puma/util.rb
|
94
117
|
- lib/rack/handler/puma.rb
|
95
|
-
- tools/
|
96
|
-
- tools/jungle/init.d/README.md
|
97
|
-
- tools/jungle/init.d/puma
|
98
|
-
- tools/jungle/init.d/run-puma
|
99
|
-
- tools/jungle/rc.d/README.md
|
100
|
-
- tools/jungle/rc.d/puma
|
101
|
-
- tools/jungle/rc.d/puma.conf
|
102
|
-
- tools/jungle/upstart/README.md
|
103
|
-
- tools/jungle/upstart/puma-manager.conf
|
104
|
-
- tools/jungle/upstart/puma.conf
|
118
|
+
- tools/Dockerfile
|
105
119
|
- tools/trickletest.rb
|
106
|
-
homepage:
|
120
|
+
homepage: https://puma.io
|
107
121
|
licenses:
|
108
122
|
- BSD-3-Clause
|
109
123
|
metadata:
|
110
|
-
|
124
|
+
bug_tracker_uri: https://github.com/puma/puma/issues
|
125
|
+
changelog_uri: https://github.com/puma/puma/blob/master/History.md
|
126
|
+
homepage_uri: https://puma.io
|
127
|
+
source_code_uri: https://github.com/puma/puma
|
111
128
|
post_install_message:
|
112
129
|
rdoc_options: []
|
113
130
|
require_paths:
|
@@ -123,10 +140,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
140
|
- !ruby/object:Gem::Version
|
124
141
|
version: '0'
|
125
142
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.7.6
|
143
|
+
rubygems_version: 3.2.26
|
128
144
|
signing_key:
|
129
145
|
specification_version: 4
|
130
|
-
summary: Puma is a simple, fast, threaded, and highly
|
146
|
+
summary: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server for
|
131
147
|
Ruby/Rack applications
|
132
148
|
test_files: []
|
data/ext/puma_http11/io_buffer.c
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
#define RSTRING_NOT_MODIFIED 1
|
2
|
-
#include "ruby.h"
|
3
|
-
|
4
|
-
#include <sys/types.h>
|
5
|
-
|
6
|
-
struct buf_int {
|
7
|
-
uint8_t* top;
|
8
|
-
uint8_t* cur;
|
9
|
-
|
10
|
-
size_t size;
|
11
|
-
};
|
12
|
-
|
13
|
-
#define BUF_DEFAULT_SIZE 4096
|
14
|
-
#define BUF_TOLERANCE 32
|
15
|
-
|
16
|
-
static void buf_free(struct buf_int* internal) {
|
17
|
-
xfree(internal->top);
|
18
|
-
xfree(internal);
|
19
|
-
}
|
20
|
-
|
21
|
-
static VALUE buf_alloc(VALUE self) {
|
22
|
-
VALUE buf;
|
23
|
-
struct buf_int* internal;
|
24
|
-
|
25
|
-
buf = Data_Make_Struct(self, struct buf_int, 0, buf_free, internal);
|
26
|
-
|
27
|
-
internal->size = BUF_DEFAULT_SIZE;
|
28
|
-
internal->top = ALLOC_N(uint8_t, BUF_DEFAULT_SIZE);
|
29
|
-
internal->cur = internal->top;
|
30
|
-
|
31
|
-
return buf;
|
32
|
-
}
|
33
|
-
|
34
|
-
static VALUE buf_append(VALUE self, VALUE str) {
|
35
|
-
struct buf_int* b;
|
36
|
-
size_t used, str_len, new_size;
|
37
|
-
|
38
|
-
Data_Get_Struct(self, struct buf_int, b);
|
39
|
-
|
40
|
-
used = b->cur - b->top;
|
41
|
-
|
42
|
-
StringValue(str);
|
43
|
-
str_len = RSTRING_LEN(str);
|
44
|
-
|
45
|
-
new_size = used + str_len;
|
46
|
-
|
47
|
-
if(new_size > b->size) {
|
48
|
-
size_t n = b->size + (b->size / 2);
|
49
|
-
uint8_t* top;
|
50
|
-
uint8_t* old;
|
51
|
-
|
52
|
-
new_size = (n > new_size ? n : new_size + BUF_TOLERANCE);
|
53
|
-
|
54
|
-
top = ALLOC_N(uint8_t, new_size);
|
55
|
-
old = b->top;
|
56
|
-
memcpy(top, old, used);
|
57
|
-
b->top = top;
|
58
|
-
b->cur = top + used;
|
59
|
-
b->size = new_size;
|
60
|
-
xfree(old);
|
61
|
-
}
|
62
|
-
|
63
|
-
memcpy(b->cur, RSTRING_PTR(str), str_len);
|
64
|
-
b->cur += str_len;
|
65
|
-
|
66
|
-
return self;
|
67
|
-
}
|
68
|
-
|
69
|
-
static VALUE buf_append2(int argc, VALUE* argv, VALUE self) {
|
70
|
-
struct buf_int* b;
|
71
|
-
size_t used, new_size;
|
72
|
-
int i;
|
73
|
-
VALUE str;
|
74
|
-
|
75
|
-
Data_Get_Struct(self, struct buf_int, b);
|
76
|
-
|
77
|
-
used = b->cur - b->top;
|
78
|
-
new_size = used;
|
79
|
-
|
80
|
-
for(i = 0; i < argc; i++) {
|
81
|
-
StringValue(argv[i]);
|
82
|
-
|
83
|
-
str = argv[i];
|
84
|
-
|
85
|
-
new_size += RSTRING_LEN(str);
|
86
|
-
}
|
87
|
-
|
88
|
-
if(new_size > b->size) {
|
89
|
-
size_t n = b->size + (b->size / 2);
|
90
|
-
uint8_t* top;
|
91
|
-
uint8_t* old;
|
92
|
-
|
93
|
-
new_size = (n > new_size ? n : new_size + BUF_TOLERANCE);
|
94
|
-
|
95
|
-
top = ALLOC_N(uint8_t, new_size);
|
96
|
-
old = b->top;
|
97
|
-
memcpy(top, old, used);
|
98
|
-
b->top = top;
|
99
|
-
b->cur = top + used;
|
100
|
-
b->size = new_size;
|
101
|
-
xfree(old);
|
102
|
-
}
|
103
|
-
|
104
|
-
for(i = 0; i < argc; i++) {
|
105
|
-
long str_len;
|
106
|
-
str = argv[i];
|
107
|
-
str_len = RSTRING_LEN(str);
|
108
|
-
memcpy(b->cur, RSTRING_PTR(str), str_len);
|
109
|
-
b->cur += str_len;
|
110
|
-
}
|
111
|
-
|
112
|
-
return self;
|
113
|
-
}
|
114
|
-
|
115
|
-
static VALUE buf_to_str(VALUE self) {
|
116
|
-
struct buf_int* b;
|
117
|
-
Data_Get_Struct(self, struct buf_int, b);
|
118
|
-
|
119
|
-
return rb_str_new((const char*)(b->top), b->cur - b->top);
|
120
|
-
}
|
121
|
-
|
122
|
-
static VALUE buf_used(VALUE self) {
|
123
|
-
struct buf_int* b;
|
124
|
-
Data_Get_Struct(self, struct buf_int, b);
|
125
|
-
|
126
|
-
return INT2FIX(b->cur - b->top);
|
127
|
-
}
|
128
|
-
|
129
|
-
static VALUE buf_capa(VALUE self) {
|
130
|
-
struct buf_int* b;
|
131
|
-
Data_Get_Struct(self, struct buf_int, b);
|
132
|
-
|
133
|
-
return INT2FIX(b->size);
|
134
|
-
}
|
135
|
-
|
136
|
-
static VALUE buf_reset(VALUE self) {
|
137
|
-
struct buf_int* b;
|
138
|
-
Data_Get_Struct(self, struct buf_int, b);
|
139
|
-
|
140
|
-
b->cur = b->top;
|
141
|
-
return self;
|
142
|
-
}
|
143
|
-
|
144
|
-
void Init_io_buffer(VALUE puma) {
|
145
|
-
VALUE buf = rb_define_class_under(puma, "IOBuffer", rb_cObject);
|
146
|
-
|
147
|
-
rb_define_alloc_func(buf, buf_alloc);
|
148
|
-
rb_define_method(buf, "<<", buf_append, 1);
|
149
|
-
rb_define_method(buf, "append", buf_append2, -1);
|
150
|
-
rb_define_method(buf, "to_str", buf_to_str, 0);
|
151
|
-
rb_define_method(buf, "to_s", buf_to_str, 0);
|
152
|
-
rb_define_method(buf, "used", buf_used, 0);
|
153
|
-
rb_define_method(buf, "capacity", buf_capa, 0);
|
154
|
-
rb_define_method(buf, "reset", buf_reset, 0);
|
155
|
-
}
|
data/lib/puma/accept_nonblock.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
|
3
|
-
module OpenSSL
|
4
|
-
module SSL
|
5
|
-
class SSLServer
|
6
|
-
unless public_method_defined? :accept_nonblock
|
7
|
-
def accept_nonblock
|
8
|
-
sock = @svr.accept_nonblock
|
9
|
-
|
10
|
-
begin
|
11
|
-
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
|
12
|
-
ssl.sync_close = true
|
13
|
-
ssl.accept if @start_immediately
|
14
|
-
ssl
|
15
|
-
rescue SSLError => ex
|
16
|
-
sock.close
|
17
|
-
raise ex
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/puma/compat.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# Provides code to work properly on 1.8 and 1.9
|
2
|
-
|
3
|
-
class String
|
4
|
-
unless method_defined? :bytesize
|
5
|
-
alias_method :bytesize, :size
|
6
|
-
end
|
7
|
-
|
8
|
-
unless method_defined? :byteslice
|
9
|
-
def byteslice(*arg)
|
10
|
-
enc = self.encoding
|
11
|
-
self.dup.force_encoding(Encoding::ASCII_8BIT).slice(*arg).force_encoding(enc)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/puma/convenient.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'puma/launcher'
|
4
|
-
require 'puma/configuration'
|
5
|
-
|
6
|
-
module Puma
|
7
|
-
def self.run(opts={})
|
8
|
-
cfg = Puma::Configuration.new do |user_config|
|
9
|
-
if port = opts[:port]
|
10
|
-
user_config.port port
|
11
|
-
end
|
12
|
-
|
13
|
-
user_config.quiet
|
14
|
-
|
15
|
-
yield c
|
16
|
-
end
|
17
|
-
|
18
|
-
cfg.clamp
|
19
|
-
|
20
|
-
events = Puma::Events.null
|
21
|
-
|
22
|
-
launcher = Puma::Launcher.new cfg, :events => events
|
23
|
-
launcher.run
|
24
|
-
end
|
25
|
-
end
|
data/lib/puma/daemon_ext.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Process
|
4
|
-
|
5
|
-
# This overrides the default version because it is broken if it
|
6
|
-
# exists.
|
7
|
-
|
8
|
-
if respond_to? :daemon
|
9
|
-
class << self
|
10
|
-
remove_method :daemon
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.daemon(nochdir=false, noclose=false)
|
15
|
-
exit if fork # Parent exits, child continues.
|
16
|
-
|
17
|
-
Process.setsid # Become session leader.
|
18
|
-
|
19
|
-
exit if fork # Zap session leader. See [1].
|
20
|
-
|
21
|
-
Dir.chdir "/" unless nochdir # Release old working directory.
|
22
|
-
|
23
|
-
if !noclose
|
24
|
-
STDIN.reopen File.open("/dev/null", "r")
|
25
|
-
|
26
|
-
null_out = File.open "/dev/null", "w"
|
27
|
-
STDOUT.reopen null_out
|
28
|
-
STDERR.reopen null_out
|
29
|
-
end
|
30
|
-
|
31
|
-
0
|
32
|
-
end
|
33
|
-
end
|
data/lib/puma/delegation.rb
DELETED
data/lib/puma/java_io_buffer.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'java'
|
4
|
-
|
5
|
-
# Conservative native JRuby/Java implementation of IOBuffer
|
6
|
-
# backed by a ByteArrayOutputStream and conversion between
|
7
|
-
# Ruby String and Java bytes
|
8
|
-
module Puma
|
9
|
-
class JavaIOBuffer < java.io.ByteArrayOutputStream
|
10
|
-
field_reader :buf
|
11
|
-
end
|
12
|
-
|
13
|
-
class IOBuffer
|
14
|
-
BUF_DEFAULT_SIZE = 4096
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@buf = JavaIOBuffer.new(BUF_DEFAULT_SIZE)
|
18
|
-
end
|
19
|
-
|
20
|
-
def reset
|
21
|
-
@buf.reset
|
22
|
-
end
|
23
|
-
|
24
|
-
def <<(str)
|
25
|
-
bytes = str.to_java_bytes
|
26
|
-
@buf.write(bytes, 0, bytes.length)
|
27
|
-
end
|
28
|
-
|
29
|
-
def append(*strs)
|
30
|
-
strs.each { |s| self << s; }
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_s
|
34
|
-
String.from_java_bytes @buf.to_byte_array
|
35
|
-
end
|
36
|
-
|
37
|
-
alias_method :to_str, :to_s
|
38
|
-
|
39
|
-
def used
|
40
|
-
@buf.size
|
41
|
-
end
|
42
|
-
|
43
|
-
def capacity
|
44
|
-
@buf.buf.length
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# :stopdoc:
|
2
|
-
|
3
|
-
require 'uri/common'
|
4
|
-
|
5
|
-
# Issue:
|
6
|
-
# http://bugs.ruby-lang.org/issues/5925
|
7
|
-
#
|
8
|
-
# Relevant commit:
|
9
|
-
# https://github.com/ruby/ruby/commit/edb7cdf1eabaff78dfa5ffedfbc2e91b29fa9ca1
|
10
|
-
|
11
|
-
|
12
|
-
module URI
|
13
|
-
begin
|
14
|
-
256.times do |i|
|
15
|
-
TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
|
16
|
-
end
|
17
|
-
TBLENCWWWCOMP_[' '] = '+'
|
18
|
-
TBLENCWWWCOMP_.freeze
|
19
|
-
|
20
|
-
256.times do |i|
|
21
|
-
h, l = i>>4, i&15
|
22
|
-
TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
|
23
|
-
TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
|
24
|
-
TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
|
25
|
-
TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
|
26
|
-
end
|
27
|
-
TBLDECWWWCOMP_['+'] = ' '
|
28
|
-
TBLDECWWWCOMP_.freeze
|
29
|
-
rescue Exception
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# :startdoc:
|
data/lib/puma/tcp_logger.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Puma
|
4
|
-
class TCPLogger
|
5
|
-
def initialize(logger, app, quiet=false)
|
6
|
-
@logger = logger
|
7
|
-
@app = app
|
8
|
-
@quiet = quiet
|
9
|
-
end
|
10
|
-
|
11
|
-
FORMAT = "%s - %s"
|
12
|
-
|
13
|
-
def log(who, str)
|
14
|
-
now = Time.now.strftime("%d/%b/%Y %H:%M:%S")
|
15
|
-
|
16
|
-
log_str = "#{now} - #{who} - #{str}"
|
17
|
-
|
18
|
-
case @logger
|
19
|
-
when IO
|
20
|
-
@logger.puts log_str
|
21
|
-
when Events
|
22
|
-
@logger.log log_str
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def call(env, socket)
|
27
|
-
who = env[Const::REMOTE_ADDR]
|
28
|
-
log who, "connected" unless @quiet
|
29
|
-
|
30
|
-
env['log'] = lambda { |str| log(who, str) }
|
31
|
-
|
32
|
-
begin
|
33
|
-
@app.call env, socket
|
34
|
-
rescue Object => e
|
35
|
-
log who, "exception: #{e.message} (#{e.class})"
|
36
|
-
else
|
37
|
-
log who, "disconnected" unless @quiet
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|