diff --git a/src/lua/fiber.cc b/src/lua/fiber.cc index f8eda08a993a28ee4a8b822994d2b09435c9cb31..6d9e42201880a301fa87d2b898787edc349ffdb9 100644 --- a/src/lua/fiber.cc +++ b/src/lua/fiber.cc @@ -220,9 +220,13 @@ lbox_fiber_statof(struct fiber *f, void *cb_ctx) { struct lua_State *L = (struct lua_State *) cb_ctx; - lua_pushstring(L, fiber_name(f)); + lua_pushinteger(L, f->fid); lua_newtable(L); + lua_pushliteral(L, "name"); + lua_pushstring(L, fiber_name(f)); + lua_settable(L, -3); + lua_pushstring(L, "fid"); lua_pushnumber(L, f->fid); lua_settable(L, -3); diff --git a/test/box/fiber.result b/test/box/fiber.result index 58656e42e8ad628672c8a494ceafa4e72ecfe505..13a1aa6044ed9b8a51b2f6744deef3477548b8f8 100644 --- a/test/box/fiber.result +++ b/test/box/fiber.result @@ -726,6 +726,44 @@ done --- - true ... +-- # gh-536: fiber.info() doesn't list fibers with default names +-- +function loop() while true do fiber.sleep(10) end end +--- +... +f1 = fiber.create(loop) +--- +... +f2 = fiber.create(loop) +--- +... +f3 = fiber.create(loop) +--- +... +info = fiber.info() +--- +... +info[f1:id()] ~= nil +--- +- true +... +info[f2:id()] ~= nil +--- +- true +... +info[f3:id()] ~= nil +--- +- true +... +f1:cancel() +--- +... +f2:cancel() +--- +... +f3:cancel() +--- +... fiber = nil --- ... diff --git a/test/box/fiber.test.lua b/test/box/fiber.test.lua index 8c80a81c45e15cd3e8f1b1aa5c21a671947e5974..258561e06c04dc5b89bbe9f055cd63c2dcb2b8c4 100644 --- a/test/box/fiber.test.lua +++ b/test/box/fiber.test.lua @@ -296,4 +296,20 @@ end; f = fiber.create(test) done +-- # gh-536: fiber.info() doesn't list fibers with default names +-- +function loop() while true do fiber.sleep(10) end end +f1 = fiber.create(loop) +f2 = fiber.create(loop) +f3 = fiber.create(loop) + +info = fiber.info() +info[f1:id()] ~= nil +info[f2:id()] ~= nil +info[f3:id()] ~= nil + +f1:cancel() +f2:cancel() +f3:cancel() + fiber = nil