1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
-- test-run result file version 2
fiber = require('fiber')
| ---
| ...
test_run = require('test_run').new()
| ---
| ...
build_path = os.getenv("BUILDDIR")
| ---
| ...
package.cpath = build_path..'/test/box/?.so;'..build_path..'/test/box/?.dylib;'..package.cpath
| ---
| ...
errinj = box.error.injection
| ---
| ...
--
-- gh-4648: box.schema.func.drop() didn't unload a .so/.dylib
-- module. Even if it was unused already. Moreover, recreation of
-- functions from the same module led to its multiple mmaping.
--
current_module_count = errinj.get("ERRINJ_DYN_MODULE_COUNT")
| ---
| ...
function check_module_count_diff(diff) \
local module_count = errinj.get("ERRINJ_DYN_MODULE_COUNT") \
current_module_count = current_module_count + diff \
if current_module_count ~= module_count then \
return current_module_count, module_count \
end \
end
| ---
| ...
-- Module is not loaded until any of its functions is called first
-- time.
box.schema.func.create('function1', {language = 'C'})
| ---
| ...
check_module_count_diff(0)
| ---
| ...
box.schema.func.drop('function1')
| ---
| ...
check_module_count_diff(0)
| ---
| ...
-- Module is unloaded when its function is dropped, and there are
-- no not finished invocations of the function.
box.schema.func.create('function1', {language = 'C'})
| ---
| ...
check_module_count_diff(0)
| ---
| ...
box.func.function1:call()
| ---
| ...
check_module_count_diff(1)
| ---
| ...
box.schema.func.drop('function1')
| ---
| ...
check_module_count_diff(-1)
| ---
| ...
-- A not finished invocation of a function from a module prevents
-- its unload. Until the call is finished.
box.schema.func.create('function1', {language = 'C'})
| ---
| ...
box.schema.func.create('function1.test_sleep', {language = 'C'})
| ---
| ...
check_module_count_diff(0)
| ---
| ...
function long_call() box.func['function1.test_sleep']:call() end
| ---
| ...
f1 = fiber.create(long_call)
| ---
| ...
f2 = fiber.create(long_call)
| ---
| ...
test_run:wait_cond(function() \
return f1:status() == 'suspended' and \
f2:status() == 'suspended' \
end)
| ---
| - true
| ...
box.func.function1:call()
| ---
| ...
check_module_count_diff(1)
| ---
| ...
box.schema.func.drop('function1')
| ---
| ...
box.schema.func.drop('function1.test_sleep')
| ---
| ...
check_module_count_diff(0)
| ---
| ...
f1:cancel()
| ---
| ...
test_run:wait_cond(function() return f1:status() == 'dead' end)
| ---
| - true
| ...
check_module_count_diff(0)
| ---
| ...
f2:cancel()
| ---
| ...
test_run:wait_cond(function() return f2:status() == 'dead' end)
| ---
| - true
| ...
check_module_count_diff(-1)
| ---
| ...
|