Skip to content

Commit

Permalink
Fix lambda capture bug in GraphStorageLocalServer
Browse files Browse the repository at this point in the history
This will crash the daemon
  • Loading branch information
yixinglu committed Mar 10, 2022
1 parent 92d9099 commit 1e27ff3
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/storage/GraphStorageLocalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

using folly::exception_wrapper;

#define LOCAL_RETURN_FUTURE(threadManager, respType, callFunc) \
auto promise = std::make_shared<folly::Promise<respType>>(); \
auto f = promise->getFuture(); \
threadManager->add([req = request, promise, this] { \
#define LOCAL_RETURN_FUTURE(RespType, callFunc) \
auto promise = std::make_shared<folly::Promise<RespType>>(); \
auto f = promise->getSemiFuture(); \
threadManager_->add([this, promise, request] { \
std::dynamic_pointer_cast<GraphStorageServiceHandler>(handler_) \
->callFunc(req) \
.thenValue([promise](respType&& resp) { promise->setValue(std::move(resp)); }) \
->callFunc(std::move(request)) \
.thenValue([promise](RespType&& resp) { promise->setValue(std::move(resp)); }) \
.thenError([promise](exception_wrapper&& ex) { promise->setException(std::move(ex)); }); \
}); \
return f;
Expand Down Expand Up @@ -60,102 +60,102 @@ void GraphStorageLocalServer::stop() {

folly::SemiFuture<cpp2::GetNeighborsResponse> GraphStorageLocalServer::semifuture_getNeighbors(
const cpp2::GetNeighborsRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetNeighborsResponse, future_getNeighbors);
LOCAL_RETURN_FUTURE(cpp2::GetNeighborsResponse, future_getNeighbors);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_addVertices(
const cpp2::AddVerticesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_addVertices);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_addVertices);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_chainAddEdges(
const cpp2::AddEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_chainAddEdges);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_chainAddEdges);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_addEdges(
const cpp2::AddEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_addEdges);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_addEdges);
}

folly::SemiFuture<cpp2::GetPropResponse> GraphStorageLocalServer::semifuture_getProps(
const cpp2::GetPropRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetPropResponse, future_getProps);
LOCAL_RETURN_FUTURE(cpp2::GetPropResponse, future_getProps);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_deleteEdges(
const cpp2::DeleteEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_deleteEdges);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_deleteEdges);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_chainDeleteEdges(
const cpp2::DeleteEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_chainDeleteEdges);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_chainDeleteEdges);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_deleteVertices(
const cpp2::DeleteVerticesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_deleteVertices);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_deleteVertices);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_deleteTags(
const cpp2::DeleteTagsRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_deleteTags);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_deleteTags);
}

folly::SemiFuture<cpp2::UpdateResponse> GraphStorageLocalServer::semifuture_updateVertex(
const cpp2::UpdateVertexRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::UpdateResponse, future_updateVertex);
LOCAL_RETURN_FUTURE(cpp2::UpdateResponse, future_updateVertex);
}

folly::SemiFuture<cpp2::UpdateResponse> GraphStorageLocalServer::semifuture_chainUpdateEdge(
const cpp2::UpdateEdgeRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::UpdateResponse, future_chainUpdateEdge);
LOCAL_RETURN_FUTURE(cpp2::UpdateResponse, future_chainUpdateEdge);
}

folly::SemiFuture<cpp2::UpdateResponse> GraphStorageLocalServer::semifuture_updateEdge(
const cpp2::UpdateEdgeRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::UpdateResponse, future_updateEdge);
LOCAL_RETURN_FUTURE(cpp2::UpdateResponse, future_updateEdge);
}

folly::SemiFuture<cpp2::GetUUIDResp> GraphStorageLocalServer::semifuture_getUUID(
const cpp2::GetUUIDReq& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetUUIDResp, future_getUUID);
LOCAL_RETURN_FUTURE(cpp2::GetUUIDResp, future_getUUID);
}

folly::SemiFuture<cpp2::LookupIndexResp> GraphStorageLocalServer::semifuture_lookupIndex(
const cpp2::LookupIndexRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::LookupIndexResp, future_lookupIndex);
LOCAL_RETURN_FUTURE(cpp2::LookupIndexResp, future_lookupIndex);
}

folly::SemiFuture<cpp2::GetNeighborsResponse> GraphStorageLocalServer::semifuture_lookupAndTraverse(
const cpp2::LookupAndTraverseRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetNeighborsResponse, future_lookupAndTraverse);
LOCAL_RETURN_FUTURE(cpp2::GetNeighborsResponse, future_lookupAndTraverse);
}

folly::SemiFuture<cpp2::ScanResponse> GraphStorageLocalServer::semifuture_scanVertex(
const cpp2::ScanVertexRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ScanResponse, future_scanVertex);
LOCAL_RETURN_FUTURE(cpp2::ScanResponse, future_scanVertex);
}

folly::SemiFuture<cpp2::ScanResponse> GraphStorageLocalServer::semifuture_scanEdge(
const cpp2::ScanEdgeRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ScanResponse, future_scanEdge);
LOCAL_RETURN_FUTURE(cpp2::ScanResponse, future_scanEdge);
}

folly::SemiFuture<cpp2::KVGetResponse> GraphStorageLocalServer::semifuture_get(
const cpp2::KVGetRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::KVGetResponse, future_get);
LOCAL_RETURN_FUTURE(cpp2::KVGetResponse, future_get);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_put(
const cpp2::KVPutRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_put);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_put);
}

folly::SemiFuture<cpp2::ExecResponse> GraphStorageLocalServer::semifuture_remove(
const cpp2::KVRemoveRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_remove);
LOCAL_RETURN_FUTURE(cpp2::ExecResponse, future_remove);
}

} // namespace nebula::storage

0 comments on commit 1e27ff3

Please sign in to comment.