Skip to content

Commit

Permalink
box: remove cord_slab_cache symbol from public API export
Browse files Browse the repository at this point in the history
`cord_slab_cache` was not designed to offer a backward compatible API, and
leaving it exposed inevitably leads to errors like those highlighted in
tarantool#7124 and tarantool/memcached#96: hence, remove it from the public API
export.

Closes tarantool#7124

@TarantoolBot document
Title: `cord_slab_cache` was removed from public API export

The `cord_slab_cache` needs to be removed from the C API reference of the
fiber module.
  • Loading branch information
CuriousGeorgiy committed Jun 21, 2023
1 parent de404cb commit b5f18ad
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## bugfix/box

* **[Breaking change]** The `cord_slab_cache` symbol was removed from the public
API export (gh-7124).
1 change: 0 additions & 1 deletion extra/exports
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ console_set_output_format
cord_ibuf_drop
cord_ibuf_put
cord_ibuf_take
cord_slab_cache
crc32_calc
crypto_ERR_error_string
crypto_ERR_get_error
Expand Down
14 changes: 6 additions & 8 deletions src/lib/core/fiber.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ enum {
FIBER_DEFAULT_FLAGS = 0
};

/**
* Return slab_cache suitable to use with tarantool/small library
*/
struct slab_cache *
cord_slab_cache(void);

/** \cond public */

/**
Expand Down Expand Up @@ -425,14 +431,6 @@ fiber_clock64(void);
API_EXPORT void
fiber_reschedule(void);

struct slab_cache;

/**
* Return slab_cache suitable to use with tarantool/small library
*/
API_EXPORT struct slab_cache *
cord_slab_cache(void);

/**
* box region allocator
*
Expand Down
2 changes: 1 addition & 1 deletion test/app-tap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build_module(module_api module_api.c)
target_link_libraries(module_api msgpuck)
target_link_libraries(module_api small msgpuck)

# gh-5313: verify that module.h actually conforms to the C99
# standard.
Expand Down
30 changes: 13 additions & 17 deletions test/app-tap/module_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <module.h>

#include <small/ibuf.h>
#include <small/quota.h>
#include <small/slab_arena.h>
#include <small/slab_cache.h>
#include <msgpuck/msgpuck.h>

#include <errno.h>
Expand Down Expand Up @@ -184,11 +187,16 @@ test_checkint64(lua_State *L)
static int
test_box_ibuf(lua_State *L)
{
struct slab_cache *slabc = cord_slab_cache();
fail_unless(slabc != NULL);
struct quota quota;
quota_init(&quota, QUOTA_MAX);
struct slab_arena arena;
fail_unless(slab_arena_create(&arena, &quota, 0, SLAB_MIN_SIZE,
SLAB_ARENA_PRIVATE) == 0);
struct slab_cache slabc;
slab_cache_create(&slabc, &arena);
box_ibuf_t ibuf;

ibuf_create(&ibuf, slabc, 16320);
ibuf_create(&ibuf, &slabc, 16320);
fail_unless(ibuf_used(&ibuf) == 0);
void *ptr = box_ibuf_reserve(&ibuf, 65536);
fail_unless(ptr != NULL);
Expand Down Expand Up @@ -220,6 +228,8 @@ test_box_ibuf(lua_State *L)
fail_unless(ibuf_used(&ibuf) == 0);
fail_unless(*rpos == *wpos);

slab_arena_destroy(&arena);

lua_pushboolean(L, 1);
return 1;
}
Expand Down Expand Up @@ -334,19 +344,6 @@ test_fiber_set_ctx(lua_State *L)
return 1;
}

static int
test_cord(lua_State *L)
{
struct slab_cache *slabc = cord_slab_cache();
fail_unless(slabc != NULL);
struct ibuf ibuf;
ibuf_create(&ibuf, slabc, 16320);
ibuf_destroy(&ibuf);

lua_pushboolean(L, 1);
return 1;
}

static int
test_pushcdata(lua_State *L)
{
Expand Down Expand Up @@ -3172,7 +3169,6 @@ luaopen_module_api(lua_State *L)
{"test_toint64", test_toint64 },
{"test_fiber", test_fiber },
{"test_fiber_set_ctx", test_fiber_set_ctx },
{"test_cord", test_cord },
{"pushcdata", test_pushcdata },
{"checkcdata", test_checkcdata },
{"test_clock", test_clock },
Expand Down
2 changes: 1 addition & 1 deletion test/app-tap/module_api.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ local function test_box_iproto_override(test, module)
end

require('tap').test("module_api", function(test)
test:plan(49)
test:plan(48)
local status, module = pcall(require, 'module_api')
test:is(status, true, "module")
test:ok(status, "module is loaded")
Expand Down

0 comments on commit b5f18ad

Please sign in to comment.