Skip to content

Conversation

tzssangglass
Copy link
Contributor

No description provided.

@tzssangglass tzssangglass marked this pull request as ready for review May 17, 2022 18:20
@tzssangglass tzssangglass requested a review from spacewander May 17, 2022 18:20
@tzssangglass
Copy link
Contributor Author

Note: should revert ci.yml before merge to master

@tzssangglass tzssangglass requested a review from soulbird May 18, 2022 02:07
@tzssangglass
Copy link
Contributor Author

build apisix-base with: api7/apisix-build-tools#190

end

- zone = ngx_lua_ffi_shdict_udata_to_zone(zone)
+ zone = C.ngx_meta_lua_ffi_shdict_udata_to_zone(zone)
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use ngx_lua_ffi_shdict_udata_to_zone and update it with ngx_lua_ffi_shdict_udata_to_zone = C.ngx_meta_lua_ffi_shdict_udata_to_zone. And other similar places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now it looks like

local ngx_lua_ffi_shdict_get
local ngx_lua_ffi_shdict_incr
local ngx_lua_ffi_shdict_store
local ngx_lua_ffi_shdict_flush_all
local ngx_lua_ffi_shdict_get_ttl
local ngx_lua_ffi_shdict_set_expire
local ngx_lua_ffi_shdict_capacity
local ngx_lua_ffi_shdict_free_space
local ngx_lua_ffi_shdict_udata_to_zone


ffi.cdef[[
int ngx_meta_lua_ffi_shdict_get(void *zone, const unsigned char *key,
    size_t key_len, int *value_type, unsigned char **str_value_buf,
    size_t *str_value_len, double *num_value, int *user_flags,
    int get_stale, int *is_stale, char **errmsg);

int ngx_meta_lua_ffi_shdict_incr(void *zone, const unsigned char *key,
    size_t key_len, double *value, char **err, int has_init,
    double init, long init_ttl, int *forcible);

int ngx_meta_lua_ffi_shdict_store(void *zone, int op,
    const unsigned char *key, size_t key_len, int value_type,
    const unsigned char *str_value_buf, size_t str_value_len,
    double num_value, long exptime, int user_flags, char **errmsg,
    int *forcible);

int ngx_meta_lua_ffi_shdict_flush_all(void *zone);

long ngx_meta_lua_ffi_shdict_get_ttl(void *zone,
    const unsigned char *key, size_t key_len);

int ngx_meta_lua_ffi_shdict_set_expire(void *zone,
    const unsigned char *key, size_t key_len, long exptime);

size_t ngx_meta_lua_ffi_shdict_capacity(void *zone);

void *ngx_meta_lua_ffi_shdict_udata_to_zone(void *zone_udata);
]]

if not pcall(function ()
    return C.ngx_meta_lua_ffi_shdict_free_space
end)
then
    ffi.cdef[[
size_t ngx_meta_lua_ffi_shdict_free_space(void *zone);
    ]]
end

pcall(function ()
    ngx_lua_ffi_shdict_get = C.ngx_meta_lua_ffi_shdict_get
    ngx_lua_ffi_shdict_incr = C.ngx_meta_lua_ffi_shdict_incr
    ngx_lua_ffi_shdict_store = C.ngx_meta_lua_ffi_shdict_store
    ngx_lua_ffi_shdict_flush_all = C.ngx_meta_lua_ffi_shdict_flush_all
    ngx_lua_ffi_shdict_get_ttl = C.ngx_meta_lua_ffi_shdict_get_ttl
    ngx_lua_ffi_shdict_set_expire = C.ngx_meta_lua_ffi_shdict_set_expire
    ngx_lua_ffi_shdict_capacity = C.ngx_meta_lua_ffi_shdict_capacity
    ngx_lua_ffi_shdict_free_space = C.ngx_meta_lua_ffi_shdict_free_space
    ngx_lua_ffi_shdict_udata_to_zone = C.ngx_meta_lua_ffi_shdict_udata_to_zone
end)

if not pcall(function () return C.free end) then
    ffi.cdef[[
void free(void *ptr);
    ]]
end

@tzssangglass tzssangglass merged commit 904e6f3 into api7:main May 19, 2022
@tzssangglass tzssangglass deleted the unify_shdict branch May 19, 2022 09:52
spacewander added a commit that referenced this pull request May 19, 2022
@tzssangglass tzssangglass restored the unify_shdict branch May 20, 2022 08:21
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