1 https://github.com/google/mozc/issues/471
3 --- /src/ipc/ipc_path_manager.cc
4 +++ /src/ipc/ipc_path_manager.cc
9 + // Expand symbolic links in the expected server path to avoid false negatives
10 + // during comparisons of the expected server path and the actual server path.
11 + string real_server_path = server_path;
13 + char real_server_path_[PATH_MAX];
14 + if (realpath(server_path.c_str(), real_server_path_) == NULL) {
15 + LOG(ERROR) << "realpath failed: " << strerror(errno);
18 + real_server_path = real_server_path_;
22 if (pid == server_pid_) {
23 - return (server_path == server_path_);
24 + return (real_server_path == server_path_);
30 std::wstring expected_server_ntpath;
31 const std::map<string, std::wstring>::const_iterator it =
32 - expected_server_ntpath_cache_.find(server_path);
33 + expected_server_ntpath_cache_.find(real_server_path);
34 if (it != expected_server_ntpath_cache_.end()) {
35 expected_server_ntpath = it->second;
37 std::wstring wide_server_path;
38 - Util::UTF8ToWide(server_path, &wide_server_path);
39 + Util::UTF8ToWide(real_server_path, &wide_server_path);
40 if (WinUtil::GetNtPath(wide_server_path, &expected_server_ntpath)) {
41 - // Caches the relationship from |server_path| to
42 - // |expected_server_ntpath| in case |server_path| is renamed later.
43 + // Caches the relationship from |real_server_path| to
44 + // |expected_server_ntpath| in case |real_server_path| is renamed later.
45 // (This can happen during the updating).
46 - expected_server_ntpath_cache_[server_path] = expected_server_ntpath;
47 + expected_server_ntpath_cache_[real_server_path] = expected_server_ntpath;
55 - // Here we can safely assume that |server_path| (expected one) should be
56 + // Here we can safely assume that |real_server_path| (expected one) should be
57 // the same to |server_path_| (actual one).
58 - server_path_ = server_path;
59 + server_path_ = real_server_path;
65 // load from /proc/<pid>/exe
68 + char filename[PATH_MAX];
69 snprintf(proc, sizeof(proc) - 1, "/proc/%u/exe", pid);
70 const ssize_t size = readlink(proc, filename, sizeof(filename) - 1);
76 - VLOG(1) << "server path: " << server_path << " " << server_path_;
77 - if (server_path == server_path_) {
78 + VLOG(1) << "server path: " << real_server_path << " " << server_path_;
79 + if (real_server_path == server_path_) {
84 - if ((server_path + " (deleted)") == server_path_) {
85 - LOG(WARNING) << server_path << " on disk is modified";
86 + if ((real_server_path + " (deleted)") == server_path_) {
87 + LOG(WARNING) << real_server_path << " on disk is modified";
88 // If a user updates the server binary on disk during the server is running,
89 // "readlink /proc/<pid>/exe" returns a path with the " (deleted)" suffix.
90 // We allow the special case.
91 - server_path_ = server_path;
92 + server_path_ = real_server_path;