Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support adb-shell style cpp_rpc #8223

Merged
merged 5 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/cpp_rpc/rpc_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ int mkdir(const char* path, int /* ignored */) { return _mkdir(path); }
#include <iostream>
#include <string>
#include <vector>

#include "../../src/support/utils.h"
#include "rpc_env.h"

Expand Down Expand Up @@ -95,7 +96,16 @@ RPCEnv::RPCEnv(const std::string& wd) {
auto cmdline = fopen("/proc/self/cmdline", "r");
fread(cwd, 1, sizeof(cwd), cmdline);
fclose(cmdline);
base_ = "/data/data/" + std::string(cwd) + "/cache/rpc";
std::string android_base_ = "/data/data/" + std::string(cwd) + "/cache";
struct stat statbuf;
// Check if application data directory exist. If not exist usually mean tvm_rpc run from adb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitty comment. If not exist, usually means we run tvm_rpc from adb shell terminal

// shell terminal.
if (stat(android_base_.data(), &statbuf) == -1 || !S_ISDIR(statbuf.st_mode)) {
// Tmp directory always writable for 'shell' user.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is always writable...

android_base_ = "/data/local/tmp";
}
base_ = android_base_ + "/rpc";

#elif !defined(_WIN32)
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd))) {
Expand Down
2 changes: 1 addition & 1 deletion apps/cpp_rpc/rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class RPCServer {
auto pid = fork();
if (pid == 0) {
ServerLoopProc(conn, addr, work_dir_);
exit(0);
_exit(0);
}
// Wait for the result
int status = 0;
Expand Down