nfs: use makeImmediateFutureWith instead of a manual version of it

Summary:
Now that makeImmediateFutureWith exists, we can simply use it instead of
constructing a ImmediateFuture<folly::Unit> and calling thenValue on it.

Reviewed By: chadaustin

Differential Revision: D28518059

fbshipit-source-id: 0041cf863fb32efab274f11c77c76109ca9b454f
This commit is contained in:
Xavier Deguillard 2021-05-25 15:14:52 -07:00 committed by Facebook GitHub Bot
parent 814c4c2bcf
commit 9621d533f4

View File

@ -453,32 +453,29 @@ ImmediateFuture<folly::Unit> Nfsd3ServerProcessor::lookup(
});
}
// XXX: makeImmediateFuture
auto immFut = ImmediateFuture<folly::Unit>{folly::unit};
return std::move(immFut)
.thenValue([this, args = std::move(args)](auto&&) mutable {
if (args.what.name == ".") {
return dispatcher_->getattr(args.what.dir.ino, *context)
.thenValue(
[ino = args.what.dir.ino](struct stat && stat)
-> std::tuple<InodeNumber, struct stat> {
return {ino, std::move(stat)};
});
} else if (args.what.name == "..") {
return dispatcher_->getParent(args.what.dir.ino, *context)
.thenValue([this](InodeNumber ino) {
return dispatcher_->getattr(ino, *context)
.thenValue(
[ino](struct stat && stat)
-> std::tuple<InodeNumber, struct stat> {
return {ino, std::move(stat)};
});
});
} else {
return dispatcher_->lookup(
args.what.dir.ino, PathComponent(args.what.name), *context);
}
})
return makeImmediateFutureWith([this, args = std::move(args)]() {
if (args.what.name == ".") {
return dispatcher_->getattr(args.what.dir.ino, *context)
.thenValue(
[ino = args.what.dir.ino](struct stat && stat)
-> std::tuple<InodeNumber, struct stat> {
return {ino, std::move(stat)};
});
} else if (args.what.name == "..") {
return dispatcher_->getParent(args.what.dir.ino, *context)
.thenValue([this](InodeNumber ino) {
return dispatcher_->getattr(ino, *context)
.thenValue(
[ino](struct stat && stat)
-> std::tuple<InodeNumber, struct stat> {
return {ino, std::move(stat)};
});
});
} else {
return dispatcher_->lookup(
args.what.dir.ino, PathComponent(args.what.name), *context);
}
})
.thenTry([ser = std::move(ser), dirAttrFut = std::move(dirAttrFut)](
folly::Try<std::tuple<InodeNumber, struct stat>>&&
lookupTry) mutable {