Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add FFI functions for ngx.req.get_post_args #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

p0pr0ck5
Copy link
Contributor

No description provided.

t/request.t Outdated
location = /t {
set $foo hello;
content_by_lua_block {
local ffi = require "ffi"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem to be of any use here, or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like this is a legacy holdover from a number of other tests (I copypasta'd the test structure from the get_args() tests); i'll remove this one and push up a separate PR to get rid of this cruft in the existing tests.

qr/\[TRACE \d+ content_by_lua\(nginx\.conf:\d+\):5 loop\]/
--- no_error_log
[error]
-- NYI:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a test with get_post_args(n) and get_post_args(0). I definitely think we need those :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting @agentzh from #78:

The test cases in this library for the FFI-version of ngx_lua's Lua API should focus instead of JIT-ability instead of functionality. Functionality tests are already in the ngx_lua module and ngx_lua's test suite can run with lua-resty-core with the following environment setting, for example:

export TEST_NGINX_INIT_BY_LUA="package.path = (package.path or '') .. ';$PWD/../lua-resty-core/lib/?.lua;$PWD/../lua-resty-lrucache/lib/?.lua;' require 'resty.core'"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!


local args = new_tab(0, nargs)
for i = 0, nargs - 1 do
local arg = kvbuf[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we go against Mike Pall's advice not to cache table lookup in such a hot code path? I am not sure, just to be clear, just raising a concern we previously talked about :)

This happens a bunch in this function, although, I do agree that it makes the code more readable :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think style consistency is important here; this loop is a duplicate of the one for URI args, so this seems the most appropriate choice. I would be interested in looking at some jit dump output of the two approaches and seeing what the functional difference is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm really unsure too, especially since we're dealing with cdata here and not tables...

local FFI_POST_ARGS_OK = 0
local FFI_POST_ARGS_EMPTY = 1
local FFI_POST_ARGS_UNREAD = 2
local FFI_POST_ARGS_IN_FILE = 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No extra error code constants.

@agentzh
Copy link
Member

agentzh commented Jun 2, 2017

@p0pr0ck5 Will you please rebase to the latest master? Sorry for the delay on my side. I'm about to look at it but found it has conflicts with the latest master. Thanks!

Update function signatures and remove an unused require in tests

Remove unwanted constants and refactor error checking
@p0pr0ck5
Copy link
Contributor Author

p0pr0ck5 commented Jun 2, 2017

@agentzh rebased and squashed.

@agentzh
Copy link
Member

agentzh commented Jun 2, 2017

@p0pr0ck5 Cool, thanks! I'll have a look.

@p0pr0ck5
Copy link
Contributor Author

@agentzh any thoughts here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants