unicorn 5.8.0 → 6.1.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
  SHA256:
3
- metadata.gz: d3166eb1eac760d39cac35a6fc46332d6a6a2ee75bdf594118fddb3c6a959f6d
4
- data.tar.gz: 3e18599fef201efdd79c67eb126aab35787c196054313a727d6bb184f830587e
3
+ metadata.gz: cd2fc6250af1faf8048df529538386a6974dcbd1aac58db683a710b804bae1e8
4
+ data.tar.gz: 50aeca90aada5aeb9869cf3885681fe9029bee6183c99c8b85afb3d0803b479f
5
5
  SHA512:
6
- metadata.gz: 356f0c951cee2e69de8e49169f2c9560e6fead9fe759bd0af5a51097888a23794eb17175ff5393f07d1fadec5678215b494b688cdeeadb8a95c37201f3808a92
7
- data.tar.gz: ffa1f8781231ac559157310d2d235340522c6c1cccf69be3d87d432659d2a2a7a39d744a84306c1f4292a3f6b36141cc1bb80497f1a9047902ec0d592f77871b
6
+ metadata.gz: 83ebf917cc17380114648c22f9cb3ad59bda6125d23781e64cd89bb8936bf17bc6bb7292933f9433f1397901022683a63b241d512b31ea1b85e5bc791a10a74e
7
+ data.tar.gz: d36730df71b5b131de61037f2838b743d587b93b1eeb70eea1956de4aabc9051485626d38debaadd3d5c3ee3c2738ca72f9a9cbc9bafb6eff9e11f08ad272275
data/.manifest CHANGED
@@ -47,6 +47,7 @@ examples/unicorn@.service
47
47
  ext/unicorn_http/CFLAGS
48
48
  ext/unicorn_http/c_util.h
49
49
  ext/unicorn_http/common_field_optimization.h
50
+ ext/unicorn_http/epollexclusive.h
50
51
  ext/unicorn_http/ext_help.h
51
52
  ext/unicorn_http/extconf.rb
52
53
  ext/unicorn_http/global_variables.h
@@ -66,6 +67,7 @@ lib/unicorn/http_server.rb
66
67
  lib/unicorn/launcher.rb
67
68
  lib/unicorn/oob_gc.rb
68
69
  lib/unicorn/preread_input.rb
70
+ lib/unicorn/select_waiter.rb
69
71
  lib/unicorn/socket_helper.rb
70
72
  lib/unicorn/stream_input.rb
71
73
  lib/unicorn/tee_input.rb
@@ -87,7 +89,6 @@ t/detach.ru
87
89
  t/env.ru
88
90
  t/fails-rack-lint.ru
89
91
  t/heartbeat-timeout.ru
90
- t/hijack.ru
91
92
  t/listener_names.ru
92
93
  t/my-tap-lib.sh
93
94
  t/oob_gc.ru
@@ -125,7 +126,6 @@ t/t0022-listener_names-preload_app.sh
125
126
  t/t0100-rack-input-tests.sh
126
127
  t/t0116-client_body_buffer_size.sh
127
128
  t/t0116.ru
128
- t/t0200-rack-hijack.sh
129
129
  t/t0300-no-default-middleware.sh
130
130
  t/t0301-no-default-middleware-ignored-in-config.sh
131
131
  t/t0301.ru
@@ -158,4 +158,5 @@ test/unit/test_stream_input.rb
158
158
  test/unit/test_tee_input.rb
159
159
  test/unit/test_upload.rb
160
160
  test/unit/test_util.rb
161
+ test/unit/test_waiter.rb
161
162
  unicorn.gemspec
data/.olddoc.yml CHANGED
@@ -3,7 +3,7 @@ cgit_url: https://yhbt.net/unicorn.git
3
3
  rdoc_url: https://yhbt.net/unicorn/
4
4
  ml_url:
5
5
  - https://yhbt.net/unicorn-public/
6
- - http://ou63pmih66umazou.onion/unicorn-public/
6
+ - http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/unicorn-public/
7
7
  merge_html:
8
8
  unicorn_1: Documentation/unicorn.1.html
9
9
  unicorn_rails_1: Documentation/unicorn_rails.1.html
@@ -13,10 +13,13 @@ noindex:
13
13
  - TODO
14
14
  - unicorn_rails_1
15
15
  public_email: unicorn-public@yhbt.net
16
+ imap_url:
17
+ - imaps://yhbt.net/inbox.comp.lang.ruby.unicorn.0
18
+ - imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn.0
16
19
  nntp_url:
17
- - nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
18
- - nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn
20
+ - nntps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
21
+ - nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn
19
22
  - nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
20
23
  source_code:
21
24
  - git clone https://yhbt.net/unicorn.git
22
- - torsocks git clone http://ou63pmih66umazou.onion/unicorn.git
25
+ - torsocks git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/unicorn.git
data/CONTRIBUTORS CHANGED
@@ -1,5 +1,9 @@
1
- Unicorn developers (let us know if we forgot you):
2
- * Eric Wong (BDFL, BOFH)
1
+ Unicorn developers (let us know if we forgot you, ...or if you no longer wish
2
+ to be associated with the doofus running this disaster :P):
3
+ * Eric Wong (Bozo Doofus For Life, Bastard Operator From Hell)
4
+
5
+ There's numerous contributors over email the years, all of our mail
6
+ is archived @ https://yhbt.net/unicorn-public/
3
7
  * Suraj N. Kurapati
4
8
  * Andrey Stikheev
5
9
  * Wayne Larsen
data/GIT-VERSION-FILE CHANGED
@@ -1 +1 @@
1
- GIT_VERSION = 5.8.0
1
+ GIT_VERSION = 6.1.0
data/GIT-VERSION-GEN CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- DEF_VER = "v5.8.0"
2
+ DEF_VER = "v6.1.0"
3
3
  CONSTANT = "Unicorn::Const::UNICORN_VERSION"
4
4
  RVF = "lib/unicorn/version.rb"
5
5
  GVF = "GIT-VERSION-FILE"
data/GNUmakefile CHANGED
@@ -42,13 +42,13 @@ ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
42
42
  ext_src := $(sort $(wildcard $(ext)/*.c) $(ext_h) $(ext)/unicorn_http.c)
43
43
  ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
44
44
  ext_dir := $(ext_pfx)/$(ext)
45
- $(ext)/extconf.rb: $(wildcard $(ext)/*.h)
45
+ $(ext)/extconf.rb:
46
46
  @>>$@
47
47
  $(ext_dir) $(tmp_bin) man/man1 doc/man1 pkg t/trash:
48
48
  @mkdir -p $@
49
49
  $(ext_pfx)/$(ext)/%: $(ext)/% | $(ext_dir)
50
50
  $(INSTALL) -m 644 $< $@
51
- $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_h) | $(ext_dir)
51
+ $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb | $(ext_dir)
52
52
  $(RM) -f $(@D)/*.o
53
53
  cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
54
54
  ext_sfx := _ext.$(DLEXT)
data/HACKING CHANGED
@@ -50,9 +50,6 @@ programming experience will come in handy (or be learned) here.
50
50
 
51
51
  === Documentation
52
52
 
53
- Due to the lack of RDoc-to-manpage converters we know about, we're
54
- writing manpages in Markdown and converting to troff/HTML with Pandoc.
55
-
56
53
  Please wrap documentation at 72 characters-per-line or less (long URLs
57
54
  are exempt) so it is comfortably readable from terminals.
58
55
 
@@ -63,7 +60,7 @@ becomes unavailable.
63
60
 
64
61
  === Ruby/C Compatibility
65
62
 
66
- We target mainline Ruby 1.9.3 and later. We need the Ruby
63
+ We target C Ruby 2.0 and later. We need the Ruby
67
64
  implementation to support fork, exec, pipe, UNIX signals, access to
68
65
  integer file descriptors and ability to use unlinked files.
69
66
 
@@ -102,10 +99,6 @@ don't email the git mailing list or maintainer with Unicorn patches :)
102
99
 
103
100
  == Building a Gem
104
101
 
105
- In order to build the gem, you must install the following components:
106
-
107
- * pandoc
108
-
109
102
  You can build the Unicorn gem with the following command:
110
103
 
111
104
  gmake gem
data/ISSUES CHANGED
@@ -20,6 +20,10 @@ can interoperate with any bug tracker which can Cc: us plain-text to
20
20
  mailto:unicorn-public@yhbt.net This includes the Debian BTS
21
21
  at https://bugs.debian.org/unicorn and possibly others.
22
22
 
23
+ unicorn is a server; it does not depend on graphics/audio. Nobody
24
+ communicating with us will ever be expected to go through the trouble
25
+ of setting up graphics nor audio support.
26
+
23
27
  If your issue is of a sensitive nature or you're just shy in public,
24
28
  use anonymity tools such as Tor or Mixmaster; and rely on the public
25
29
  mail archives for responses. Be sure to scrub sensitive log messages
@@ -73,27 +77,21 @@ document distributed with git) on guidelines for patch submission.
73
77
 
74
78
  == Contact Info
75
79
 
76
- * public: mailto:unicorn-public@yhbt.net
77
- * nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
78
- * nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
79
- * imaps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn.0
80
- * https://yhbt.net/unicorn-public/
81
- * http://ou63pmih66umazou.onion/unicorn-public/
82
-
83
- Mailing list subscription is optional, so Cc: all participants.
80
+ Mail is publicly-archived, SMTP subscription is discouraged to avoid
81
+ servers being a single-point-of-failure, so Cc: all participants.
84
82
 
85
- You can follow along via NNTP or IMAP (read-only):
83
+ The HTTP(S) archives have links to per-thread Atom feeds and downloadable
84
+ mboxes. Read-only IMAP(S) folders and NNTP(S) newsgroups are also available.
86
85
 
87
- nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
88
- nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
89
- imaps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn.0
90
- imap://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn.0
91
-
92
- Or Atom feeds:
86
+ * https://yhbt.net/unicorn-public/
87
+ * http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/unicorn-public/
88
+ * imaps://yhbt.net/inbox.comp.lang.ruby.unicorn.0
89
+ * imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn.0
90
+ * nntps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
91
+ * nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
93
92
 
94
- https://yhbt.net/unicorn-public/new.atom
95
- http://ou63pmih66umazou.onion/unicorn-public/new.atom
93
+ Full Atom feeds:
94
+ * https://yhbt.net/unicorn-public/new.atom
95
+ * http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/unicorn-public/new.atom
96
96
 
97
- The HTML archives at https://yhbt.net/unicorn-public/
98
- also has links to per-thread Atom feeds and downloadable
99
- mboxes.
97
+ We only accept plain-text mail: mailto:unicorn-public@yhbt.net
data/LATEST CHANGED
@@ -1,23 +1,24 @@
1
- === unicorn 5.5.0 / 2019-03-04 00:41 UTC
2
-
3
- Mostly identical to 5.5.0.pre1, which I didn't hear any feedback
4
- from:
5
-
6
- https://bogomips.org/unicorn-public/20181220222842.GA27382@dcvr/
7
-
8
- > Jeremy Evans contributed the "default_middleware" configuration option:
9
- >
10
- > https://bogomips.org/unicorn-public/20180913192055.GD48926@jeremyevans.local/
11
- >
12
- > Jeremy also contributed the ability to use separate groups for the process
13
- > and log files:
14
- >
15
- > https://bogomips.org/unicorn-public/20180913192449.GE48926@jeremyevans.local/
16
- >
17
- > There's also a couple of uninteresting minor optimizations and
18
- > documentation additions.
19
-
20
- Otherwise, there's one extra change to use
21
- rb_gc_register_mark_object which is finally a documented part of
22
- the Ruby C-API, but has existed since the 1.9 days.
1
+ === unicorn 6.0.0 - no more recycling Rack env / 2021-03-17 06:38 UTC
2
+
3
+ This release allocates a new Rack `env' hash for every request.
4
+ This is done for safety with internally-(thread|event)-using Rack
5
+ apps which expect to use `env' after the normal Rack response is
6
+ complete, but without relying on rack.hijack[1]. Thanks to
7
+ Dirkjan Bussink <d.bussink@gmail.com> for the patch:
8
+
9
+ https://yhbt.net/unicorn-public/66A68DD8-83EF-4C7A-80E8-3F1F7AB31670@github.com/
10
+
11
+ The major version is bumped since:
12
+
13
+ 1) there are performance regressions for some simple Rack apps
14
+
15
+ 2) unsupported 3rd-party monkey patches which previously
16
+ relied on this behavior may be broken (our version of
17
+ OobGC was).
18
+
19
+ The test suite is also more reliable on multi-core systems
20
+ and Ruby 3.x.
21
+
22
+ [1] thread from 2017 around rack.hijack safety:
23
+ https://yhbt.net/unicorn-public/CAAtdryPG3nLuyo0jxfYW1YHu1Q+ZpkLkd4KdWC8vA46B5haZxw@mail.gmail.com/
23
24
 
data/NEWS CHANGED
@@ -1,3 +1,135 @@
1
+ === unicorn 6.0.0 - no more recycling Rack env / 2021-03-17 06:38 UTC
2
+
3
+ This release allocates a new Rack `env' hash for every request.
4
+ This is done for safety with internally-(thread|event)-using Rack
5
+ apps which expect to use `env' after the normal Rack response is
6
+ complete, but without relying on rack.hijack[1]. Thanks to
7
+ Dirkjan Bussink <d.bussink@gmail.com> for the patch:
8
+
9
+ https://yhbt.net/unicorn-public/66A68DD8-83EF-4C7A-80E8-3F1F7AB31670@github.com/
10
+
11
+ The major version is bumped since:
12
+
13
+ 1) there are performance regressions for some simple Rack apps
14
+
15
+ 2) unsupported 3rd-party monkey patches which previously
16
+ relied on this behavior may be broken (our version of
17
+ OobGC was).
18
+
19
+ The test suite is also more reliable on multi-core systems
20
+ and Ruby 3.x.
21
+
22
+ [1] thread from 2017 around rack.hijack safety:
23
+ https://yhbt.net/unicorn-public/CAAtdryPG3nLuyo0jxfYW1YHu1Q+ZpkLkd4KdWC8vA46B5haZxw@mail.gmail.com/
24
+
25
+ === unicorn 5.8.0 - rack.after_reply support / 2020-12-24 20:39 UTC
26
+
27
+ This release supports env['rack.after_reply'] which allows
28
+ rack middleware to pass lambdas to be executed after the client
29
+ connection is closed, matching functionality in Puma.
30
+
31
+ Thanks to Blake Williams for this patch:
32
+ https://yhbt.net/unicorn-public/9873E53C-04D3-4759-9678-CA17DBAEF7B7@blakewilliams.me/
33
+
34
+ The top-level of our website is now simpler and no longer
35
+ redundant with the contents of https://yhbt.net/unicorn/README.html
36
+ (which contains the old content)
37
+
38
+ === unicorn 5.7.0 / 2020-09-08 08:41 UTC
39
+
40
+ Relaxed Ruby version requirements for Ruby 3.0.0dev.
41
+ Thanks to Jean Boussier for testing
42
+
43
+ === unicorn 5.6.0 - early_hints support / 2020-07-26 01:52 UTC
44
+
45
+ This release adds support for the early_hints configurator
46
+ directive for the 'rack.early_hints' API used by Rails 5.2+.
47
+
48
+ Thanks to Jean Boussier for the patch.
49
+
50
+ Link: https://yhbt.net/unicorn-public/242F0859-0F83-4F14-A0FF-5BE392BB01E6@shopify.com/
51
+
52
+ === unicorn 5.5.5 / 2020-04-27 02:48 UTC
53
+
54
+ This release fixes a bug for users of multiple listeners setups
55
+ where a busy listen socket could starve other listeners.
56
+
57
+ Thanks to Stan Hu for reporting and testing.
58
+
59
+ No need to upgrade if you're using a single listen socket.
60
+
61
+ Link: https://yhbt.net/unicorn-public/CAMBWrQ=Yh42MPtzJCEO7XryVknDNetRMuA87irWfqVuLdJmiBQ@mail.gmail.com/
62
+
63
+ === unicorn 5.5.4 / 2020-03-24 22:10 UTC
64
+
65
+ One change to improve RFC 7230 conformance in the HTTP parser:
66
+
67
+ https://yhbt.net/unicorn-public/20200319022823.32472-1-bofh@yhbt.net/
68
+
69
+ === unicorn 5.5.3 / 2020-01-31 20:39 UTC
70
+
71
+ Documentation updates to switch bogomips.org to yhbt.net since
72
+ the .org TLD won't be affordable in the near future.
73
+
74
+ There's also a few minor test cleanups.
75
+
76
+ === unicorn 5.5.2 / 2019-12-20 02:08 UTC
77
+
78
+ Thanks to Terry Scheingeld, we now workaround a Ruby bug
79
+ and can now run with taint checks enabled:
80
+ <https://bugs.ruby-lang.org/issues/14485>
81
+ <https://bogomips.org/unicorn-public/CABg1sXrvGv9G6CDQxePDUqTe6N-5UpLXm7eG3YQO=dda-Cgg7A@mail.gmail.com/>
82
+
83
+ There's also a few documentation updates and building packages
84
+ from source is easier since pandoc is no longer a dependency
85
+ (and I can no longer afford the bandwidth or space to install
86
+ it).
87
+
88
+ Eric Wong (7):
89
+ test/benchmark/ddstream: demo for slowly reading clients
90
+ test/benchmark/readinput: demo for slowly uploading clients
91
+ test/benchmark/uconnect: test for accept loop speed
92
+ examples/unicorn@.service: note the NonBlocking flag
93
+ Merge remote-tracking branch 'origin/ts/tmpio'
94
+ test_util: get rid of some unused variables in tests
95
+ doc: replace pandoc-"Markdown" with real manpages
96
+
97
+ Terry Scheingeld (1):
98
+ tmpio: workaround File#path being tainted on unlink
99
+
100
+ === unicorn 5.5.1 / 2019-05-06 06:40 UTC
101
+
102
+ This release fixes and works around issues from v5.5.0 (2019-03-04)
103
+
104
+ Stephen Demjanenko worked around a pipe resource accounting bug
105
+ present in old Linux kernels. Linux 3.x users from 3.16.57 and
106
+ on are unaffected. Linux 4.x users from 4.9 and on are
107
+ unaffected.
108
+
109
+ https://bogomips.org/unicorn-public/1556922018-24096-1-git-send-email-sdemjanenko@gmail.com/
110
+
111
+ Stan Pitucha reported a bug with the old `unicorn_rails' wrapper
112
+ (intended for Rails 2.x users) which was promptly fixed by
113
+ Jeremy Evans:
114
+
115
+ https://bogomips.org/unicorn-public/CAJ2_uEPifcv_ux4sX=t0C4zHTHGhqVfcLcSB2kTU3Rb_6pQ3nw@mail.gmail.com/
116
+
117
+ There's also some doc updates to warn users off `unicorn_rails';
118
+ the homepage is now energy-efficient for OLEDs and CRTs;
119
+ and I'm no longer advertising mailing list subscriptions
120
+ (because I hate centralization and mail archives are the priority)
121
+
122
+ Eric Wong (3):
123
+ doc: unicorn_rails: clarify that it is intended for rails <= 2.x
124
+ doc: stop advertising mailing list subscription
125
+ doc: switch homepage to dark216
126
+
127
+ Jeremy Evans (1):
128
+ unicorn_rails: fix regression with Rails >= 3.x in app build
129
+
130
+ Stephen Demjanenko (1):
131
+ Rescue failed pipe resizes due to permissions
132
+
1
133
  === unicorn 5.5.0 / 2019-03-04 00:41 UTC
2
134
 
3
135
  Mostly identical to 5.5.0.pre1, which I didn't hear any feedback
data/README CHANGED
@@ -12,8 +12,7 @@ both the the request and response in between unicorn and slow clients.
12
12
  cut out everything that is better supported by the operating system,
13
13
  {nginx}[https://nginx.org/] or {Rack}[https://rack.github.io/].
14
14
 
15
- * Compatible with Ruby 1.9.3 and later.
16
- unicorn 4.x remains supported for Ruby 1.8 users.
15
+ * Compatible with Ruby 2.0.0 and later.
17
16
 
18
17
  * Process management: unicorn will reap and restart workers that
19
18
  die from broken apps. There is no need to manage multiple processes
@@ -138,13 +137,13 @@ information on the {mailing list}[mailto:unicorn-public@yhbt.net].
138
137
  The mailing list is archived at https://yhbt.net/unicorn-public/
139
138
 
140
139
  Read-only NNTP access is available at:
141
- nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn and
140
+ nntps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn and
142
141
  nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
143
142
 
144
143
  Read-only IMAP access is also avaialble at:
145
- imaps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn.0 and
146
- imap://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn.0
147
- AUTH=ANONYMOUS mechanism is supported, as is any username+password
144
+ imaps://yhbt.net/inbox.comp.lang.ruby.unicorn.0 and
145
+ imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn.0
146
+ The AUTH=ANONYMOUS mechanism is supported, as is any username+password
148
147
  combination.
149
148
 
150
149
  For the latest on unicorn releases, you may also finger us at
data/Sandbox CHANGED
@@ -87,7 +87,7 @@ For now workarounds include doing one of the following:
87
87
 
88
88
  3. Explicitly setting RUBYLIB or $LOAD_PATH to include any gem path
89
89
  where the unicorn gem is installed
90
- (e.g. /usr/lib/ruby/gems/1.9.3/gems/unicorn-VERSION/lib)
90
+ (e.g. /usr/lib/ruby/gems/3.0.0/gems/unicorn-VERSION/lib)
91
91
 
92
92
  === RUBYOPT pollution from SIGUSR2 upgrades
93
93
 
@@ -8,23 +8,15 @@
8
8
 
9
9
  #include <unistd.h>
10
10
  #include <assert.h>
11
+ #include <limits.h>
11
12
 
12
13
  #define MIN(a,b) (a < b ? a : b)
13
14
  #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
14
15
 
15
- #ifndef SIZEOF_OFF_T
16
- # define SIZEOF_OFF_T 4
17
- # warning SIZEOF_OFF_T not defined, guessing 4. Did you run extconf.rb?
18
- #endif
19
-
20
- #if SIZEOF_OFF_T == 4
21
- # define UH_OFF_T_MAX 0x7fffffff
22
- #elif SIZEOF_OFF_T == 8
23
- # if SIZEOF_LONG == 4
24
- # define UH_OFF_T_MAX 0x7fffffffffffffffLL
25
- # else
26
- # define UH_OFF_T_MAX 0x7fffffffffffffff
27
- # endif
16
+ #if SIZEOF_OFF_T == SIZEOF_INT
17
+ # define UH_OFF_T_MAX INT_MAX
18
+ #elif SIZEOF_OFF_T == SIZEOF_LONG_LONG
19
+ # define UH_OFF_T_MAX LLONG_MAX
28
20
  #else
29
21
  # error off_t size unknown for this platform!
30
22
  #endif /* SIZEOF_OFF_T check */
@@ -83,7 +83,6 @@ static void init_common_fields(void)
83
83
  struct common_field *cf = common_http_fields;
84
84
  char tmp[64];
85
85
 
86
- id_uminus = rb_intern("-@");
87
86
  memcpy(tmp, HTTP_PREFIX, HTTP_PREFIX_LEN);
88
87
 
89
88
  for(i = ARRAY_SIZE(common_http_fields); --i >= 0; cf++) {
@@ -0,0 +1,124 @@
1
+ /*
2
+ * This is only intended for use inside a unicorn worker, nowhere else.
3
+ * EPOLLEXCLUSIVE somewhat mitigates the thundering herd problem for
4
+ * mostly idle processes since we can't use blocking accept4.
5
+ * This is NOT intended for use with multi-threaded servers, nor
6
+ * single-threaded multi-client ("C10K") servers or anything advanced
7
+ * like that. This use of epoll is only appropriate for a primitive,
8
+ * single-client, single-threaded servers like unicorn that need to
9
+ * support SIGKILL timeouts and parent death detection.
10
+ */
11
+ #if defined(HAVE_EPOLL_CREATE1)
12
+ # include <sys/epoll.h>
13
+ # include <errno.h>
14
+ # include <ruby/io.h>
15
+ # include <ruby/thread.h>
16
+ #endif /* __linux__ */
17
+
18
+ #if defined(EPOLLEXCLUSIVE) && defined(HAVE_EPOLL_CREATE1)
19
+ # define USE_EPOLL (1)
20
+ #else
21
+ # define USE_EPOLL (0)
22
+ #endif
23
+
24
+ #if USE_EPOLL
25
+ /*
26
+ * :nodoc:
27
+ * returns IO object if EPOLLEXCLUSIVE works and arms readers
28
+ */
29
+ static VALUE prep_readers(VALUE cls, VALUE readers)
30
+ {
31
+ long i;
32
+ int epfd = epoll_create1(EPOLL_CLOEXEC);
33
+ VALUE epio;
34
+
35
+ if (epfd < 0) rb_sys_fail("epoll_create1");
36
+
37
+ epio = rb_funcall(cls, rb_intern("for_fd"), 1, INT2NUM(epfd));
38
+
39
+ Check_Type(readers, T_ARRAY);
40
+ for (i = 0; i < RARRAY_LEN(readers); i++) {
41
+ int rc;
42
+ struct epoll_event e;
43
+ rb_io_t *fptr;
44
+ VALUE io = rb_ary_entry(readers, i);
45
+
46
+ e.data.u64 = i; /* the reason readers shouldn't change */
47
+
48
+ /*
49
+ * I wanted to use EPOLLET here, but maintaining our own
50
+ * equivalent of ep->rdllist in Ruby-space doesn't fit
51
+ * our design at all (and the kernel already has it's own
52
+ * code path for doing it). So let the kernel spend
53
+ * cycles on maintaining level-triggering.
54
+ */
55
+ e.events = EPOLLEXCLUSIVE | EPOLLIN;
56
+ io = rb_io_get_io(io);
57
+ GetOpenFile(io, fptr);
58
+ rc = epoll_ctl(epfd, EPOLL_CTL_ADD, fptr->fd, &e);
59
+ if (rc < 0) rb_sys_fail("epoll_ctl");
60
+ }
61
+ return epio;
62
+ }
63
+ #endif /* USE_EPOLL */
64
+
65
+ #if USE_EPOLL
66
+ struct ep_wait {
67
+ struct epoll_event *events;
68
+ rb_io_t *fptr;
69
+ int maxevents;
70
+ int timeout_msec;
71
+ };
72
+
73
+ static void *do_wait(void *ptr) /* runs w/o GVL */
74
+ {
75
+ struct ep_wait *epw = ptr;
76
+
77
+ return (void *)(long)epoll_wait(epw->fptr->fd, epw->events,
78
+ epw->maxevents, epw->timeout_msec);
79
+ }
80
+
81
+ /* :nodoc: */
82
+ /* readers must not change between prepare_readers and get_readers */
83
+ static VALUE
84
+ get_readers(VALUE epio, VALUE ready, VALUE readers, VALUE timeout_msec)
85
+ {
86
+ struct ep_wait epw;
87
+ long i, n;
88
+ VALUE buf;
89
+
90
+ Check_Type(ready, T_ARRAY);
91
+ Check_Type(readers, T_ARRAY);
92
+ epw.maxevents = RARRAY_LENINT(readers);
93
+ buf = rb_str_buf_new(sizeof(struct epoll_event) * epw.maxevents);
94
+ epw.events = (struct epoll_event *)RSTRING_PTR(buf);
95
+ epio = rb_io_get_io(epio);
96
+ GetOpenFile(epio, epw.fptr);
97
+
98
+ epw.timeout_msec = NUM2INT(timeout_msec);
99
+ n = (long)rb_thread_call_without_gvl(do_wait, &epw, RUBY_UBF_IO, NULL);
100
+ if (n < 0) {
101
+ if (errno != EINTR) rb_sys_fail("epoll_wait");
102
+ n = 0;
103
+ }
104
+ /* Linux delivers events in order received */
105
+ for (i = 0; i < n; i++) {
106
+ struct epoll_event *ev = &epw.events[i];
107
+ VALUE obj = rb_ary_entry(readers, ev->data.u64);
108
+
109
+ if (RTEST(obj))
110
+ rb_ary_push(ready, obj);
111
+ }
112
+ rb_str_resize(buf, 0);
113
+ return Qfalse;
114
+ }
115
+ #endif /* USE_EPOLL */
116
+
117
+ static void init_epollexclusive(VALUE mUnicorn)
118
+ {
119
+ #if USE_EPOLL
120
+ VALUE cWaiter = rb_define_class_under(mUnicorn, "Waiter", rb_cIO);
121
+ rb_define_singleton_method(cWaiter, "prep_readers", prep_readers, 1);
122
+ rb_define_method(cWaiter, "get_readers", get_readers, 3);
123
+ #endif
124
+ }
@@ -8,30 +8,6 @@
8
8
  # define assert_frozen(f) do {} while (0)
9
9
  #endif /* !defined(OBJ_FROZEN) */
10
10
 
11
- #if !defined(OFFT2NUM)
12
- # if SIZEOF_OFF_T == SIZEOF_LONG
13
- # define OFFT2NUM(n) LONG2NUM(n)
14
- # else
15
- # define OFFT2NUM(n) LL2NUM(n)
16
- # endif
17
- #endif /* ! defined(OFFT2NUM) */
18
-
19
- #if !defined(SIZET2NUM)
20
- # if SIZEOF_SIZE_T == SIZEOF_LONG
21
- # define SIZET2NUM(n) ULONG2NUM(n)
22
- # else
23
- # define SIZET2NUM(n) ULL2NUM(n)
24
- # endif
25
- #endif /* ! defined(SIZET2NUM) */
26
-
27
- #if !defined(NUM2SIZET)
28
- # if SIZEOF_SIZE_T == SIZEOF_LONG
29
- # define NUM2SIZET(n) ((size_t)NUM2ULONG(n))
30
- # else
31
- # define NUM2SIZET(n) ((size_t)NUM2ULL(n))
32
- # endif
33
- #endif /* ! defined(NUM2SIZET) */
34
-
35
11
  static inline int str_cstr_eq(VALUE val, const char *ptr, long len)
36
12
  {
37
13
  return (RSTRING_LEN(val) == len && !memcmp(ptr, RSTRING_PTR(val), len));
@@ -1,17 +1,7 @@
1
1
  # -*- encoding: binary -*-
2
2
  require 'mkmf'
3
3
 
4
- unless RUBY_VERSION < '3.1'
5
- warn "Unicorn was only tested against MRI up to 3.0.\n" \
6
- "It might not properly work with #{RUBY_VERSION}"
7
- end
8
-
9
- have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
10
- have_macro("SIZEOF_SIZE_T", "ruby.h") or check_sizeof("size_t", "sys/types.h")
11
- have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
12
- have_func("rb_str_set_len", "ruby.h") or abort 'Ruby 1.9.3+ required'
13
- have_func("rb_hash_clear", "ruby.h") # Ruby 2.0+
14
- have_func("gmtime_r", "time.h")
4
+ have_func("rb_hash_clear", "ruby.h") or abort 'Ruby 2.0+ required'
15
5
 
16
6
  message('checking if String#-@ (str_uminus) dedupes... ')
17
7
  begin
@@ -43,4 +33,5 @@ else
43
33
  message("no, needs Ruby 2.6+\n")
44
34
  end
45
35
 
36
+ have_func('epoll_create1', %w(sys/epoll.h))
46
37
  create_makefile("unicorn_http")
@@ -55,7 +55,7 @@ NORETURN(static void parser_raise(VALUE klass, const char *));
55
55
 
56
56
  /** Defines global strings in the init method. */
57
57
  #define DEF_GLOBAL(N, val) do { \
58
- g_##N = rb_obj_freeze(rb_str_new(val, sizeof(val) - 1)); \
58
+ g_##N = str_new_dd_freeze(val, (long)sizeof(val) - 1); \
59
59
  rb_gc_register_mark_object(g_##N); \
60
60
  } while (0)
61
61
 
@@ -11,6 +11,7 @@ static const char months[] = "Jan\0Feb\0Mar\0Apr\0May\0Jun\0"
11
11
 
12
12
  /* for people on wonky systems only */
13
13
  #ifndef HAVE_GMTIME_R
14
+ # warning using fake gmtime_r
14
15
  static struct tm * my_gmtime_r(time_t *now, struct tm *tm)
15
16
  {
16
17
  struct tm *global = gmtime(now);