Skip to content

fiber.cond:wait() returns when fiber is canceled #5013

@printercu

Description

@printercu

Tarantool version: 2.3.1

Bug description:

fiber.cond works unexpectedly when fiber is canceled. It differs from other cases.

-- luacheck: no global
fiber = require('fiber')
log = require('log')

function test(name, fn)
    log.info(name)
    local f = fiber.new(function()
        log.info({pcall = {pcall(function()
            log.info({result = {fn()}})
            log.info('after cancel')
        end)}})
        log.info({testcancel = {pcall(fiber.testcancel)}})
    end)
    f:set_joinable(true)
    fiber.yield()
    log.info('before cancel')
    f:cancel()
    f:join()
    log.info('')
end

test('sleep', function() fiber.sleep(10) end)
test('channel', function() fiber.channel():get() end)
test('cond', function() fiber.cond():wait() end)
sleep
before cancel
{"pcall":[false,"fiber is cancelled"]}
{"testcancel":[false,"fiber is cancelled"]}

channel
before cancel
{"pcall":[false,"fiber is cancelled"]}
{"testcancel":[false,"fiber is cancelled"]}

cond
before cancel
{"result":[]}
after cancel
{"pcall":[true]}
{"testcancel":[false,"fiber is cancelled"]}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions