Revert "protobuf_grpc: google serializing and RPC library"
This reverts commit 5587d78e89.
Issue #190
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
commit b4f45e0fa3e07a91623b1039dfea8dfa77f792e0
|
||||
Author: Pirmin Duss <pirmin.duss@gapfruit.com>
|
||||
Date: Mon Sep 23 15:15:49 2019 +0200
|
||||
|
||||
mutex fixes
|
||||
|
||||
diff --git a/include/grpc/impl/codegen/sync_custom.h b/include/grpc/impl/codegen/sync_custom.h
|
||||
index 69b1bf6..dd0bb95 100644
|
||||
--- a/include/grpc/impl/codegen/sync_custom.h
|
||||
+++ b/include/grpc/impl/codegen/sync_custom.h
|
||||
@@ -21,15 +21,15 @@
|
||||
|
||||
#include <grpc/impl/codegen/port_platform.h>
|
||||
|
||||
-#include <grpc/impl/codegen/sync_generic.h>
|
||||
+#include <base/lock.h>
|
||||
|
||||
/* Users defining GPR_CUSTOM_SYNC need to define the following macros. */
|
||||
|
||||
#ifdef GPR_CUSTOM_SYNC
|
||||
|
||||
-typedef GPR_CUSTOM_MU_TYPE gpr_mu;
|
||||
-typedef GPR_CUSTOM_CV_TYPE gpr_cv;
|
||||
-typedef GPR_CUSTOM_ONCE_TYPE gpr_once;
|
||||
+typedef Genode::Lock gpr_mu;
|
||||
+typedef pthread_cond_t gpr_cv;
|
||||
+typedef pthread_once_t gpr_once;
|
||||
|
||||
#define GPR_ONCE_INIT GPR_CUSTOM_ONCE_INIT
|
||||
|
||||
diff --git a/include/grpcpp/impl/codegen/sync.h b/include/grpcpp/impl/codegen/sync.h
|
||||
index 146f182..d1a60cb 100644
|
||||
--- a/include/grpcpp/impl/codegen/sync.h
|
||||
+++ b/include/grpcpp/impl/codegen/sync.h
|
||||
@@ -26,6 +26,7 @@
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
||||
+#include <base/lock.h>
|
||||
|
||||
#include <grpc/impl/codegen/log.h>
|
||||
#include <grpc/impl/codegen/sync.h>
|
||||
@@ -58,7 +59,7 @@ class Mutex {
|
||||
private:
|
||||
union {
|
||||
gpr_mu mu_;
|
||||
- std::mutex do_not_use_sth_;
|
||||
+ Genode::Lock do_not_use_sth_;
|
||||
#ifdef GPR_HAS_PTHREAD_H
|
||||
pthread_mutex_t do_not_use_pth_;
|
||||
#endif
|
||||
diff --git a/src/lib/grpc/src/cpp/server/external_connection_acceptor_impl.h b/src/lib/grpc/src/cpp/server/external_connection_acceptor_impl.h
|
||||
index b5bd935..e835bbf 100644
|
||||
--- a/src/cpp/server/external_connection_acceptor_impl.h
|
||||
+++ b/src/cpp/server/external_connection_acceptor_impl.h
|
||||
@@ -20,7 +20,7 @@
|
||||
#define SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_
|
||||
|
||||
#include <memory>
|
||||
-#include <mutex>
|
||||
+#include <base/lock.h>
|
||||
|
||||
#include <grpc/impl/codegen/grpc_types.h>
|
||||
#include <grpcpp/security/server_credentials.h>
|
||||
@@ -60,7 +60,7 @@ class ExternalConnectionAcceptorImpl
|
||||
const grpc::string name_;
|
||||
std::shared_ptr<ServerCredentials> creds_;
|
||||
grpc_core::TcpServerFdHandler* handler_ = nullptr; // not owned
|
||||
- std::mutex mu_;
|
||||
+ Genode::Lock mu_;
|
||||
bool has_acceptor_ = false;
|
||||
bool started_ = false;
|
||||
bool shutdown_ = false;
|
||||
diff --git a/src/lib/grpc/src/cpp/server/external_connection_acceptor_impl.cc b/src/lib/grpc/src/cpp/server/external_connection_acceptor_impl.cc
|
||||
index 7f0e2dc..a788b0d 100644
|
||||
--- a/src/cpp/server/external_connection_acceptor_impl.cc
|
||||
+++ b/src/cpp/server/external_connection_acceptor_impl.cc
|
||||
@@ -52,7 +52,7 @@ ExternalConnectionAcceptorImpl::ExternalConnectionAcceptorImpl(
|
||||
|
||||
std::unique_ptr<experimental::ExternalConnectionAcceptor>
|
||||
ExternalConnectionAcceptorImpl::GetAcceptor() {
|
||||
- std::lock_guard<std::mutex> lock(mu_);
|
||||
+ std::lock_guard<Genode::Lock> lock(mu_);
|
||||
GPR_ASSERT(!has_acceptor_);
|
||||
has_acceptor_ = true;
|
||||
return std::unique_ptr<experimental::ExternalConnectionAcceptor>(
|
||||
@@ -61,7 +61,7 @@ ExternalConnectionAcceptorImpl::GetAcceptor() {
|
||||
|
||||
void ExternalConnectionAcceptorImpl::HandleNewConnection(
|
||||
experimental::ExternalConnectionAcceptor::NewConnectionParameters* p) {
|
||||
- std::lock_guard<std::mutex> lock(mu_);
|
||||
+ std::lock_guard<Genode::Lock> lock(mu_);
|
||||
if (shutdown_ || !started_) {
|
||||
// TODO(yangg) clean up.
|
||||
gpr_log(
|
||||
@@ -76,12 +76,12 @@ void ExternalConnectionAcceptorImpl::HandleNewConnection(
|
||||
}
|
||||
|
||||
void ExternalConnectionAcceptorImpl::Shutdown() {
|
||||
- std::lock_guard<std::mutex> lock(mu_);
|
||||
+ std::lock_guard<Genode::Lock> lock(mu_);
|
||||
shutdown_ = true;
|
||||
}
|
||||
|
||||
void ExternalConnectionAcceptorImpl::Start() {
|
||||
- std::lock_guard<std::mutex> lock(mu_);
|
||||
+ std::lock_guard<Genode::Lock> lock(mu_);
|
||||
GPR_ASSERT(!started_);
|
||||
GPR_ASSERT(has_acceptor_);
|
||||
GPR_ASSERT(!shutdown_);
|
||||
@@ -1,39 +0,0 @@
|
||||
diff --git a/src/cpp/util/core_stats.h b/src/cpp/util/core_stats.h
|
||||
index 6366d7d..0f0e2ee 100644
|
||||
--- a/src/cpp/util/core_stats.h
|
||||
+++ b/src/cpp/util/core_stats.h
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef GRPC_INTERNAL_CPP_UTIL_CORE_STATS_H
|
||||
#define GRPC_INTERNAL_CPP_UTIL_CORE_STATS_H
|
||||
|
||||
-#include "src/proto/grpc/core/stats.pb.h"
|
||||
+#include "stats.pb.h"
|
||||
|
||||
#include "src/core/lib/debug/stats.h"
|
||||
|
||||
diff --git a/src/cpp/util/error_details.cc b/src/cpp/util/error_details.cc
|
||||
index a1aafcb..6be9390 100644
|
||||
--- a/src/cpp/util/error_details.cc
|
||||
+++ b/src/cpp/util/error_details.cc
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <grpcpp/support/error_details.h>
|
||||
|
||||
-#include "src/proto/grpc/status/status.pb.h"
|
||||
+#include "status.pb.h"
|
||||
|
||||
namespace grpc_impl {
|
||||
|
||||
diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h
|
||||
index bf40c3c180..69f36c3e96 100644
|
||||
--- a/src/cpp/ext/proto_server_reflection.h
|
||||
+++ b/src/cpp/ext/proto_server_reflection.h
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
-#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h"
|
||||
+#include "reflection.grpc.pb.h"
|
||||
|
||||
namespace grpc {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
|
||||
index f1ba20dcec..0d94d79246 100644
|
||||
--- a/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
|
||||
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
|
||||
@@ -29,13 +29,8 @@
|
||||
|
||||
#include <grpc/support/log.h>
|
||||
|
||||
-uint32_t grpc_if_nametoindex(char* name) {
|
||||
- uint32_t out = if_nametoindex(name);
|
||||
- if (out == 0) {
|
||||
- gpr_log(GPR_DEBUG, "if_nametoindex failed for name %s. errno %d", name,
|
||||
- errno);
|
||||
- }
|
||||
- return out;
|
||||
+uint32_t grpc_if_nametoindex(char*) {
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
#endif /* GRPC_IF_NAMETOINDEX == 1 && \
|
||||
@@ -1,152 +0,0 @@
|
||||
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc
|
||||
index 47d9f51b09..66abe6982a 100644
|
||||
--- a/src/core/lib/iomgr/socket_utils_common_posix.cc
|
||||
+++ b/src/core/lib/iomgr/socket_utils_common_posix.cc
|
||||
@@ -70,21 +70,21 @@ grpc_error* grpc_set_socket_nonblocking(int fd, int non_blocking) {
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
-grpc_error* grpc_set_socket_no_sigpipe_if_possible(int fd) {
|
||||
-#ifdef GRPC_HAVE_SO_NOSIGPIPE
|
||||
- int val = 1;
|
||||
- int newval;
|
||||
- socklen_t intlen = sizeof(newval);
|
||||
- if (0 != setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val))) {
|
||||
- return GRPC_OS_ERROR(errno, "setsockopt(SO_NOSIGPIPE)");
|
||||
- }
|
||||
- if (0 != getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &newval, &intlen)) {
|
||||
- return GRPC_OS_ERROR(errno, "getsockopt(SO_NOSIGPIPE)");
|
||||
- }
|
||||
- if ((newval != 0) != (val != 0)) {
|
||||
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_NOSIGPIPE");
|
||||
- }
|
||||
-#endif
|
||||
+grpc_error* grpc_set_socket_no_sigpipe_if_possible(int /*fd*/) {
|
||||
+//#ifdef GRPC_HAVE_SO_NOSIGPIPE
|
||||
+// int val = 1;
|
||||
+// int newval;
|
||||
+// socklen_t intlen = sizeof(newval);
|
||||
+// if (0 != setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val))) {
|
||||
+// return GRPC_OS_ERROR(errno, "setsockopt(SO_NOSIGPIPE)");
|
||||
+// }
|
||||
+// if (0 != getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &newval, &intlen)) {
|
||||
+// return GRPC_OS_ERROR(errno, "getsockopt(SO_NOSIGPIPE)");
|
||||
+// }
|
||||
+// if ((newval != 0) != (val != 0)) {
|
||||
+// return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_NOSIGPIPE");
|
||||
+// }
|
||||
+//#endif
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -125,22 +125,22 @@ grpc_error* grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) {
|
||||
}
|
||||
|
||||
/* set a socket to close on exec */
|
||||
-grpc_error* grpc_set_socket_cloexec(int fd, int close_on_exec) {
|
||||
- int oldflags = fcntl(fd, F_GETFD, 0);
|
||||
- if (oldflags < 0) {
|
||||
- return GRPC_OS_ERROR(errno, "fcntl");
|
||||
- }
|
||||
-
|
||||
- if (close_on_exec) {
|
||||
- oldflags |= FD_CLOEXEC;
|
||||
- } else {
|
||||
- oldflags &= ~FD_CLOEXEC;
|
||||
- }
|
||||
-
|
||||
- if (fcntl(fd, F_SETFD, oldflags) != 0) {
|
||||
- return GRPC_OS_ERROR(errno, "fcntl");
|
||||
- }
|
||||
-
|
||||
+grpc_error* grpc_set_socket_cloexec(int /*fd*/, int /*close_on_exec*/) {
|
||||
+// int oldflags = fcntl(fd, F_GETFD, 0);
|
||||
+// if (oldflags < 0) {
|
||||
+// return GRPC_OS_ERROR(errno, "fcntl");
|
||||
+// }
|
||||
+//
|
||||
+// if (close_on_exec) {
|
||||
+// oldflags |= FD_CLOEXEC;
|
||||
+// } else {
|
||||
+// oldflags &= ~FD_CLOEXEC;
|
||||
+// }
|
||||
+//
|
||||
+// if (fcntl(fd, F_SETFD, oldflags) != 0) {
|
||||
+// return GRPC_OS_ERROR(errno, "fcntl");
|
||||
+// }
|
||||
+//
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -163,24 +163,24 @@ grpc_error* grpc_set_socket_reuse_addr(int fd, int reuse) {
|
||||
}
|
||||
|
||||
/* set a socket to reuse old addresses */
|
||||
-grpc_error* grpc_set_socket_reuse_port(int fd, int reuse) {
|
||||
+grpc_error* grpc_set_socket_reuse_port(int /*fd*/, int /*reuse*/) {
|
||||
#ifndef SO_REUSEPORT
|
||||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
"SO_REUSEPORT unavailable on compiling system");
|
||||
#else
|
||||
- int val = (reuse != 0);
|
||||
- int newval;
|
||||
- socklen_t intlen = sizeof(newval);
|
||||
- if (0 != setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val))) {
|
||||
- return GRPC_OS_ERROR(errno, "setsockopt(SO_REUSEPORT)");
|
||||
- }
|
||||
- if (0 != getsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &newval, &intlen)) {
|
||||
- return GRPC_OS_ERROR(errno, "getsockopt(SO_REUSEPORT)");
|
||||
- }
|
||||
- if ((newval != 0) != val) {
|
||||
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_REUSEPORT");
|
||||
- }
|
||||
-
|
||||
+// int val = (reuse != 0);
|
||||
+// int newval;
|
||||
+// socklen_t intlen = sizeof(newval);
|
||||
+// if (0 != setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val))) {
|
||||
+// return GRPC_OS_ERROR(errno, "setsockopt(SO_REUSEPORT)");
|
||||
+// }
|
||||
+// if (0 != getsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &newval, &intlen)) {
|
||||
+// return GRPC_OS_ERROR(errno, "getsockopt(SO_REUSEPORT)");
|
||||
+// }
|
||||
+// if ((newval != 0) != val) {
|
||||
+// return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_REUSEPORT");
|
||||
+// }
|
||||
+//
|
||||
return GRPC_ERROR_NONE;
|
||||
#endif
|
||||
}
|
||||
@@ -210,19 +210,19 @@ bool grpc_is_socket_reuse_port_supported() {
|
||||
}
|
||||
|
||||
/* disable nagle */
|
||||
-grpc_error* grpc_set_socket_low_latency(int fd, int low_latency) {
|
||||
- int val = (low_latency != 0);
|
||||
- int newval;
|
||||
- socklen_t intlen = sizeof(newval);
|
||||
- if (0 != setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val))) {
|
||||
- return GRPC_OS_ERROR(errno, "setsockopt(TCP_NODELAY)");
|
||||
- }
|
||||
- if (0 != getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &newval, &intlen)) {
|
||||
- return GRPC_OS_ERROR(errno, "getsockopt(TCP_NODELAY)");
|
||||
- }
|
||||
- if ((newval != 0) != val) {
|
||||
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set TCP_NODELAY");
|
||||
- }
|
||||
+grpc_error* grpc_set_socket_low_latency(int /*fd*/, int /*low_latency*/) {
|
||||
+// int val = (low_latency != 0);
|
||||
+// int newval;
|
||||
+// socklen_t intlen = sizeof(newval);
|
||||
+// if (0 != setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val))) {
|
||||
+// return GRPC_OS_ERROR(errno, "setsockopt(TCP_NODELAY)");
|
||||
+// }
|
||||
+// if (0 != getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &newval, &intlen)) {
|
||||
+// return GRPC_OS_ERROR(errno, "getsockopt(TCP_NODELAY)");
|
||||
+// }
|
||||
+// if ((newval != 0) != val) {
|
||||
+// return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set TCP_NODELAY");
|
||||
+// }
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
diff --git a/examples/cpp/helloworld/greeter_client.cc b/examples/cpp/helloworld/greeter_client.cc
|
||||
index 932583c84a..0fa38aac38 100644
|
||||
--- a/examples/cpp/helloworld/greeter_client.cc
|
||||
+++ b/examples/cpp/helloworld/greeter_client.cc
|
||||
@@ -77,7 +77,7 @@ int main(int argc, char** argv) {
|
||||
// localhost at port 50051). We indicate that the channel isn't authenticated
|
||||
// (use of InsecureChannelCredentials()).
|
||||
GreeterClient greeter(grpc::CreateChannel(
|
||||
- "localhost:50051", grpc::InsecureChannelCredentials()));
|
||||
+ "10.10.10.55:50051", grpc::InsecureChannelCredentials()));
|
||||
std::string user("world");
|
||||
std::string reply = greeter.SayHello(user);
|
||||
std::cout << "Greeter received: " << reply << std::endl;
|
||||
diff --git a/examples/cpp/helloworld/greeter_server.cc b/examples/cpp/helloworld/greeter_server.cc
|
||||
index f36ad906a2..03025b7920 100644
|
||||
--- a/examples/cpp/helloworld/greeter_server.cc
|
||||
+++ b/examples/cpp/helloworld/greeter_server.cc
|
||||
@@ -47,7 +47,7 @@ class GreeterServiceImpl final : public Greeter::Service {
|
||||
};
|
||||
|
||||
void RunServer() {
|
||||
- std::string server_address("0.0.0.0:50051");
|
||||
+ std::string server_address("10.10.10.55:50051");
|
||||
GreeterServiceImpl service;
|
||||
|
||||
ServerBuilder builder;
|
||||
@@ -1,12 +0,0 @@
|
||||
diff --git a/third_party/genode/if_indextoname.c b/third_party/genode/if_indextoname.c
|
||||
new file mode 100644
|
||||
index 0000000000..9ea67cee0c
|
||||
--- /dev/null
|
||||
+++ b/third_party/genode/if_indextoname.c
|
||||
@@ -0,0 +1,6 @@
|
||||
+char * if_indextoname(unsigned int ifindex, char *ifname)
|
||||
+{
|
||||
+ const char* name = "eth0";
|
||||
+ ifname = name;
|
||||
+ return ifname;
|
||||
+}
|
||||
@@ -1,28 +0,0 @@
|
||||
commit 3a55e1d3c8ab37fb14a9a2875db0e031044d4863
|
||||
Author: Pirmin Duss <pirmin.duss@gapfruit.com>
|
||||
Date: Mon Sep 23 16:16:57 2019 +0200
|
||||
|
||||
Mutex fixes
|
||||
|
||||
diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h
|
||||
index a311889..967be6a 100644
|
||||
--- a/src/google/protobuf/stubs/mutex.h
|
||||
+++ b/src/google/protobuf/stubs/mutex.h
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef GOOGLE_PROTOBUF_STUBS_MUTEX_H_
|
||||
#define GOOGLE_PROTOBUF_STUBS_MUTEX_H_
|
||||
|
||||
-#include <mutex>
|
||||
+#include <base/lock.h>
|
||||
|
||||
#ifdef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
|
||||
@@ -104,7 +104,7 @@ class PROTOBUF_EXPORT GOOGLE_PROTOBUF_CAPABILITY("mutex") WrappedMutex {
|
||||
|
||||
private:
|
||||
#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
- std::mutex mu_;
|
||||
+ Genode::Lock mu_;
|
||||
#else // ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
CriticalSectionLock mu_;
|
||||
#endif // #ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
@@ -1,34 +0,0 @@
|
||||
commit 420f5bb78bfd61825ad5d3bc52a27469f298d17b
|
||||
Author: Pirmin Duss <pirmin.duss@gapfruit.com>
|
||||
Date: Mon Sep 23 16:33:08 2019 +0200
|
||||
|
||||
run_once fix
|
||||
|
||||
diff --git a/src/google/protobuf/stubs/once.h b/src/google/protobuf/stubs/once.h
|
||||
index 070d36d..3602ee7 100644
|
||||
--- a/src/google/protobuf/stubs/once.h
|
||||
+++ b/src/google/protobuf/stubs/once.h
|
||||
@@ -31,19 +31,16 @@
|
||||
#ifndef GOOGLE_PROTOBUF_STUBS_ONCE_H__
|
||||
#define GOOGLE_PROTOBUF_STUBS_ONCE_H__
|
||||
|
||||
-#include <mutex>
|
||||
-#include <utility>
|
||||
-
|
||||
#include <google/protobuf/port_def.inc>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace internal {
|
||||
|
||||
-using once_flag = std::once_flag;
|
||||
-template <typename... Args>
|
||||
-void call_once(Args&&... args ) {
|
||||
- std::call_once(std::forward<Args>(args)...);
|
||||
+using once_flag = int;
|
||||
+template <typename FN, typename... Args>
|
||||
+void call_once(once_flag, FN fn, Args&&... args ) {
|
||||
+ fn(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
@@ -1,45 +0,0 @@
|
||||
diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc
|
||||
index 36d7307..04a565b 100644
|
||||
--- a/src/google/protobuf/generated_message_util.cc
|
||||
+++ b/src/google/protobuf/generated_message_util.cc
|
||||
@@ -799,8 +799,8 @@ void InitSCCImpl(SCCInfoBase* scc) {
|
||||
// Either the default in case no initialization is running or the id of the
|
||||
// thread that is currently initializing.
|
||||
#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
- static std::atomic<std::thread::id> runner;
|
||||
- auto me = std::this_thread::get_id();
|
||||
+ static std::atomic<long long> runner = -1LL;
|
||||
+ auto me = 1LL;
|
||||
#else
|
||||
// This is a lightweight replacement for std::thread::id. std::thread does not
|
||||
// work on Windows XP SP2 with the latest VC++ libraries, because it utilizes
|
||||
@@ -811,20 +811,20 @@ void InitSCCImpl(SCCInfoBase* scc) {
|
||||
|
||||
// This will only happen because the constructor will call InitSCC while
|
||||
// constructing the default instance.
|
||||
- if (runner.load(std::memory_order_relaxed) == me) {
|
||||
- // Because we're in the process of constructing the default instance.
|
||||
- // We can be assured that we're already exploring this SCC.
|
||||
- GOOGLE_CHECK_EQ(scc->visit_status.load(std::memory_order_relaxed),
|
||||
- SCCInfoBase::kRunning);
|
||||
- return;
|
||||
- }
|
||||
+ if (runner.load(std::memory_order_relaxed) == me) {
|
||||
+ // Because we're in the process of constructing the default instance.
|
||||
+ // We can be assured that we're already exploring this SCC.
|
||||
+ GOOGLE_CHECK_EQ(scc->visit_status.load(std::memory_order_relaxed),
|
||||
+ SCCInfoBase::kRunning);
|
||||
+ return;
|
||||
+ }
|
||||
InitProtobufDefaults();
|
||||
mu.Lock();
|
||||
- runner.store(me, std::memory_order_relaxed);
|
||||
+ runner.store(me, std::memory_order_relaxed);
|
||||
InitSCC_DFS(scc);
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
- runner.store(std::thread::id{}, std::memory_order_relaxed);
|
||||
+ runner.store(0, std::memory_order_relaxed);
|
||||
#else
|
||||
runner.store(-1, std::memory_order_relaxed);
|
||||
#endif // #ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
|
||||
Reference in New Issue
Block a user