Skip to content

Commit

Permalink
[RPC][CPP] Add support of cpp RPC-server for Apple (apache#8224)
Browse files Browse the repository at this point in the history
  • Loading branch information
KJlaccHoeUM9l authored and ylc committed Jan 13, 2022
1 parent 3364e94 commit a36725d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/cpp_rpc/rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
* \brief RPC Server implementation.
*/
#include <tvm/runtime/registry.h>
#if defined(__linux__) || defined(__ANDROID__)
#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
#include <signal.h>
#include <sys/select.h>
#include <sys/wait.h>
#endif
Expand Down Expand Up @@ -52,7 +53,7 @@ namespace runtime {
* \brief wait the child process end.
* \param status status value
*/
#if defined(__linux__) || defined(__ANDROID__)
#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
static pid_t waitPidEintr(int* status) {
pid_t pid = 0;
while ((pid = waitpid(-1, status, 0)) == -1) {
Expand Down Expand Up @@ -162,7 +163,7 @@ class RPCServer {
}

int timeout = GetTimeOutFromOpts(opts);
#if defined(__linux__) || defined(__ANDROID__)
#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
// step 3: serving
if (timeout != 0) {
const pid_t timer_pid = fork();
Expand Down Expand Up @@ -219,6 +220,10 @@ class RPCServer {
auto dur = high_resolution_clock::now() - start_time;

LOG(INFO) << "Serve Time " << duration_cast<milliseconds>(dur).count() << "ms";
#else
LOG(WARNING) << "Unknown platform. It is not known how to bring up the subprocess."
<< " RPC will be launched in the main thread.";
ServerLoopProc(conn, addr, work_dir_);
#endif
// close from our side.
LOG(INFO) << "Socket Connection Closed";
Expand Down

0 comments on commit a36725d

Please sign in to comment.