crimson/mon: do not set_value() again
authorKefu Chai <kchai@redhat.com>
Tue, 22 Sep 2020 08:06:17 +0000 (16:06 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 22 Sep 2020 09:13:21 +0000 (17:13 +0800)
commita631510d4f669dbfa96fb6aa773d034e4d7ce4c2
tree2a2f782545b2723aa77ba16aec9bd7de8786a06e
parent182f6db9b126b9a98a38098e70425b0ad5934d65
crimson/mon: do not set_value() again

once the continuation consuming the stored value of the associated
future, we cannot set_value() again. otherwise, ASan complains that we
are accessing the memory on heap after it is freed.

in this change, std::optional<> is used for holding
promise<auth_result_t>, once the promise is fulfilled, `auth_done` is
reset to prevent another call of `set_value()` or `set_exception()`.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mon/MonClient.cc