]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
crimson/common: do not take from a future twice 37687/head
authorKefu Chai <kchai@redhat.com>
Fri, 16 Oct 2020 06:11:52 +0000 (14:11 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 16 Oct 2020 06:36:58 +0000 (14:36 +0800)
commit5d80c545a95a343c5cf8b07ad40af4a955136e36
treeb141b44c73d4d4a962aac915ff32a82d472a9075
parent715e83aa9b05c2ea89b28405d66ff8ab3655782b
crimson/common: do not take from a future twice

before this change, in our specialization of seastar::do_until(),
we access `f` after calling `f.get()`, this is not correct. as `f.get()`
actually moves `f._state` away and detaches the associated promise if any.
so we cannot call `f._then()` anymore after calling `f.get()`. as
`f._then()` schedules `f` by detaching the future from promise and
attaching the scheduled task to the promise. but `future_base::detach_promise()`
does not check `_promise` before accessing it, hence the segfault.

after this change, the order of the checks is rearranged so that
`f.get()` is called at the end. and also use `f.get0()` to be more
explicit, as we are accessing the only element of the returned
value.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/common/errorator.h
src/test/crimson/CMakeLists.txt
src/test/crimson/test_errorator.cc [new file with mode: 0644]