lua-nginx-module icon indicating copy to clipboard operation
lua-nginx-module copied to clipboard

ffi_write new API: Update ngx_http_lua_output.c

Open hkmo opened this issue 8 years ago • 6 comments

ffi_write new API function.

This new FFI API function is used to print a string buffer on the client output starting from a given offset and ending at given length. This avoids the overhead of creating another string in the lua land.

See https://github.com/openresty/lua-nginx-module/issues/938 for more details.

hkmo avatar Jan 18 '17 19:01 hkmo

@hkmo Please use the ngx-releng script to analyze coding style issues in your branch. See https://github.com/openresty/openresty-devel-utils/blob/master/ngx-releng

agentzh avatar Jan 18 '17 19:01 agentzh

Also, please rebase to the latest master.

agentzh avatar Jan 18 '17 19:01 agentzh

@agentzh Do you know why travis is complaining with: "Failed to get the version of the Nginx in PATH"?

hkmo avatar Jan 19 '17 22:01 hkmo

@hkmo They were the consequences of the earlier compilation errors. To quote:

/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c: In function ‘ngx_http_lua_ffi_write’:
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:823:16: error: ‘NGX_HTTP_LUA_FFI_NO_REQUEST’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_NO_REQUEST;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:823:16: note: each undeclared identifier is reported only once for each function it appears in
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:827:16: error: ‘NGX_HTTP_LUA_FFI_NULL_STRING’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_NULL_STRING;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:833:16: error: ‘NGX_HTTP_LUA_FFI_BAD_RANGE’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_BAD_RANGE;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:863:16: error: ‘NGX_HTTP_LUA_FFI_RAW_SOCKET’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_RAW_SOCKET;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:868:16: error: ‘NGX_HTTP_LUA_FFI_HEADER_ONLY’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_HEADER_ONLY;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:872:16: error: ‘NGX_HTTP_LUA_FFI_EOF’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_EOF;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:881:16: error: ‘NGX_HTTP_LUA_FFI_NO_MEMORY’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_NO_MEMORY;
                ^
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_output.c:893:16: error: ‘NGX_HTTP_LUA_FFI_OUTPUT_ERROR’ undeclared (first use in this function)
         return NGX_HTTP_LUA_FFI_OUTPUT_ERROR;
                ^
make[1]: *** [objs/addon/src/ngx_http_lua_output.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/travis/build/openresty/lua-nginx-module/buildroot/nginx-1.9.15'
make: *** [build] Error 2

agentzh avatar Jan 20 '17 00:01 agentzh

Yes I figured that out yesterday and I made the corrections.

hkmo avatar Jan 20 '17 11:01 hkmo

@agentzh I did a load test and I see a lot of "bad range" errors and very slow throughput compared to the normal print. Is it possible the fact we are not casting to const char* in the lua is giving us a bad buffers, or?

 size = ngx_strlen(buf);      
 if (len == 0 || size == 0 || offset > size - 1) {
      *err = "bad buffer range";        
      return NGX_ERROR;     
  }

hkmo avatar Jan 24 '17 16:01 hkmo