summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2022-09-28 15:51:55 +0100
committerAndrew Clayton <andrew@digital-domain.net>2022-10-04 19:33:11 +0100
commitdc9f592d6e7123d57924146dcbf1be80366bc98b (patch)
tree372c7377a1420705a1a39acfdd12d126136a9307
parentb00983369be5f356280168b4c5d600bd7d614c60 (diff)
downloadunit-dc9f592d6e7123d57924146dcbf1be80366bc98b.tar.gz
unit-dc9f592d6e7123d57924146dcbf1be80366bc98b.tar.bz2
Ruby: added support for rack V3.
Ruby applications would fail to start if they were using rack v3 2022/09/28 15:48:46 [alert] 0#80912 [unit] Ruby: Failed to parse rack script 2022/09/28 15:48:46 [notice] 80911#80911 app process 80912 exited with code 1 This was due to a change in the rack API Rack V2 def self.load_file(path, opts = Server::Options.new) ... cfgfile.sub!(/^__END__\n.*\Z/m, '') app = new_from_string cfgfile, path return app, options end Rack V3 def self.load_file(path) ... return new_from_string(config, path) end This patch handles _both_ the above APIs by correctly handling the cases where we do and don't get an array returned from nxt_ruby_rack_parse_script(). Closes: <https://github.com/nginx/unit/issues/755> Tested-by: Andrew Clayton <a.clayton@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> [ Andrew: Patch by Zhidao, commit message by me with input from Zhidao ] Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
-rw-r--r--docs/changes.xml6
-rw-r--r--src/ruby/nxt_ruby.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/docs/changes.xml b/docs/changes.xml
index e37c8219..8f871eb1 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -31,6 +31,12 @@ NGINX Unit updated to 1.29.0.
date="" time=""
packager="Nginx Packaging &lt;nginx-packaging@f5.com&gt;">
+<change type="feature">
+<para>
+support rack v3 in ruby applications.
+</para>
+</change>
+
<change type="bugfix">
<para>
fix HTTP cookie parsing when the value contains an equals sign.
diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c
index 1b55e7ef..cc287e0e 100644
--- a/src/ruby/nxt_ruby.c
+++ b/src/ruby/nxt_ruby.c
@@ -480,12 +480,17 @@ nxt_ruby_rack_init(nxt_ruby_rack_init_t *rack_init)
rackup = rb_protect(nxt_ruby_rack_parse_script,
(VALUE) (uintptr_t) rack_init, &state);
- if (nxt_slow_path(TYPE(rackup) != T_ARRAY || state != 0)) {
+
+ if (nxt_slow_path(state != 0)) {
nxt_ruby_exception_log(NULL, NXT_LOG_ALERT,
"Failed to parse rack script");
return Qnil;
}
+ if (TYPE(rackup) != T_ARRAY) {
+ return rackup;
+ }
+
if (nxt_slow_path(RARRAY_LEN(rackup) < 1)) {
nxt_alert(rack_init->task, "Ruby: Invalid rack config file");
return Qnil;