From b00983369be5f356280168b4c5d600bd7d614c60 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 29 Sep 2022 20:59:43 +0100 Subject: Renamed a couple of members of nxt_unit_request_t. This is a preparatory patch that renames the 'local' and 'local_length' members of the nxt_unit_request_t structure to 'local_addr' and 'local_addr_length' in preparation for the adding of 'local_port' and 'local_port_length' members. Suggested-by: Zhidao HONG Signed-off-by: Andrew Clayton --- src/ruby/nxt_ruby.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ruby') diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c index f316d8a5..1b55e7ef 100644 --- a/src/ruby/nxt_ruby.c +++ b/src/ruby/nxt_ruby.c @@ -747,8 +747,8 @@ nxt_ruby_read_request(nxt_unit_request_info_t *req, VALUE hash_env) r->version_length); nxt_ruby_add_sptr(hash_env, nxt_rb_remote_addr_str, &r->remote, r->remote_length); - nxt_ruby_add_sptr(hash_env, nxt_rb_server_addr_str, &r->local, - r->local_length); + nxt_ruby_add_sptr(hash_env, nxt_rb_server_addr_str, &r->local_addr, + r->local_addr_length); nxt_ruby_add_sptr(hash_env, nxt_rb_server_name_str, &r->server_name, r->server_name_length); -- cgit From dc9f592d6e7123d57924146dcbf1be80366bc98b Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Wed, 28 Sep 2022 15:51:55 +0100 Subject: 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: Tested-by: Andrew Clayton Reviewed-by: Andrew Clayton [ Andrew: Patch by Zhidao, commit message by me with input from Zhidao ] Signed-off-by: Andrew Clayton --- src/ruby/nxt_ruby.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ruby') 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; -- cgit From d806a90609e99cb4c8db71d620d5db3d26e83693 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 3 Oct 2022 13:01:33 +0100 Subject: Ruby: used nxt_ruby_exception_log() in nxt_ruby_rack_init(). For consistency use nxt_ruby_exception_log() rather than nxt_alert() in nxt_ruby_rack_init(). Signed-off-by: Andrew Clayton --- src/ruby/nxt_ruby.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ruby') diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c index cc287e0e..bcb48f6b 100644 --- a/src/ruby/nxt_ruby.c +++ b/src/ruby/nxt_ruby.c @@ -492,7 +492,7 @@ nxt_ruby_rack_init(nxt_ruby_rack_init_t *rack_init) } if (nxt_slow_path(RARRAY_LEN(rackup) < 1)) { - nxt_alert(rack_init->task, "Ruby: Invalid rack config file"); + nxt_ruby_exception_log(NULL, NXT_LOG_ALERT, "Invalid rack config file"); return Qnil; } -- cgit