Skip to content

Commit

Permalink
Merge pull request #99 from ywy2090/feature-milestone2-gateway
Browse files Browse the repository at this point in the history
fix mpc task not execute bug
  • Loading branch information
ywy2090 authored Nov 25, 2024
2 parents 77c138f + 02d5d90 commit a5b817d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,26 +347,31 @@ void MPCService::asyncRunMpcRpc(Json::Value const& request, RespFunc func)
{
response["code"] = MPC_SUCCESS;
response["message"] = "success";

MPC_LOG(INFO) << LOG_DESC("[MPCService][asyncRunMpcRpc]") << LOG_DESC("async run mpc submit job successfully")
<< LOG_KV("request", request.toStyledString())
<< LOG_KV("response", response.toStyledString());

// async run mpc job
m_threadPool->enqueue([self = weak_from_this(), jobInfo]() {
auto service = self.lock();
if (!service)
{
MPC_LOG(ERROR) << LOG_DESC("[MPCService][asyncRunMpcRpc]") << LOG_DESC("async run mpc service is null");
return;
}
service->runMpcRpcByJobInfo(jobInfo);
});
}
else
{
response["code"] = MPC_DUPLICATED;
response["message"] = "duplicated submit job";
}

MPC_LOG(INFO) << LOG_DESC("[MPCService][asyncRunMpcRpc]") << LOG_DESC("async run mpc submit job successfully")
MPC_LOG(INFO) << LOG_DESC("[MPCService][asyncRunMpcRpc]") << LOG_DESC("async run mpc duplicated submit job")
<< LOG_KV("request", request.toStyledString())
<< LOG_KV("response", response.toStyledString());

// async run mpc job
m_threadPool->enqueue([self = weak_from_this(), jobInfo]() {
auto service = self.lock();
if (!service)
{
return;
}
service->runMpcRpcByJobInfo(jobInfo);
});
}
}
catch (const std::exception& e)
{
Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-computing/ppc-mpc/src/MPCService.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace ppc::mpc
{
class MPCService: std::enable_shared_from_this<MPCService>
class MPCService: public std::enable_shared_from_this<MPCService>
{
public:
using Ptr = std::shared_ptr<MPCService>;
Expand Down

0 comments on commit a5b817d

Please sign in to comment.