From 609676daf2d6b2c0d04948458dcfd2b8bd629202 Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Sun, 12 Jan 2025 19:08:46 +0800 Subject: [PATCH 1/6] Support tcp user timeout of client --- src/brpc/input_messenger.cpp | 17 +- src/brpc/socket.cpp | 49 ++++-- src/brpc/socket.h | 52 +++--- src/brpc/socket_inl.h | 15 -- src/brpc/versioned_ref_with_id.h | 4 +- test/brpc_socket_unittest.cpp | 279 ++++++++++++++++--------------- 6 files changed, 222 insertions(+), 194 deletions(-) diff --git a/src/brpc/input_messenger.cpp b/src/brpc/input_messenger.cpp index b28c704415..afb8fb3f5e 100644 --- a/src/brpc/input_messenger.cpp +++ b/src/brpc/input_messenger.cpp @@ -57,13 +57,20 @@ DEFINE_bool(socket_keepalive, false, "Enable keepalive of sockets if this value is true"); DEFINE_int32(socket_keepalive_idle_s, -1, - "Set idle time of sockets before keepalive if this value is positive"); + "Set idle time for socket keepalive in seconds if this value is positive"); DEFINE_int32(socket_keepalive_interval_s, -1, - "Set interval of sockets between keepalives if this value is positive"); + "Set interval between keepalives in seconds if this value is positive"); DEFINE_int32(socket_keepalive_count, -1, - "Set number of keepalives of sockets before close if this value is positive"); + "Set number of keepalives before death if this value is positive"); + +DEFINE_int32(socket_tcp_user_timeout_ms, -1, + "If this value is positive, set number of milliseconds that transmitted " + "data may remain unacknowledged, or bufferred data may remain untransmitted " + "(due to zero window size) before TCP will forcibly close the corresponding " + "connection and return ETIMEDOUT to the application. Only linux supports " + "TCP_USER_TIMEOUT."); DECLARE_bool(usercode_in_pthread); DECLARE_bool(usercode_in_coroutine); @@ -501,6 +508,7 @@ int InputMessenger::Create(const butil::EndPoint& remote_side, options.keepalive_options->keepalive_count = FLAGS_socket_keepalive_count; } + options.tcp_user_timeout_ms = FLAGS_socket_tcp_user_timeout_ms; return Socket::Create(options, id); } @@ -535,6 +543,9 @@ int InputMessenger::Create(SocketOptions options, SocketId* id) { = FLAGS_socket_keepalive_count; } } + if (options.tcp_user_timeout_ms <= 0) { + options.tcp_user_timeout_ms = FLAGS_socket_tcp_user_timeout_ms; + } return Socket::Create(options, id); } diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 0201a97880..ac4c6892c0 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -492,6 +492,7 @@ Socket::Socket(Forbidden f) , _stream_set(NULL) , _total_streams_unconsumed_size(0) , _ninflight_app_health_check(0) + , _tcp_user_timeout_ms(-1) , _http_request_method(HTTP_METHOD_GET) { CreateVarsOnce(); pthread_mutex_init(&_id_wait_list_mutex, NULL); @@ -597,6 +598,21 @@ int Socket::ResetFileDescriptor(int fd) { // turn off nagling. // OK to fail, namely unix domain socket does not support this. butil::make_no_delay(fd); + + SetSocketOptions(fd); + + if (_on_edge_triggered_events) { + if (_io_event.AddConsumer(fd) != 0) { + PLOG(ERROR) << "Fail to add SocketId=" << id() + << " into EventDispatcher"; + _fd.store(-1, butil::memory_order_release); + return -1; + } + } + return 0; +} + +void Socket::SetSocketOptions(int fd) { if (_tos > 0 && setsockopt(fd, IPPROTO_IP, IP_TOS, &_tos, sizeof(_tos)) != 0) { PLOG(ERROR) << "Fail to set tos of fd=" << fd << " to " << _tos; @@ -618,27 +634,21 @@ int Socket::ResetFileDescriptor(int fd) { } } - EnableKeepaliveIfNeeded(fd); - - if (_on_edge_triggered_events) { - if (_io_event.AddConsumer(fd) != 0) { - PLOG(ERROR) << "Fail to add SocketId=" << id() - << " into EventDispatcher"; - _fd.store(-1, butil::memory_order_release); - return -1; +#if defined(OS_LINUX) + if (_tcp_user_timeout_ms > 0) { + if (setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, + &_tcp_user_timeout_ms, sizeof(_tcp_user_timeout_ms)) != 0) { + PLOG(ERROR) << "Fail to set TCP_USER_TIMEOUT of fd=" << fd; } } - return 0; -} +#endif -void Socket::EnableKeepaliveIfNeeded(int fd) { if (!_keepalive_options) { return; } int keepalive = 1; - if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, - sizeof(keepalive)) != 0) { + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) != 0) { PLOG(ERROR) << "Fail to set keepalive of fd=" << fd; return; } @@ -782,6 +792,7 @@ int Socket::OnCreated(const SocketOptions& options) { _last_writetime_us.store(cpuwide_now, butil::memory_order_relaxed); _unwritten_bytes.store(0, butil::memory_order_relaxed); _keepalive_options = options.keepalive_options; + _tcp_user_timeout_ms = options.tcp_user_timeout_ms; CHECK(NULL == _write_head.load(butil::memory_order_relaxed)); _is_write_shutdown = false; int fd = options.fd; @@ -1388,7 +1399,7 @@ int Socket::CheckConnected(int sockfd) { butil::EndPoint local_point; CHECK_EQ(0, butil::get_local_side(sockfd, &local_point)); LOG(INFO) << "Connected to " << remote_side() - << " via fd=" << (int)sockfd << " SocketId=" << id() + << " via fd=" << sockfd << " SocketId=" << id() << " local_side=" << local_point; } @@ -2501,6 +2512,16 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) { #endif } +#if defined(OS_LINUX) + { + int tcp_user_timeout = 0; + socklen_t len = sizeof(tcp_user_timeout); + if (getsockopt(fd, SOL_TCP, TCP_USER_TIMEOUT, &tcp_user_timeout, &len) == 0) { + os << "\ntcp_user_timeout=" << tcp_user_timeout; + } + } +#endif + #if defined(OS_MACOSX) struct tcp_connection_info ti; socklen_t len = sizeof(ti); diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 2a6ab748f2..a84c0abdcf 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -234,60 +234,57 @@ struct SocketSSLContext { }; struct SocketKeepaliveOptions { - SocketKeepaliveOptions() - : keepalive_idle_s(-1) - , keepalive_interval_s(-1) - , keepalive_count(-1) - {} // Start keeplives after this period. - int keepalive_idle_s; + int keepalive_idle_s{-1}; // Interval between keepalives. - int keepalive_interval_s; + int keepalive_interval_s{-1}; // Number of keepalives before death. - int keepalive_count; + int keepalive_count{-1}; }; // TODO: Comment fields struct SocketOptions { - SocketOptions(); - // If `fd' is non-negative, set `fd' to be non-blocking and take the // ownership. Socket will close the fd(if needed) and call // user->BeforeRecycle() before recycling. - int fd; + int fd{-1}; butil::EndPoint remote_side; // If `connect_on_create' is true and `fd' is less than 0, // a client connection will be established to remote_side() // regarding deadline `connect_abstime' when Socket is being created. // Default: false, means that a connection will be established // on first write. - bool connect_on_create; + bool connect_on_create{false}; // Default: NULL, means no timeout. - const timespec* connect_abstime; - SocketUser* user; + const timespec* connect_abstime{NULL}; + SocketUser* user{NULL}; // When *edge-triggered* events happen on the file descriptor, callback // `on_edge_triggered_events' will be called. Inside the callback, user // shall read fd() in non-blocking mode until all data has been read // or EAGAIN is met, otherwise the callback will not be called again // until new data arrives. The callback will not be called from more than // one thread at any time. - void (*on_edge_triggered_events)(Socket*); - int health_check_interval_s; + void (*on_edge_triggered_events)(Socket*){NULL}; + int health_check_interval_s{-1}; // Only accept ssl connection. - bool force_ssl; + bool force_ssl{false}; std::shared_ptr initial_ssl_ctx; - bool use_rdma; - bthread_keytable_pool_t* keytable_pool; - SocketConnection* conn; + bool use_rdma{false}; + bthread_keytable_pool_t* keytable_pool{NULL}; + SocketConnection* conn{NULL}; std::shared_ptr app_connect; // The created socket will set parsing_context with this value. - Destroyable* initial_parsing_context; + Destroyable* initial_parsing_context{NULL}; // Socket keepalive related options. // Refer to `SocketKeepaliveOptions' for details. std::shared_ptr keepalive_options; + // https://github.com/apache/brpc/issues/1154 + // https://github.com/grpc/grpc/pull/16419/files + // Only linux supports TCP_USER_TIMEOUT. + int tcp_user_timeout_ms{ -1}; // Tag of this socket - bthread_tag_t bthread_tag; + bthread_tag_t bthread_tag{BTHREAD_TAG_DEFAULT}; }; // Abstractions on reading from and writing into file descriptors. @@ -725,7 +722,7 @@ friend void DereferenceSocket(Socket*); int ResetFileDescriptor(int fd); - void EnableKeepaliveIfNeeded(int fd); + void SetSocketOptions(int fd); // Wait until nref hits `expected_nref' and reset some internal resources. int WaitAndReset(int32_t expected_nref); @@ -973,6 +970,15 @@ friend void DereferenceSocket(Socket*); // non-NULL means that keepalive is on. std::shared_ptr _keepalive_options; + // Only linux supports TCP_USER_TIMEOUT. + // When the value is greater than 0, it specifies the maximum + // amount of time in milliseconds that transmitted data may + // remain unacknowledged, or bufferred data may remain + // untransmitted (due to zero window size) before TCP will + // forcibly close the corresponding connection and return + // ETIMEDOUT to the application. + int _tcp_user_timeout_ms; + HttpMethod _http_request_method; }; diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index d704b90053..ea8a392ef2 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -23,21 +23,6 @@ namespace brpc { -inline SocketOptions::SocketOptions() - : fd(-1) - , connect_on_create(false) - , connect_abstime(NULL) - , user(NULL) - , on_edge_triggered_events(NULL) - , health_check_interval_s(-1) - , force_ssl(false) - , use_rdma(false) - , keytable_pool(NULL) - , conn(NULL) - , app_connect(NULL) - , initial_parsing_context(NULL) - , bthread_tag(BTHREAD_TAG_DEFAULT) {} - inline bool Socket::MoreReadEvents(int* progress) { // Fail to CAS means that new events arrived. return !_nevent.compare_exchange_strong( diff --git a/src/brpc/versioned_ref_with_id.h b/src/brpc/versioned_ref_with_id.h index 23ea0e0ad1..e7c3ef8d71 100644 --- a/src/brpc/versioned_ref_with_id.h +++ b/src/brpc/versioned_ref_with_id.h @@ -211,7 +211,7 @@ class VersionedRefWithId { // Create a VersionedRefWithId, put the identifier into `id'. // `args' will be passed to OnCreated() directly. // Returns 0 on success, -1 otherwise. - template + template static int Create(VRefId* id, Args&&... args); // Place the VersionedRefWithId associated with identifier `id' into @@ -350,7 +350,7 @@ void DereferenceVersionedRefWithId(T* r) { } template -template +template int VersionedRefWithId::Create(VRefId* id, Args&&... args) { resource_id_t slot; T* const t = butil::get_resource(&slot, Forbidden()); diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 3f9b88ad8d..59075b2bdb 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -59,6 +59,7 @@ DECLARE_bool(socket_keepalive); DECLARE_int32(socket_keepalive_idle_s); DECLARE_int32(socket_keepalive_interval_s); DECLARE_int32(socket_keepalive_count); +DECLARE_int32(socket_tcp_user_timeout_ms); } void EchoProcessHuluRequest(brpc::InputMessageBase* msg_base); @@ -1113,16 +1114,15 @@ TEST_F(SocketTest, keepalive) { int default_keepalive_count = 0; { butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); - GetKeepaliveValue(sockfd, - default_keepalive, - default_keepalive_idle, - default_keepalive_interval, - default_keepalive_count); + ASSERT_GT(sockfd, 0); + GetKeepaliveValue(sockfd, default_keepalive, default_keepalive_idle, + default_keepalive_interval, default_keepalive_count); } // Disable keepalive. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; brpc::SocketId id; @@ -1130,7 +1130,6 @@ TEST_F(SocketTest, keepalive) { brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); CheckNoKeepalive(ptr->fd()); - sockfd.release(); } int keepalive_idle = 1; @@ -1138,7 +1137,8 @@ TEST_F(SocketTest, keepalive) { int keepalive_count = 2; // Enable keepalive. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); @@ -1146,17 +1146,14 @@ TEST_F(SocketTest, keepalive) { ASSERT_EQ(0, brpc::Socket::Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - default_keepalive_idle, - default_keepalive_interval, - default_keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, default_keepalive_idle, + default_keepalive_interval, default_keepalive_count); } // Enable keepalive and set keepalive idle. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); @@ -1166,17 +1163,15 @@ TEST_F(SocketTest, keepalive) { ASSERT_EQ(0, brpc::Socket::Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - keepalive_idle, + CheckKeepalive(ptr->fd(), true, keepalive_idle, default_keepalive_interval, default_keepalive_count); - sockfd.release(); } // Enable keepalive and set keepalive interval. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); @@ -1186,56 +1181,42 @@ TEST_F(SocketTest, keepalive) { ASSERT_EQ(0, brpc::Socket::Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - default_keepalive_idle, - keepalive_interval, - default_keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, default_keepalive_idle, + keepalive_interval, default_keepalive_count); } // Enable keepalive and set keepalive count. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); - options.keepalive_options->keepalive_count - = keepalive_count; + options.keepalive_options->keepalive_count = keepalive_count; brpc::SocketId id; ASSERT_EQ(0, brpc::Socket::Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - default_keepalive_idle, - default_keepalive_interval, - keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, default_keepalive_idle, + default_keepalive_interval, keepalive_count); } // Enable keepalive and set keepalive idle, interval, count. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); - options.keepalive_options->keepalive_idle_s - = keepalive_idle; - options.keepalive_options->keepalive_interval_s - = keepalive_interval; - options.keepalive_options->keepalive_count - = keepalive_count; + options.keepalive_options->keepalive_idle_s = keepalive_idle; + options.keepalive_options->keepalive_interval_s = keepalive_interval; + options.keepalive_options->keepalive_count = keepalive_count; brpc::SocketId id; ASSERT_EQ(0, brpc::Socket::Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - keepalive_idle, - keepalive_interval, - keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, keepalive_idle, + keepalive_interval, keepalive_count); } } @@ -1246,101 +1227,83 @@ TEST_F(SocketTest, keepalive_input_message) { int default_keepalive_count = 0; { butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); - GetKeepaliveValue(sockfd, - default_keepalive, - default_keepalive_idle, - default_keepalive_interval, - default_keepalive_count); + ASSERT_GT(sockfd, 0); + GetKeepaliveValue(sockfd, default_keepalive, default_keepalive_idle, + default_keepalive_interval, default_keepalive_count); } // Disable keepalive. { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); CheckNoKeepalive(ptr->fd()); - sockfd.release(); } // Enable keepalive. brpc::FLAGS_socket_keepalive = true; { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - default_keepalive_idle, - default_keepalive_interval, - default_keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, default_keepalive_idle, + default_keepalive_interval, default_keepalive_count); } // Enable keepalive and set keepalive idle. brpc::FLAGS_socket_keepalive_idle_s = 10; { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - brpc::FLAGS_socket_keepalive_idle_s, - default_keepalive_interval, - default_keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, brpc::FLAGS_socket_keepalive_idle_s, + default_keepalive_interval, default_keepalive_count); } // Enable keepalive and set keepalive idle, interval. brpc::FLAGS_socket_keepalive_interval_s = 10; { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - brpc::FLAGS_socket_keepalive_idle_s, - brpc::FLAGS_socket_keepalive_interval_s, - default_keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, brpc::FLAGS_socket_keepalive_idle_s, + brpc::FLAGS_socket_keepalive_interval_s, default_keepalive_count); } // Enable keepalive and set keepalive idle, interval, count. brpc::FLAGS_socket_keepalive_count = 10; { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - brpc::FLAGS_socket_keepalive_idle_s, + CheckKeepalive(ptr->fd(), true, brpc::FLAGS_socket_keepalive_idle_s, brpc::FLAGS_socket_keepalive_interval_s, brpc::FLAGS_socket_keepalive_count); - sockfd.release(); } // Options of keepalive set by user have priority over Gflags. @@ -1348,90 +1311,132 @@ TEST_F(SocketTest, keepalive_input_message) { int keepalive_interval = 2; int keepalive_count = 2; { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); - options.keepalive_options->keepalive_idle_s - = keepalive_idle; + options.keepalive_options->keepalive_idle_s = keepalive_idle; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - keepalive_idle, + CheckKeepalive(ptr->fd(), true, keepalive_idle, brpc::FLAGS_socket_keepalive_interval_s, brpc::FLAGS_socket_keepalive_count); - sockfd.release(); } { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); - options.keepalive_options->keepalive_interval_s - = keepalive_interval; + options.keepalive_options->keepalive_interval_s = keepalive_interval; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - brpc::FLAGS_socket_keepalive_idle_s, - keepalive_interval, - brpc::FLAGS_socket_keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, brpc::FLAGS_socket_keepalive_idle_s, + keepalive_interval, brpc::FLAGS_socket_keepalive_count); } { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); - options.keepalive_options->keepalive_count - = keepalive_count; + options.keepalive_options->keepalive_count = keepalive_count; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - brpc::FLAGS_socket_keepalive_idle_s, - brpc::FLAGS_socket_keepalive_interval_s, - keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, brpc::FLAGS_socket_keepalive_idle_s, + brpc::FLAGS_socket_keepalive_interval_s, keepalive_count); } { - butil::fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); brpc::SocketOptions options; options.fd = sockfd; options.keepalive_options = std::make_shared(); - options.keepalive_options->keepalive_idle_s - = keepalive_idle; - options.keepalive_options->keepalive_interval_s - = keepalive_interval; - options.keepalive_options->keepalive_count - = keepalive_count; + options.keepalive_options->keepalive_idle_s = keepalive_idle; + options.keepalive_options->keepalive_interval_s = keepalive_interval; + options.keepalive_options->keepalive_count = keepalive_count; brpc::SocketId id; - ASSERT_EQ(0, brpc::get_or_new_client_side_messenger() - ->Create(options, &id)); + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); - CheckKeepalive(ptr->fd(), - true, - keepalive_idle, - keepalive_interval, - keepalive_count); - sockfd.release(); + CheckKeepalive(ptr->fd(), true, keepalive_idle, + keepalive_interval, keepalive_count); } } +#if defined(OS_LINUX) +void CheckTCPUserTimeout(int fd, int expect_tcp_user_timeout) { + int tcp_user_timeout = 0; + socklen_t len = sizeof(tcp_user_timeout); + ASSERT_EQ(0, getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &tcp_user_timeout, &len) ); + ASSERT_EQ(tcp_user_timeout, expect_tcp_user_timeout); +} + +TEST_F(SocketTest, tcp_user_timeout) { + { + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); + brpc::SocketOptions options; + options.fd = sockfd; + brpc::SocketId id; + ASSERT_EQ(0, brpc::Socket::Create(options, &id)); + brpc::SocketUniquePtr ptr; + ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); + CheckTCPUserTimeout(ptr->fd(), 0); + } + + { + int tcp_user_timeout_ms = 1000; + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); + brpc::SocketOptions options; + options.fd = sockfd; + options.tcp_user_timeout_ms = tcp_user_timeout_ms; + brpc::SocketId id; + ASSERT_EQ(0, brpc::Socket::Create(options, &id)); + brpc::SocketUniquePtr ptr; + ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); + CheckTCPUserTimeout(ptr->fd(), tcp_user_timeout_ms); + } + + brpc::FLAGS_socket_tcp_user_timeout_ms = 2000; + { + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); + brpc::SocketOptions options; + options.fd = sockfd; + brpc::SocketId id; + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); + brpc::SocketUniquePtr ptr; + ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); + CheckTCPUserTimeout(ptr->fd(), brpc::FLAGS_socket_tcp_user_timeout_ms); + } + { + int tcp_user_timeout_ms = 3000; + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + ASSERT_GT(sockfd, 0); + brpc::SocketOptions options; + options.fd = sockfd; + options.tcp_user_timeout_ms = tcp_user_timeout_ms; + brpc::SocketId id; + ASSERT_EQ(0, brpc::get_or_new_client_side_messenger()->Create(options, &id)); + brpc::SocketUniquePtr ptr; + ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)); + CheckTCPUserTimeout(ptr->fd(), tcp_user_timeout_ms); + } +} +#endif + int HandleSocketSuccessWrite(bthread_id_t id, void* data, int error_code, const std::string& error_text) { auto success_count = static_cast(data); From e45e957b0dd1eb7e69b9250648315f29a824b2a9 Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Thu, 16 Jan 2025 11:05:33 +0800 Subject: [PATCH 2/6] Fix some compilation warning issues (#2876) --- .github/workflows/ci-linux.yml | 8 +++--- config_brpc.sh | 7 ++++- src/brpc/memcache.h | 2 +- src/brpc/policy/http2_rpc_protocol.cpp | 8 ++++-- src/brpc/policy/http_rpc_protocol.cpp | 32 +++++++++++------------ src/brpc/rdma/block_pool.cpp | 4 +-- src/brpc/rdma/rdma_endpoint.cpp | 8 +++--- src/brpc/rdma/rdma_helper.cpp | 2 +- src/brpc/thrift_message.h | 2 +- src/bthread/task_group.cpp | 2 +- src/butil/logging.h | 36 ++++++++++++++++---------- 11 files changed, 63 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 1854483a42..e4db5c0e1b 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -21,7 +21,7 @@ jobs: - uses: ./.github/actions/install-essential-dependences - uses: ./.github/actions/init-make-config with: - options: --cc=gcc --cxx=g++ + options: --cc=gcc --cxx=g++ --werror - name: compile run: | make -j ${{env.proc_num}} @@ -61,7 +61,7 @@ jobs: - uses: ./.github/actions/install-all-dependences - uses: ./.github/actions/init-make-config with: - options: --cc=gcc --cxx=g++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer + options: --cc=gcc --cxx=g++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer --werror - name: compile run: | make -j ${{env.proc_num}} @@ -95,7 +95,7 @@ jobs: - uses: ./.github/actions/install-essential-dependences - uses: ./.github/actions/init-make-config with: - options: --cc=clang --cxx=clang++ + options: --cc=clang --cxx=clang++ --werror - name: compile run: | make -j ${{env.proc_num}} @@ -135,7 +135,7 @@ jobs: - uses: ./.github/actions/install-all-dependences - uses: ./.github/actions/init-make-config with: - options: --cc=clang --cxx=clang++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer + options: --cc=clang --cxx=clang++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer --werror - name: compile run: | make -j ${{env.proc_num}} diff --git a/config_brpc.sh b/config_brpc.sh index 2563b0e28e..afc84a7d68 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -38,7 +38,7 @@ else LDD=ldd fi -TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,nodebugsymbols -n 'config_brpc' -- "$@"` +TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,nodebugsymbols,werror -n 'config_brpc' -- "$@"` WITH_GLOG=0 WITH_THRIFT=0 WITH_RDMA=0 @@ -46,6 +46,7 @@ WITH_MESALINK=0 WITH_BTHREAD_TRACER=0 BRPC_DEBUG_BTHREAD_SCHE_SAFETY=0 DEBUGSYMBOLS=-g +WERROR= BRPC_DEBUG_LOCK=0 if [ $? != 0 ] ; then >&2 $ECHO "Terminating..."; exit 1 ; fi @@ -74,6 +75,7 @@ while true; do --with-debug-bthread-sche-safety ) BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1; shift 1 ;; --with-debug-lock ) BRPC_DEBUG_LOCK=1; shift 1 ;; --nodebugsymbols ) DEBUGSYMBOLS=; shift 1 ;; + --werror ) WERROR=-Werror; shift 1 ;; -- ) shift; break ;; * ) break ;; esac @@ -441,6 +443,9 @@ CPPFLAGS="${CPPFLAGS} -D__const__=__unused__" if [ ! -z "$DEBUGSYMBOLS" ]; then CPPFLAGS="${CPPFLAGS} $DEBUGSYMBOLS" fi +if [ ! -z "$WERROR" ]; then + CPPFLAGS="${CPPFLAGS} $WERROR" +fi if [ "$SYSTEM" = "Darwin" ]; then CPPFLAGS="${CPPFLAGS} -Wno-deprecated-declarations -Wno-inconsistent-missing-override" version=`sw_vers -productVersion | awk -F '.' '{print $1 "." $2}'` diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h index 535516ed20..daedd49861 100644 --- a/src/brpc/memcache.h +++ b/src/brpc/memcache.h @@ -196,7 +196,7 @@ class MemcacheResponse : public NonreflectableMessage { void Clear() override; bool IsInitialized() const PB_527_OVERRIDE; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const override; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE; void SerializeWithCachedSizes( diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index 1fd93bf7bf..e202d32bc2 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -740,9 +740,13 @@ H2ParseResult H2StreamContext::OnData( } } - const int64_t acc = _deferred_window_update.fetch_add(frag_size, butil::memory_order_relaxed) + frag_size; + int64_t acc = frag_size + + _deferred_window_update.fetch_add(frag_size, butil::memory_order_relaxed); + int64_t quota = static_cast( + _conn_ctx->local_settings().stream_window_size / + (_conn_ctx->VolatilePendingStreamSize() + 1)); // Allocate the quota of the window to each stream. - if (acc >= static_cast(_conn_ctx->local_settings().stream_window_size) / (_conn_ctx->VolatilePendingStreamSize() + 1)) { + if (acc >= quota) { if (acc > _conn_ctx->local_settings().stream_window_size) { LOG(ERROR) << "Fail to satisfy the stream-level flow control policy"; return MakeH2Error(H2_FLOW_CONTROL_ERROR, frame_head.stream_id); diff --git a/src/brpc/policy/http_rpc_protocol.cpp b/src/brpc/policy/http_rpc_protocol.cpp index 2dd18076fb..444be39708 100644 --- a/src/brpc/policy/http_rpc_protocol.cpp +++ b/src/brpc/policy/http_rpc_protocol.cpp @@ -1457,9 +1457,9 @@ void ProcessHttpRequest(InputMessageBase *msg) { return svc->CallMethod(md, cntl, NULL, NULL, done); } - const Server::MethodProperty* const sp = + const Server::MethodProperty* const mp = FindMethodPropertyByURI(path, server, &req_header._unresolved_path); - if (NULL == sp) { + if (NULL == mp) { if (security_mode) { std::string escape_path; WebEscape(path, &escape_path); @@ -1468,36 +1468,36 @@ void ProcessHttpRequest(InputMessageBase *msg) { cntl->SetFailed(ENOMETHOD, "Fail to find method on `%s'", path.c_str()); } return; - } else if (sp->service->GetDescriptor() == BadMethodService::descriptor()) { + } else if (mp->service->GetDescriptor() == BadMethodService::descriptor()) { BadMethodRequest breq; BadMethodResponse bres; butil::StringSplitter split(path.c_str(), '/'); breq.set_service_name(std::string(split.field(), split.length())); - sp->service->CallMethod(sp->method, cntl, &breq, &bres, NULL); + mp->service->CallMethod(mp->method, cntl, &breq, &bres, NULL); return; } // Switch to service-specific error. non_service_error.release(); - MethodStatus* method_status = sp->status; + MethodStatus* method_status = mp->status; resp_sender.set_method_status(method_status); if (method_status) { int rejected_cc = 0; if (!method_status->OnRequested(&rejected_cc)) { cntl->SetFailed(ELIMIT, "Rejected by %s's ConcurrencyLimiter, concurrency=%d", - sp->method->full_name().c_str(), rejected_cc); + mp->method->full_name().c_str(), rejected_cc); return; } } if (span) { - span->ResetServerSpanName(sp->method->full_name()); + span->ResetServerSpanName(mp->method->full_name()); } // NOTE: accesses to builtin services are not counted as part of // concurrency, therefore are not limited by ServerOptions.max_concurrency. - if (!sp->is_builtin_service && !sp->params.is_tabbed) { + if (!mp->is_builtin_service && !mp->params.is_tabbed) { if (socket->is_overcrowded() && !server->options().ignore_eovercrowded && - !sp->ignore_eovercrowded) { + !mp->ignore_eovercrowded) { cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded", butil::endpoint2str(socket->remote_side()).c_str()); return; @@ -1522,8 +1522,8 @@ void ProcessHttpRequest(InputMessageBase *msg) { return; } - google::protobuf::Service* svc = sp->service; - const google::protobuf::MethodDescriptor* method = sp->method; + google::protobuf::Service* svc = mp->service; + const google::protobuf::MethodDescriptor* method = mp->method; accessor.set_method(method); RpcPBMessages* messages = server->options().rpc_pb_message_factory->Get(*svc, *method);; resp_sender.set_messages(messages); @@ -1535,7 +1535,7 @@ void ProcessHttpRequest(InputMessageBase *msg) { cntl->SetFailed("Fail to new req or res"); return; } - if (sp->params.allow_http_body_to_pb && + if (mp->params.allow_http_body_to_pb && method->input_type()->field_count() > 0) { // A protobuf service. No matter if Content-type is set to // applcation/json or body is empty, we have to treat body as a json @@ -1604,10 +1604,10 @@ void ProcessHttpRequest(InputMessageBase *msg) { butil::IOBufAsZeroCopyInputStream wrapper(req_body); std::string err; json2pb::Json2PbOptions options; - options.base64_to_bytes = sp->params.pb_bytes_to_base64; - options.array_to_single_repeated = sp->params.pb_single_repeated_to_array; - cntl->set_pb_bytes_to_base64(sp->params.pb_bytes_to_base64); - cntl->set_pb_single_repeated_to_array(sp->params.pb_single_repeated_to_array); + options.base64_to_bytes = mp->params.pb_bytes_to_base64; + options.array_to_single_repeated = mp->params.pb_single_repeated_to_array; + cntl->set_pb_bytes_to_base64(mp->params.pb_bytes_to_base64); + cntl->set_pb_single_repeated_to_array(mp->params.pb_single_repeated_to_array); if (!json2pb::JsonToProtoMessage(&wrapper, req, options, &err)) { cntl->SetFailed(EREQUEST, "Fail to parse http body as %s, %s", req->GetDescriptor()->full_name().c_str(), err.c_str()); diff --git a/src/brpc/rdma/block_pool.cpp b/src/brpc/rdma/block_pool.cpp index 54e47da457..aef94150ba 100644 --- a/src/brpc/rdma/block_pool.cpp +++ b/src/brpc/rdma/block_pool.cpp @@ -46,8 +46,8 @@ static RegisterCallback g_cb = NULL; static const size_t BYTES_IN_MB = 1048576; static const int BLOCK_DEFAULT = 0; // 8KB -static const int BLOCK_LARGE = 1; // 64KB -static const int BLOCK_HUGE = 2; // 2MB +// static const int BLOCK_LARGE = 1; // 64KB +// static const int BLOCK_HUGE = 2; // 2MB static const int BLOCK_SIZE_COUNT = 3; static size_t g_block_size[BLOCK_SIZE_COUNT] = { 8192, 65536, 2 * BYTES_IN_MB }; diff --git a/src/brpc/rdma/rdma_endpoint.cpp b/src/brpc/rdma/rdma_endpoint.cpp index 4d83deacf7..2750b756d3 100644 --- a/src/brpc/rdma/rdma_endpoint.cpp +++ b/src/brpc/rdma/rdma_endpoint.cpp @@ -60,8 +60,6 @@ DEFINE_bool(rdma_trace_verbose, false, "Print log message verbosely"); BRPC_VALIDATE_GFLAG(rdma_trace_verbose, brpc::PassValidate); static const size_t IOBUF_BLOCK_HEADER_LEN = 32; // implementation-dependent -static const size_t IOBUF_BLOCK_DEFAULT_PAYLOAD = - butil::IOBuf::DEFAULT_BLOCK_SIZE - IOBUF_BLOCK_HEADER_LEN; // DO NOT change this value unless you know the safe value!!! // This is the number of reserved WRs in SQ/RQ for pure ACK. @@ -79,14 +77,14 @@ static const size_t RESERVED_WR_NUM = 3; static const char* MAGIC_STR = "RDMA"; static const size_t MAGIC_STR_LEN = 4; static const size_t HELLO_MSG_LEN_MIN = 40; -static const size_t HELLO_MSG_LEN_MAX = 4096; +// static const size_t HELLO_MSG_LEN_MAX = 4096; static const size_t ACK_MSG_LEN = 4; static uint16_t g_rdma_hello_msg_len = 40; // In Byte static uint16_t g_rdma_hello_version = 2; static uint16_t g_rdma_impl_version = 1; static uint32_t g_rdma_recv_block_size = 0; -static const uint32_t MAX_INLINE_DATA = 64; +// static const uint32_t MAX_INLINE_DATA = 64; static const uint8_t MAX_HOP_LIMIT = 16; static const uint8_t TIMEOUT = 14; static const uint8_t RETRY_CNT = 7; @@ -1021,7 +1019,7 @@ int RdmaEndpoint::PostRecv(uint32_t num, bool zerocopy) { PLOG(WARNING) << "Fail to allocate rbuf"; return -1; } else { - CHECK(size == g_rdma_recv_block_size) << size; + CHECK(static_cast(size) == g_rdma_recv_block_size) << size; } } if (DoPostRecv(_rbuf_data[_rq_received], g_rdma_recv_block_size) < 0) { diff --git a/src/brpc/rdma/rdma_helper.cpp b/src/brpc/rdma/rdma_helper.cpp index cf1cce9505..a64eba0aa7 100644 --- a/src/brpc/rdma/rdma_helper.cpp +++ b/src/brpc/rdma/rdma_helper.cpp @@ -94,7 +94,7 @@ DEFINE_string(rdma_device, "", "The name of the HCA device used " DEFINE_int32(rdma_port, 1, "The port number to use. For RoCE, it is always 1."); DEFINE_int32(rdma_gid_index, -1, "The GID index to use. -1 means using the last one."); -static const size_t SYSFS_SIZE = 4096; +// static const size_t SYSFS_SIZE = 4096; static ibv_device** g_devices = NULL; static ibv_context* g_context = NULL; static SocketId g_async_socket; diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h index 881b5cf77d..e31c941968 100644 --- a/src/brpc/thrift_message.h +++ b/src/brpc/thrift_message.h @@ -81,7 +81,7 @@ friend class ThriftStub; void Swap(ThriftFramedMessage* other); // implements Message ---------------------------------------------- - void MergeFrom(const ThriftFramedMessage& from); + void MergeFrom(const ThriftFramedMessage& from) override; void Clear() override; size_t ByteSizeLong() const override; diff --git a/src/bthread/task_group.cpp b/src/bthread/task_group.cpp index 170b273043..7d18a70cf9 100644 --- a/src/bthread/task_group.cpp +++ b/src/bthread/task_group.cpp @@ -999,7 +999,7 @@ void print_task(std::ostream& os, bthread_t tid) { bthread_attr_t attr = BTHREAD_ATTR_NORMAL; bool has_tls = false; int64_t cpuwide_start_ns = 0; - TaskStatistics stat = {0, 0}; + TaskStatistics stat = {0, 0, 0}; TaskStatus status = TASK_STATUS_UNKNOWN; bool traced = false; pid_t worker_tid = 0; diff --git a/src/butil/logging.h b/src/butil/logging.h index a26ff1e13c..58e369189b 100644 --- a/src/butil/logging.h +++ b/src/butil/logging.h @@ -53,23 +53,23 @@ # define DPLOG_IF(...) DLOG_IF(__VA_ARGS__) # define DPCHECK(...) DCHECK(__VA_ARGS__) # define DVPLOG(...) DVLOG(__VA_ARGS__) -# endif +# endif // DCHECK_IS_ON() #ifndef LOG_BACKTRACE_IF #define LOG_BACKTRACE_IF(severity, condition) LOG_IF(severity, condition) -#endif +#endif // LOG_BACKTRACE_IF #ifndef LOG_BACKTRACE_IF_ONCE #define LOG_BACKTRACE_IF_ONCE(severity, condition) LOG_IF_ONCE(severity, condition) -#endif +#endif // LOG_BACKTRACE_IF_ONCE #ifndef LOG_BACKTRACE_FIRST_N #define LOG_BACKTRACE_FIRST_N(severity, N) LOG_FIRST_N(severity, N) -#endif +#endif // LOG_BACKTRACE_FIRST_N #ifndef LOG_BACKTRACE_IF_FIRST_N #define LOG_BACKTRACE_IF_FIRST_N(severity, condition, N) LOG_IF_FIRST_N(severity, condition, N) -#endif +#endif // LOG_BACKTRACE_IF_FIRST_N #define LOG_AT(severity, file, line) \ @@ -485,8 +485,10 @@ void print_vlog_sites(VLogSitePrinter*); BAIDU_LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity)) #define LOG_IF(severity, condition) \ BAIDU_LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) +#ifndef LOG_BACKTRACE_IF #define LOG_BACKTRACE_IF(severity, condition) \ BAIDU_LAZY_STREAM(LOG_STREAM(severity).SetBacktrace(), LOG_IS_ON(severity) && (condition)) +#endif // LOG_BACKTRACE_IF // FIXME(gejun): Should always crash. #define LOG_ASSERT(condition) \ @@ -1185,7 +1187,7 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { // Select default policy: LOG(ERROR) #define NOTIMPLEMENTED_POLICY 4 #endif -#endif +#endif // NOTIMPLEMENTED_POLICY #if defined(COMPILER_GCC) // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name @@ -1259,9 +1261,11 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { # define LOG_ONCE(severity) LOG_FIRST_N(severity, 1) # define LOG_BACKTRACE_ONCE(severity) LOG_BACKTRACE_FIRST_N(severity, 1) # define LOG_IF_ONCE(severity, condition) LOG_IF_FIRST_N(severity, condition, 1) +#ifndef LOG_BACKTRACE_IF_ONCE # define LOG_BACKTRACE_IF_ONCE(severity, condition) \ LOG_BACKTRACE_IF_FIRST_N(severity, condition, 1) -#endif +#endif // LOG_BACKTRACE_IF_ONCE +#endif // LOG_ONCE // Print a log after every N calls. First call always prints. // Each call to this macro has a cost of relaxed atomic increment. @@ -1271,7 +1275,7 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { BAIDU_LOG_IF_EVERY_N_IMPL(LOG_IF, severity, true, N) # define LOG_IF_EVERY_N(severity, condition, N) \ BAIDU_LOG_IF_EVERY_N_IMPL(LOG_IF, severity, condition, N) -#endif +#endif // LOG_EVERY_N // Print logs for first N calls. // Almost zero overhead when the log was printed for N times @@ -1279,13 +1283,17 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { #ifndef LOG_FIRST_N # define LOG_FIRST_N(severity, N) \ BAIDU_LOG_IF_FIRST_N_IMPL(LOG_IF, severity, true, N) +#ifndef LOG_BACKTRACE_FIRST_N # define LOG_BACKTRACE_FIRST_N(severity, N) \ BAIDU_LOG_IF_FIRST_N_IMPL(LOG_BACKTRACE_IF, severity, true, N) +#endif // LOG_BACKTRACE_FIRST_N # define LOG_IF_FIRST_N(severity, condition, N) \ BAIDU_LOG_IF_FIRST_N_IMPL(LOG_IF, severity, condition, N) +#ifndef LOG_BACKTRACE_IF_FIRST_N # define LOG_BACKTRACE_IF_FIRST_N(severity, condition, N) \ BAIDU_LOG_IF_FIRST_N_IMPL(LOG_BACKTRACE_IF, severity, condition, N) -#endif +#endif // LOG_BACKTRACE_IF_FIRST_N +#endif // LOG_FIRST_N // Print a log every second. (not present in glog). First call always prints. // Each call to this macro has a cost of calling gettimeofday. @@ -1294,33 +1302,33 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { BAIDU_LOG_IF_EVERY_SECOND_IMPL(LOG_IF, severity, true) # define LOG_IF_EVERY_SECOND(severity, condition) \ BAIDU_LOG_IF_EVERY_SECOND_IMPL(LOG_IF, severity, condition) -#endif +#endif // LOG_EVERY_SECOND #ifndef PLOG_EVERY_N # define PLOG_EVERY_N(severity, N) \ BAIDU_LOG_IF_EVERY_N_IMPL(PLOG_IF, severity, true, N) # define PLOG_IF_EVERY_N(severity, condition, N) \ BAIDU_LOG_IF_EVERY_N_IMPL(PLOG_IF, severity, condition, N) -#endif +#endif // PLOG_EVERY_N #ifndef PLOG_FIRST_N # define PLOG_FIRST_N(severity, N) \ BAIDU_LOG_IF_FIRST_N_IMPL(PLOG_IF, severity, true, N) # define PLOG_IF_FIRST_N(severity, condition, N) \ BAIDU_LOG_IF_FIRST_N_IMPL(PLOG_IF, severity, condition, N) -#endif +#endif // PLOG_FIRST_N #ifndef PLOG_ONCE # define PLOG_ONCE(severity) PLOG_FIRST_N(severity, 1) # define PLOG_IF_ONCE(severity, condition) PLOG_IF_FIRST_N(severity, condition, 1) -#endif +#endif // PLOG_ONCE #ifndef PLOG_EVERY_SECOND # define PLOG_EVERY_SECOND(severity) \ BAIDU_LOG_IF_EVERY_SECOND_IMPL(PLOG_IF, severity, true) # define PLOG_IF_EVERY_SECOND(severity, condition) \ BAIDU_LOG_IF_EVERY_SECOND_IMPL(PLOG_IF, severity, condition) -#endif +#endif // PLOG_EVERY_SECOND // DEBUG_MODE is for uses like // if (DEBUG_MODE) foo.CheckThatFoo(); From 6e0d1b39545789cfbf8cf2ed5cbbeeb2784db560 Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Sat, 18 Jan 2025 14:14:20 +0800 Subject: [PATCH 3/6] Release 1.12.0 (#2875) --- CMakeLists.txt | 2 +- MODULE.bazel | 2 +- NOTICE | 2 +- RELEASE_VERSION | 2 +- package/rpm/brpc.spec | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6b7716b29..284f27fe10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) endif() -set(BRPC_VERSION 1.11.0) +set(BRPC_VERSION 1.12.0) SET(CPACK_GENERATOR "DEB") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "brpc authors") diff --git a/MODULE.bazel b/MODULE.bazel index e53146aefb..e041b67a03 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = 'brpc', - version = '1.11.0', + version = '1.12.0', compatibility_level = 1, ) diff --git a/NOTICE b/NOTICE index 9939c15699..55a2c50bd0 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ Apache bRPC -Copyright 2018-2024 The Apache Software Foundation +Copyright 2018-2025 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/RELEASE_VERSION b/RELEASE_VERSION index 1cac385c6c..0eed1a29ef 100644 --- a/RELEASE_VERSION +++ b/RELEASE_VERSION @@ -1 +1 @@ -1.11.0 +1.12.0 diff --git a/package/rpm/brpc.spec b/package/rpm/brpc.spec index f70daf1873..4348347426 100644 --- a/package/rpm/brpc.spec +++ b/package/rpm/brpc.spec @@ -18,7 +18,7 @@ # Name: brpc -Version: 1.11.0 +Version: 1.12.0 Release: 1%{?dist} Summary: Industrial-grade RPC framework using C++ Language. From c93d0e06f50182bf41d973cad6f8714f4b1d021e Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Sat, 18 Jan 2025 17:49:51 +0800 Subject: [PATCH 4/6] Fix gflag namespace (#2877) --- BUILD.bazel | 1 - config_brpc.sh | 11 +--- src/brpc/builtin/flags_service.cpp | 24 ++++----- src/brpc/builtin/rpcz_service.cpp | 4 +- src/brpc/rpc_dump.cpp | 2 +- src/bthread/bthread.cpp | 40 ++++++--------- src/bthread/task_group.cpp | 14 ++---- src/butil/logging.cc | 28 +++-------- src/butil/reloadable_flags.h | 18 ++++--- src/bvar/gflag.cpp | 12 ++--- src/bvar/latency_recorder.cpp | 20 ++++---- src/bvar/mvariable.cpp | 20 ++++---- src/bvar/variable.cpp | 53 +++++++++----------- test/BUILD.bazel | 1 - test/CMakeLists.txt | 2 +- test/brpc_alpn_protocol_unittest.cpp | 2 +- test/brpc_block_pool_unittest.cpp | 2 +- test/brpc_channel_unittest.cpp | 2 +- test/brpc_circuit_breaker_unittest.cpp | 2 +- test/brpc_coroutine_unittest.cpp | 2 +- test/brpc_esp_protocol_unittest.cpp | 2 +- test/brpc_grpc_protocol_unittest.cpp | 6 +-- test/brpc_http_message_unittest.cpp | 4 +- test/brpc_http_rpc_protocol_unittest.cpp | 6 +-- test/brpc_hulu_pbrpc_protocol_unittest.cpp | 2 +- test/brpc_interceptor_unittest.cpp | 2 +- test/brpc_load_balancer_unittest.cpp | 8 +-- test/brpc_mongo_protocol_unittest.cpp | 2 +- test/brpc_public_pbrpc_protocol_unittest.cpp | 2 +- test/brpc_rdma_unittest.cpp | 2 +- test/brpc_rtmp_unittest.cpp | 2 +- test/brpc_server_unittest.cpp | 2 +- test/brpc_socket_unittest.cpp | 10 ++-- test/brpc_sofa_pbrpc_protocol_unittest.cpp | 2 +- test/brpc_ssl_unittest.cpp | 2 +- test/bthread_butex_multi_tag_unittest.cpp | 2 +- test/bthread_key_unittest.cpp | 2 +- test/bthread_setconcurrency_unittest.cpp | 8 +-- test/bthread_unittest.cpp | 2 +- test/butil_unittest_main.cpp | 6 +-- test/bvar_file_dumper_unittest.cpp | 4 +- test/bvar_multi_dimension_unittest.cpp | 32 ++++++------ test/bvar_mvariable_unittest.cpp | 24 ++++----- test/bvar_variable_unittest.cpp | 2 +- test/logging_unittest.cc | 30 +++++------ 45 files changed, 189 insertions(+), 237 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 0e2e66edd2..84ae6bd775 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -29,7 +29,6 @@ COPTS = [ "-D__STDC_FORMAT_MACROS", "-D__STDC_LIMIT_MACROS", "-D__STDC_CONSTANT_MACROS", - "-DGFLAGS_NS=google", ] + select({ "//bazel/config:brpc_with_glog": ["-DBRPC_WITH_GLOG=1"], "//conditions:default": ["-DBRPC_WITH_GLOG=0"], diff --git a/config_brpc.sh b/config_brpc.sh index afc84a7d68..25f506fe04 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -261,15 +261,6 @@ fi PROTOC=$(find_bin_or_die protoc) GFLAGS_HDR=$(find_dir_of_header_or_die gflags/gflags.h) -# namespace of gflags may not be google, grep it from source. -GFLAGS_NS=$(grep "namespace [_A-Za-z0-9]\+ {" $GFLAGS_HDR/gflags/gflags_declare.h | head -1 | awk '{print $2}') -if [ "$GFLAGS_NS" = "GFLAGS_NAMESPACE" ]; then - GFLAGS_NS=$(grep "#define GFLAGS_NAMESPACE [_A-Za-z0-9]\+" $GFLAGS_HDR/gflags/gflags_declare.h | head -1 | awk '{print $3}') -fi -if [ -z "$GFLAGS_NS" ]; then - >&2 $ECHO "Fail to grep namespace of gflags source $GFLAGS_HDR/gflags/gflags_declare.h" - exit 1 -fi PROTOBUF_HDR=$(find_dir_of_header_or_die google/protobuf/message.h) PROTOBUF_VERSION=$(grep '#define GOOGLE_PROTOBUF_VERSION [0-9]\+' $PROTOBUF_HDR/google/protobuf/stubs/common.h | awk '{print $3}') @@ -434,7 +425,7 @@ append_to_output "STATIC_LINKINGS=$STATIC_LINKINGS" append_to_output "DYNAMIC_LINKINGS=$DYNAMIC_LINKINGS" # CPP means C PreProcessing, not C PlusPlus -CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS -DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=$BRPC_DEBUG_BTHREAD_SCHE_SAFETY -DBRPC_DEBUG_LOCK=$BRPC_DEBUG_LOCK" +CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_GLOG=$WITH_GLOG -DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=$BRPC_DEBUG_BTHREAD_SCHE_SAFETY -DBRPC_DEBUG_LOCK=$BRPC_DEBUG_LOCK" # Avoid over-optimizations of TLS variables by GCC>=4.8 # See: https://github.com/apache/brpc/issues/1693 diff --git a/src/brpc/builtin/flags_service.cpp b/src/brpc/builtin/flags_service.cpp index 27ad5bc48b..1c9075c54e 100644 --- a/src/brpc/builtin/flags_service.cpp +++ b/src/brpc/builtin/flags_service.cpp @@ -63,7 +63,7 @@ static std::string HtmlReplace(const std::string& s) { } } -static void PrintFlag(std::ostream& os, const GFLAGS_NS::CommandLineFlagInfo& flag, +static void PrintFlag(std::ostream& os, const GFLAGS_NAMESPACE::CommandLineFlagInfo& flag, bool use_html) { if (use_html) { os << ""; @@ -108,8 +108,8 @@ void FlagsService::set_value_page(Controller* cntl, ::google::protobuf::Closure* done) { ClosureGuard done_guard(done); const std::string& name = cntl->http_request().unresolved_path(); - GFLAGS_NS::CommandLineFlagInfo info; - if (!GFLAGS_NS::GetCommandLineFlagInfo(name.c_str(), &info)) { + GFLAGS_NAMESPACE::CommandLineFlagInfo info; + if (!GFLAGS_NAMESPACE::GetCommandLineFlagInfo(name.c_str(), &info)) { cntl->SetFailed(ENOMETHOD, "No such gflag"); return; } @@ -155,8 +155,8 @@ void FlagsService::default_method(::google::protobuf::RpcController* cntl_base, if (use_html && cntl->http_request().uri().GetQuery("withform")) { return set_value_page(cntl, done_guard.release()); } - GFLAGS_NS::CommandLineFlagInfo info; - if (!GFLAGS_NS::GetCommandLineFlagInfo(constraint.c_str(), &info)) { + GFLAGS_NAMESPACE::CommandLineFlagInfo info; + if (!GFLAGS_NAMESPACE::GetCommandLineFlagInfo(constraint.c_str(), &info)) { cntl->SetFailed(ENOMETHOD, "No such gflag"); return; } @@ -169,8 +169,8 @@ void FlagsService::default_method(::google::protobuf::RpcController* cntl_base, constraint.c_str()); return; } - if (GFLAGS_NS::SetCommandLineOption(constraint.c_str(), - value_str->c_str()).empty()) { + if (GFLAGS_NAMESPACE::SetCommandLineOption(constraint.c_str(), + value_str->c_str()).empty()) { cntl->SetFailed(EPERM, "Fail to set `%s' to %s", constraint.c_str(), (value_str->empty() ? "empty string" : value_str->c_str())); @@ -218,8 +218,8 @@ void FlagsService::default_method(::google::protobuf::RpcController* cntl_base, // Only exact names. We don't have to iterate all flags in this case. for (std::set::iterator it = exact.begin(); it != exact.end(); ++it) { - GFLAGS_NS::CommandLineFlagInfo info; - if (GFLAGS_NS::GetCommandLineFlagInfo(it->c_str(), &info)) { + GFLAGS_NAMESPACE::CommandLineFlagInfo info; + if (GFLAGS_NAMESPACE::GetCommandLineFlagInfo(it->c_str(), &info)) { PrintFlag(os, info, use_html); os << '\n'; } @@ -227,10 +227,10 @@ void FlagsService::default_method(::google::protobuf::RpcController* cntl_base, } else { // Iterate all flags and filter. - std::vector flag_list; + std::vector flag_list; flag_list.reserve(128); - GFLAGS_NS::GetAllFlags(&flag_list); - for (std::vector::iterator + GFLAGS_NAMESPACE::GetAllFlags(&flag_list); + for (std::vector::iterator it = flag_list.begin(); it != flag_list.end(); ++it) { if (!constraint.empty() && exact.find(it->name) == exact.end() && diff --git a/src/brpc/builtin/rpcz_service.cpp b/src/brpc/builtin/rpcz_service.cpp index b9e056376a..d9121eb555 100644 --- a/src/brpc/builtin/rpcz_service.cpp +++ b/src/brpc/builtin/rpcz_service.cpp @@ -65,7 +65,7 @@ void RpczService::enable(::google::protobuf::RpcController* cntl_base, const bool use_html = UseHTML(cntl->http_request()); cntl->http_response().set_content_type( use_html ? "text/html" : "text/plain"); - if (!GFLAGS_NS::SetCommandLineOption("enable_rpcz", "true").empty()) { + if (!GFLAGS_NAMESPACE::SetCommandLineOption("enable_rpcz", "true").empty()) { if (use_html) { // Redirect to /rpcz cntl->response_attachment().append( @@ -94,7 +94,7 @@ void RpczService::disable(::google::protobuf::RpcController* cntl_base, const bool use_html = UseHTML(cntl->http_request()); cntl->http_response().set_content_type( use_html ? "text/html" : "text/plain"); - if (!GFLAGS_NS::SetCommandLineOption("enable_rpcz", "false").empty()) { + if (!GFLAGS_NAMESPACE::SetCommandLineOption("enable_rpcz", "false").empty()) { if (use_html) { // Redirect to /rpcz cntl->response_attachment().append( diff --git a/src/brpc/rpc_dump.cpp b/src/brpc/rpc_dump.cpp index bf3d7fc8e9..4686713cd2 100644 --- a/src/brpc/rpc_dump.cpp +++ b/src/brpc/rpc_dump.cpp @@ -139,7 +139,7 @@ void SampledRequest::destroy() { // Save gflags which could be reloaded at anytime. void RpcDumpContext::SaveFlags() { std::string dir; - CHECK(GFLAGS_NS::GetCommandLineOption("rpc_dump_dir", &dir)); + CHECK(GFLAGS_NAMESPACE::GetCommandLineOption("rpc_dump_dir", &dir)); const size_t pos = dir.find(""); if (pos != std::string::npos) { diff --git a/src/bthread/bthread.cpp b/src/bthread/bthread.cpp index 3de7265705..e124f4bc6f 100644 --- a/src/bthread/bthread.cpp +++ b/src/bthread/bthread.cpp @@ -24,6 +24,7 @@ #include "butil/macros.h" // BAIDU_CASSERT #include "butil/logging.h" #include "butil/thread_local.h" +#include "butil/reloadable_flags.h" #include "bthread/task_group.h" // TaskGroup #include "bthread/task_control.h" // TaskControl #include "bthread/timer_thread.h" @@ -32,47 +33,34 @@ namespace bthread { +static bool validate_bthread_concurrency(const char*, int32_t val) { + // bthread_setconcurrency sets the flag on success path which should + // not be strictly in a validator. But it's OK for a int flag. + return bthread_setconcurrency(val) == 0; +} +static bool validate_bthread_min_concurrency(const char*, int32_t val); +static bool validate_bthread_current_tag(const char*, int32_t val); +static bool validate_bthread_concurrency_by_tag(const char*, int32_t val); + DEFINE_int32(bthread_concurrency, 8 + BTHREAD_EPOLL_THREAD_NUM, "Number of pthread workers"); +BUTIL_VALIDATE_GFLAG(bthread_concurrency, validate_bthread_concurrency); DEFINE_int32(bthread_min_concurrency, 0, "Initial number of pthread workers which will be added on-demand." " The laziness is disabled when this value is non-positive," " and workers will be created eagerly according to -bthread_concurrency and bthread_setconcurrency(). "); +BUTIL_VALIDATE_GFLAG(bthread_min_concurrency, validate_bthread_min_concurrency); DEFINE_int32(bthread_current_tag, BTHREAD_TAG_INVALID, "Set bthread concurrency for this tag"); +BUTIL_VALIDATE_GFLAG(bthread_current_tag, validate_bthread_current_tag); DEFINE_int32(bthread_concurrency_by_tag, 8 + BTHREAD_EPOLL_THREAD_NUM, "Number of pthread workers of FLAGS_bthread_current_tag"); +BUTIL_VALIDATE_GFLAG(bthread_concurrency_by_tag, validate_bthread_concurrency_by_tag); static bool never_set_bthread_concurrency = true; -static bool validate_bthread_concurrency(const char*, int32_t val) { - // bthread_setconcurrency sets the flag on success path which should - // not be strictly in a validator. But it's OK for a int flag. - return bthread_setconcurrency(val) == 0; -} -const int ALLOW_UNUSED register_FLAGS_bthread_concurrency = - ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_bthread_concurrency, - validate_bthread_concurrency); - -static bool validate_bthread_min_concurrency(const char*, int32_t val); - -const int ALLOW_UNUSED register_FLAGS_bthread_min_concurrency = - ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_bthread_min_concurrency, - validate_bthread_min_concurrency); - -static bool validate_bthread_current_tag(const char*, int32_t val); - -const int ALLOW_UNUSED register_FLAGS_bthread_current_tag = - ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_bthread_current_tag, validate_bthread_current_tag); - -static bool validate_bthread_concurrency_by_tag(const char*, int32_t val); - -const int ALLOW_UNUSED register_FLAGS_bthread_concurrency_by_tag = - ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_bthread_concurrency_by_tag, - validate_bthread_concurrency_by_tag); - BAIDU_CASSERT(sizeof(TaskControl*) == sizeof(butil::atomic), atomic_size_match); pthread_mutex_t g_task_control_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/bthread/task_group.cpp b/src/bthread/task_group.cpp index 7d18a70cf9..361efa5936 100644 --- a/src/bthread/task_group.cpp +++ b/src/bthread/task_group.cpp @@ -28,6 +28,7 @@ #include "butil/fast_rand.h" #include "butil/unique_ptr.h" #include "butil/third_party/murmurhash3/murmurhash3.h" // fmix64 +#include "butil/reloadable_flags.h" #include "bthread/errno.h" // ESTOP #include "bthread/butex.h" // butex_* #include "bthread/sys_futex.h" // futex_wake_private @@ -41,24 +42,17 @@ namespace bthread { static const bthread_attr_t BTHREAD_ATTR_TASKGROUP = { BTHREAD_STACKTYPE_UNKNOWN, 0, NULL, BTHREAD_TAG_INVALID }; -static bool pass_bool(const char*, bool) { return true; } - DEFINE_bool(show_bthread_creation_in_vars, false, "When this flags is on, The time " "from bthread creation to first run will be recorded and shown in /vars"); -const bool ALLOW_UNUSED dummy_show_bthread_creation_in_vars = - ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_show_bthread_creation_in_vars, - pass_bool); +BUTIL_VALIDATE_GFLAG(show_bthread_creation_in_vars, butil::PassValidate); DEFINE_bool(show_per_worker_usage_in_vars, false, "Show per-worker usage in /vars/bthread_per_worker_usage_"); -const bool ALLOW_UNUSED dummy_show_per_worker_usage_in_vars = - ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_show_per_worker_usage_in_vars, - pass_bool); +BUTIL_VALIDATE_GFLAG(show_per_worker_usage_in_vars, butil::PassValidate); DEFINE_bool(bthread_enable_cpu_clock_stat, false, "Enable CPU clock statistics for bthread"); -const bool ALLOW_UNUSED dummy_bthread_enable_cpu_clock_stat = ::GFLAGS_NS::RegisterFlagValidator(&FLAGS_bthread_enable_cpu_clock_stat, - pass_bool); +BUTIL_VALIDATE_GFLAG(bthread_enable_cpu_clock_stat, butil::PassValidate); BAIDU_VOLATILE_THREAD_LOCAL(TaskGroup*, tls_task_group, NULL); // Sync with TaskMeta::local_storage when a bthread is created or destroyed. diff --git a/src/butil/logging.cc b/src/butil/logging.cc index 9f2246092c..a15251b2db 100644 --- a/src/butil/logging.cc +++ b/src/butil/logging.cc @@ -102,6 +102,7 @@ typedef pthread_mutex_t* MutexHandle; #include "butil/containers/doubly_buffered_data.h" #include "butil/memory/singleton.h" #include "butil/endpoint.h" +#include "butil/reloadable_flags.h" #ifdef BAIDU_INTERNAL #include "butil/comlog_sink.h" #endif @@ -122,8 +123,11 @@ namespace logging { DEFINE_bool(crash_on_fatal_log, false, "Crash process when a FATAL log is printed"); +BUTIL_VALIDATE_GFLAG(crash_on_fatal_log, butil::PassValidate); + DEFINE_bool(print_stack_on_check, true, "Print the stack trace when a CHECK was failed"); +BUTIL_VALIDATE_GFLAG(print_stack_on_check, butil::PassValidate); DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this." " Overridable by --vmodule."); @@ -140,6 +144,7 @@ DEFINE_bool(log_bid, true, "Log bthread id"); DEFINE_int32(minloglevel, 0, "Any log at or above this level will be " "displayed. Anything below this level will be silently ignored. " "0=INFO 1=NOTICE 2=WARNING 3=ERROR 4=FATAL"); +BUTIL_VALIDATE_GFLAG(minloglevel, butil::NonNegativeInteger); DEFINE_bool(log_hostname, false, "Add host after pid in each log so" " that we know where logs came from when using aggregation tools" @@ -1930,7 +1935,7 @@ static bool validate_vmodule(const char*, const std::string& vmodule) { return on_reset_vmodule(vmodule.c_str()) == 0; } -const bool ALLOW_UNUSED validate_vmodule_dummy = GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED validate_vmodule_dummy = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_vmodule, &validate_vmodule); // [Thread-safe] Reset FLAGS_v. @@ -1959,26 +1964,7 @@ static bool validate_v(const char*, int32_t v) { on_reset_verbose(v); return true; } - -const bool ALLOW_UNUSED validate_v_dummy = GFLAGS_NS::RegisterFlagValidator( - &FLAGS_v, &validate_v); - -static bool PassValidate(const char*, bool) { - return true; -} - -const bool ALLOW_UNUSED validate_crash_on_fatal_log = - GFLAGS_NS::RegisterFlagValidator(&FLAGS_crash_on_fatal_log, PassValidate); - -const bool ALLOW_UNUSED validate_print_stack_on_check = - GFLAGS_NS::RegisterFlagValidator(&FLAGS_print_stack_on_check, PassValidate); - -static bool NonNegativeInteger(const char*, int32_t v) { - return v >= 0; -} - -const bool ALLOW_UNUSED validate_min_log_level = GFLAGS_NS::RegisterFlagValidator( - &FLAGS_minloglevel, NonNegativeInteger); +BUTIL_VALIDATE_GFLAG(v, validate_v); } // namespace logging diff --git a/src/butil/reloadable_flags.h b/src/butil/reloadable_flags.h index 2cb11e9253..15a9f98d61 100644 --- a/src/butil/reloadable_flags.h +++ b/src/butil/reloadable_flags.h @@ -34,12 +34,11 @@ // // This macro does not work for string-flags because they're thread-unsafe to // modify directly. To emphasize this, you have to write the validator by -// yourself and use GFLAGS_NS::GetCommandLineOption() to acess the flag. -#define BUTIL_VALIDATE_GFLAG(flag, validate_fn) \ - namespace butil_flags {} \ - const int register_FLAGS_ ## flag ## _dummy \ - __attribute__((__unused__)) = \ - ::butil::RegisterFlagValidatorOrDieImpl< \ +// yourself and use GFLAGS_NAMESPACE::GetCommandLineOption() to acess the flag. +#define BUTIL_VALIDATE_GFLAG(flag, validate_fn) \ + namespace butil_flags {} \ + const int ALLOW_UNUSED register_FLAGS_ ## flag ## _dummy = \ + ::butil::RegisterFlagValidatorOrDieImpl< \ decltype(FLAGS_##flag)>(&FLAGS_##flag, (validate_fn)) @@ -55,12 +54,17 @@ bool PositiveInteger(const char*, T v) { return v > 0; } +template +bool NonNegativeInteger(const char*, T v) { + return v >= 0; +} + template bool RegisterFlagValidatorOrDieImpl( const T* flag, bool (*validate_fn)(const char*, T val)) { static_assert(!butil::is_same::value, "Not support string flags"); - if (GFLAGS_NS::RegisterFlagValidator(flag, validate_fn)) { + if (::GFLAGS_NAMESPACE::RegisterFlagValidator(flag, validate_fn)) { return true; } // Error printed by gflags does not have newline. Add one to it. diff --git a/src/bvar/gflag.cpp b/src/bvar/gflag.cpp index a4d11f8af2..5525795cc7 100644 --- a/src/bvar/gflag.cpp +++ b/src/bvar/gflag.cpp @@ -34,8 +34,8 @@ GFlag::GFlag(const butil::StringPiece& prefix, } void GFlag::describe(std::ostream& os, bool quote_string) const { - GFLAGS_NS::CommandLineFlagInfo info; - if (!GFLAGS_NS::GetCommandLineFlagInfo(gflag_name().c_str(), &info)) { + GFLAGS_NAMESPACE::CommandLineFlagInfo info; + if (!GFLAGS_NAMESPACE::GetCommandLineFlagInfo(gflag_name().c_str(), &info)) { if (quote_string) { os << '"'; } @@ -54,8 +54,8 @@ void GFlag::describe(std::ostream& os, bool quote_string) const { #ifdef BAIDU_INTERNAL void GFlag::get_value(boost::any* value) const { - GFLAGS_NS::CommandLineFlagInfo info; - if (!GFLAGS_NS::GetCommandLineFlagInfo(gflag_name().c_str(), &info)) { + GFLAGS_NAMESPACE::CommandLineFlagInfo info; + if (!GFLAGS_NAMESPACE::GetCommandLineFlagInfo(gflag_name().c_str(), &info)) { *value = "Unknown gflag=" + gflag_name(); } else if (info.type == "string") { *value = info.current_value; @@ -78,14 +78,14 @@ void GFlag::get_value(boost::any* value) const { std::string GFlag::get_value() const { std::string str; - if (!GFLAGS_NS::GetCommandLineOption(gflag_name().c_str(), &str)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption(gflag_name().c_str(), &str)) { return "Unknown gflag=" + gflag_name(); } return str; } bool GFlag::set_value(const char* value) { - return !GFLAGS_NS::SetCommandLineOption(gflag_name().c_str(), value).empty(); + return !GFLAGS_NAMESPACE::SetCommandLineOption(gflag_name().c_str(), value).empty(); } } // namespace bvar diff --git a/src/bvar/latency_recorder.cpp b/src/bvar/latency_recorder.cpp index 791bc62693..b4ba0c442e 100644 --- a/src/bvar/latency_recorder.cpp +++ b/src/bvar/latency_recorder.cpp @@ -19,25 +19,25 @@ #include #include "butil/unique_ptr.h" +#include "butil/reloadable_flags.h" #include "bvar/latency_recorder.h" namespace bvar { +static bool valid_percentile(const char*, int32_t v) { + return v > 0 && v < 100; +} + // Reloading following gflags does not change names of the corresponding bvars. // Avoid reloading in practice. DEFINE_int32(bvar_latency_p1, 80, "First latency percentile"); +BUTIL_VALIDATE_GFLAG(bvar_latency_p1, valid_percentile); + DEFINE_int32(bvar_latency_p2, 90, "Second latency percentile"); -DEFINE_int32(bvar_latency_p3, 99, "Third latency percentile"); +BUTIL_VALIDATE_GFLAG(bvar_latency_p2, valid_percentile); -static bool valid_percentile(const char*, int32_t v) { - return v > 0 && v < 100; -} -const bool ALLOW_UNUSED dummy_bvar_latency_p1 = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_latency_p1, valid_percentile); -const bool ALLOW_UNUSED dummy_bvar_latency_p2 = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_latency_p2, valid_percentile); -const bool ALLOW_UNUSED dummy_bvar_latency_p3 = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_latency_p3, valid_percentile); +DEFINE_int32(bvar_latency_p3, 99, "Third latency percentile"); +BUTIL_VALIDATE_GFLAG(bvar_latency_p3, valid_percentile); namespace detail { diff --git a/src/bvar/mvariable.cpp b/src/bvar/mvariable.cpp index 033de7faef..86eadf1333 100644 --- a/src/bvar/mvariable.cpp +++ b/src/bvar/mvariable.cpp @@ -24,6 +24,7 @@ #include "butil/containers/flat_map.h" // butil::FlatMap #include "butil/scoped_lock.h" // BAIDU_SCOPE_LOCK #include "butil/file_util.h" // butil::FilePath +#include "butil/reloadable_flags.h" #include "bvar/variable.h" #include "bvar/mvariable.h" @@ -35,10 +36,6 @@ DECLARE_bool(bvar_abort_on_same_name); extern bool s_bvar_may_abort; -DEFINE_int32(bvar_max_multi_dimension_metric_number, 1024, "Max number of multi dimension"); -DEFINE_int32(bvar_max_dump_multi_dimension_metric_number, 1024, - "Max number of multi dimension metric number to dump by prometheus rpc service"); - static bool validator_bvar_max_multi_dimension_metric_number(const char*, int32_t v) { if (v < 1) { LOG(ERROR) << "Invalid bvar_max_multi_dimension_metric_number=" << v; @@ -47,6 +44,10 @@ static bool validator_bvar_max_multi_dimension_metric_number(const char*, int32_ return true; } +DEFINE_int32(bvar_max_multi_dimension_metric_number, 1024, "Max number of multi dimension"); +BUTIL_VALIDATE_GFLAG(bvar_max_multi_dimension_metric_number, + validator_bvar_max_multi_dimension_metric_number); + static bool validator_bvar_max_dump_multi_dimension_metric_number(const char*, int32_t v) { if (v < 0) { LOG(ERROR) << "Invalid bvar_max_dump_multi_dimension_metric_number=" << v; @@ -54,13 +55,10 @@ static bool validator_bvar_max_dump_multi_dimension_metric_number(const char*, i } return true; } - - -const bool ALLOW_UNUSED dummp_bvar_max_multi_dimension_metric_number = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_max_multi_dimension_metric_number, validator_bvar_max_multi_dimension_metric_number); - -const bool ALLOW_UNUSED dummp_bvar_max_dump_multi_dimension_metric_number = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_max_dump_multi_dimension_metric_number, validator_bvar_max_dump_multi_dimension_metric_number); +DEFINE_int32(bvar_max_dump_multi_dimension_metric_number, 1024, + "Max number of multi dimension metric number to dump by prometheus rpc service"); +BUTIL_VALIDATE_GFLAG(bvar_max_dump_multi_dimension_metric_number, + validator_bvar_max_dump_multi_dimension_metric_number); class MVarEntry { public: diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index e4f093555e..0b1e20d9e2 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -30,6 +30,7 @@ #include "butil/time.h" // milliseconds_from_now #include "butil/file_util.h" // butil::FilePath #include "butil/threading/platform_thread.h" +#include "butil/reloadable_flags.h" #include "bvar/gflag.h" #include "bvar/variable.h" #include "bvar/mvariable.h" @@ -43,21 +44,20 @@ DEFINE_bool(save_series, true, DEFINE_bool(quote_vector, true, "Quote description of Vector<> to make it valid to noah"); -DEFINE_bool(bvar_abort_on_same_name, false, - "Abort when names of bvar are same"); // Remember abort request before bvar_abort_on_same_name is initialized. bool s_bvar_may_abort = false; static bool validate_bvar_abort_on_same_name(const char*, bool v) { RELEASE_ASSERT_VERBOSE(!v || !s_bvar_may_abort, "Abort due to name conflict"); return true; } -const bool ALLOW_UNUSED dummy_bvar_abort_on_same_name = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_abort_on_same_name, validate_bvar_abort_on_same_name); +DEFINE_bool(bvar_abort_on_same_name, false, "Abort when names of bvar are same"); +BUTIL_VALIDATE_GFLAG(bvar_abort_on_same_name, validate_bvar_abort_on_same_name); DEFINE_bool(bvar_log_dumpped, false, "[For debugging] print dumpped info" " into logstream before call Dumpper"); +BUTIL_VALIDATE_GFLAG(bvar_log_dumpped, butil::PassValidate); const size_t SUB_MAP_COUNT = 32; // must be power of 2 BAIDU_CASSERT(!(SUB_MAP_COUNT & (SUB_MAP_COUNT - 1)), must_be_power_of_2); @@ -743,39 +743,39 @@ static void* dumping_thread(void*) { std::string mbvar_filename; std::string mbvar_prefix; std::string mbvar_format; - if (!GFLAGS_NS::GetCommandLineOption("bvar_dump_file", &filename)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_file", &filename)) { LOG(ERROR) << "Fail to get gflag bvar_dump_file"; return NULL; } - if (!GFLAGS_NS::GetCommandLineOption("bvar_dump_include", + if (!GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_include", &options.white_wildcards)) { LOG(ERROR) << "Fail to get gflag bvar_dump_include"; return NULL; } - if (!GFLAGS_NS::GetCommandLineOption("bvar_dump_exclude", + if (!GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_exclude", &options.black_wildcards)) { LOG(ERROR) << "Fail to get gflag bvar_dump_exclude"; return NULL; } - if (!GFLAGS_NS::GetCommandLineOption("bvar_dump_prefix", &prefix)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_prefix", &prefix)) { LOG(ERROR) << "Fail to get gflag bvar_dump_prefix"; return NULL; } - if (!GFLAGS_NS::GetCommandLineOption("bvar_dump_tabs", &tabs)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_tabs", &tabs)) { LOG(ERROR) << "Fail to get gflags bvar_dump_tabs"; return NULL; } // We can't access string flags directly because it's thread-unsafe. - if (!GFLAGS_NS::GetCommandLineOption("mbvar_dump_file", &mbvar_filename)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump_file", &mbvar_filename)) { LOG(ERROR) << "Fail to get gflag mbvar_dump_file"; return NULL; } - if (!GFLAGS_NS::GetCommandLineOption("mbvar_dump_prefix", &mbvar_prefix)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump_prefix", &mbvar_prefix)) { LOG(ERROR) << "Fail to get gflag mbvar_dump_prefix"; return NULL; } - if (!GFLAGS_NS::GetCommandLineOption("mbvar_dump_format", &mbvar_format)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump_format", &mbvar_format)) { LOG(ERROR) << "Fail to get gflag mbvar_dump_format"; return NULL; } @@ -883,8 +883,7 @@ static bool validate_bvar_dump(const char*, bool enabled) { } return true; } -const bool ALLOW_UNUSED dummy_bvar_dump = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_dump, validate_bvar_dump); +BUTIL_VALIDATE_GFLAG(bvar_dump, validate_bvar_dump); // validators (to make these gflags reloadable in brpc) static bool validate_bvar_dump_interval(const char*, int32_t v) { @@ -898,12 +897,7 @@ static bool validate_bvar_dump_interval(const char*, int32_t v) { } return true; } -const bool ALLOW_UNUSED dummy_bvar_dump_interval = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_dump_interval, validate_bvar_dump_interval); - -static bool validate_bvar_log_dumpped(const char *, bool) { return true; } -const bool ALLOW_UNUSED dummy_bvar_log_dumpped = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_bvar_log_dumpped, validate_bvar_log_dumpped); +BUTIL_VALIDATE_GFLAG(bvar_dump_interval, validate_bvar_dump_interval); static bool wakeup_dumping_thread(const char*, const std::string&) { // We're modifying a flag, wake up dumping_thread to generate @@ -912,22 +906,21 @@ static bool wakeup_dumping_thread(const char*, const std::string&) { return true; } -const bool ALLOW_UNUSED dummy_bvar_dump_file = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dummy_bvar_dump_file = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_bvar_dump_file, wakeup_dumping_thread); -const bool ALLOW_UNUSED dummy_bvar_dump_filter = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dummy_bvar_dump_filter = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_bvar_dump_include, wakeup_dumping_thread); -const bool ALLOW_UNUSED dummy_bvar_dump_exclude = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dummy_bvar_dump_exclude = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_bvar_dump_exclude, wakeup_dumping_thread); -const bool ALLOW_UNUSED dummy_bvar_dump_prefix = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dummy_bvar_dump_prefix = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_bvar_dump_prefix, wakeup_dumping_thread); -const bool ALLOW_UNUSED dummy_bvar_dump_tabs = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dummy_bvar_dump_tabs = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_bvar_dump_tabs, wakeup_dumping_thread); -const bool ALLOW_UNUSED dummy_mbvar_dump = ::GFLAGS_NS::RegisterFlagValidator( - &FLAGS_mbvar_dump, validate_bvar_dump); -const bool ALLOW_UNUSED dummy_mbvar_dump_prefix = ::GFLAGS_NS::RegisterFlagValidator( +BUTIL_VALIDATE_GFLAG(mbvar_dump, validate_bvar_dump); +const bool ALLOW_UNUSED dummy_mbvar_dump_prefix = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_mbvar_dump_prefix, wakeup_dumping_thread); -const bool ALLOW_UNUSED dump_mbvar_dump_file = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dump_mbvar_dump_file = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_mbvar_dump_file, wakeup_dumping_thread); static bool validate_mbvar_dump_format(const char*, const std::string& format) { @@ -943,7 +936,7 @@ static bool validate_mbvar_dump_format(const char*, const std::string& format) { return true; } -const bool ALLOW_UNUSED dummy_mbvar_dump_format = ::GFLAGS_NS::RegisterFlagValidator( +const bool ALLOW_UNUSED dummy_mbvar_dump_format = GFLAGS_NAMESPACE::RegisterFlagValidator( &FLAGS_mbvar_dump_format, validate_mbvar_dump_format); void to_underscored_name(std::string* name, const butil::StringPiece& src) { diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 3c4242da22..9817b45f10 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -29,7 +29,6 @@ COPTS = [ "-fPIC", "-Wno-unused-parameter", "-fno-omit-frame-pointer", - "-DGFLAGS_NS=google", "-fno-access-control", "-DBAZEL_TEST=1", "-DBVAR_NOT_LINK_DEFAULT_VARIABLES", diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 11f1ad3b15..9f635e672c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,7 +52,7 @@ else() message(FATAL_ERROR "Googletest is not available") endif() -set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} -DGFLAGS_NS=${GFLAGS_NS}") +set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL}") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__=__unused__ -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -D__STRICT_ANSI__ -include ${PROJECT_SOURCE_DIR}/test/sstream_workaround.h") set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer") use_cxx11() diff --git a/test/brpc_alpn_protocol_unittest.cpp b/test/brpc_alpn_protocol_unittest.cpp index 7970db9af1..21aada70d6 100644 --- a/test/brpc_alpn_protocol_unittest.cpp +++ b/test/brpc_alpn_protocol_unittest.cpp @@ -32,7 +32,7 @@ DEFINE_string(listen_addr, "0.0.0.0:8011", "Server listen address."); int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + ::GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_block_pool_unittest.cpp b/test/brpc_block_pool_unittest.cpp index d0bdd8e492..76e8c3258e 100644 --- a/test/brpc_block_pool_unittest.cpp +++ b/test/brpc_block_pool_unittest.cpp @@ -214,6 +214,6 @@ TEST_F(BlockPoolTest, dump_info) { int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp index 7b98896b41..43d0ab7f1f 100644 --- a/test/brpc_channel_unittest.cpp +++ b/test/brpc_channel_unittest.cpp @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) { brpc::FLAGS_idle_timeout_second = 0; brpc::FLAGS_max_connection_pool_size = 0; testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_circuit_breaker_unittest.cpp b/test/brpc_circuit_breaker_unittest.cpp index e8f55153f3..607fede9ea 100644 --- a/test/brpc_circuit_breaker_unittest.cpp +++ b/test/brpc_circuit_breaker_unittest.cpp @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { brpc::FLAGS_circuit_breaker_max_isolation_duration_ms = kMaxIsolationDurationMs; brpc::FLAGS_circuit_breaker_half_open_window_size = kHalfWindowSize; testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_coroutine_unittest.cpp b/test/brpc_coroutine_unittest.cpp index b89c1408cb..1df2c3a0e4 100644 --- a/test/brpc_coroutine_unittest.cpp +++ b/test/brpc_coroutine_unittest.cpp @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) { #ifdef BRPC_ENABLE_COROUTINE testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); #else printf("bRPC coroutine is not enabled, please add -std=c++20 to compile options\n"); diff --git a/test/brpc_esp_protocol_unittest.cpp b/test/brpc_esp_protocol_unittest.cpp index 4db1943cc9..d4cab7c47d 100644 --- a/test/brpc_esp_protocol_unittest.cpp +++ b/test/brpc_esp_protocol_unittest.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_grpc_protocol_unittest.cpp b/test/brpc_grpc_protocol_unittest.cpp index 4818b319b5..f170639d17 100644 --- a/test/brpc_grpc_protocol_unittest.cpp +++ b/test/brpc_grpc_protocol_unittest.cpp @@ -27,12 +27,12 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); - if (GFLAGS_NS::SetCommandLineOption("http_body_compress_threshold", "0").empty()) { + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); + if (GFLAGS_NAMESPACE::SetCommandLineOption("http_body_compress_threshold", "0").empty()) { std::cerr << "Fail to set -crash_on_fatal_log" << std::endl; return -1; } - if (GFLAGS_NS::SetCommandLineOption("crash_on_fatal_log", "true").empty()) { + if (GFLAGS_NAMESPACE::SetCommandLineOption("crash_on_fatal_log", "true").empty()) { std::cerr << "Fail to set -crash_on_fatal_log" << std::endl; return -1; } diff --git a/test/brpc_http_message_unittest.cpp b/test/brpc_http_message_unittest.cpp index 0d5a979a38..d6f206cd07 100644 --- a/test/brpc_http_message_unittest.cpp +++ b/test/brpc_http_message_unittest.cpp @@ -32,7 +32,7 @@ DECLARE_bool(allow_http_1_1_request_without_host); int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::FLAGS_allow_http_1_1_request_without_host = true; return RUN_ALL_TESTS(); } @@ -77,7 +77,7 @@ TEST(HttpMessageTest, http_method) { } TEST(HttpMessageTest, eof) { - GFLAGS_NS::SetCommandLineOption("verbose", "100"); + GFLAGS_NAMESPACE::SetCommandLineOption("verbose", "100"); const char* http_request = "GET /CloudApiControl/HttpServer/telematics/v3/weather?location=%E6%B5%B7%E5%8D%97%E7%9C%81%E7%9B%B4%E8%BE%96%E5%8E%BF%E7%BA%A7%E8%A1%8C%E6%94%BF%E5%8D%95%E4%BD%8D&output=json&ak=0l3FSP6qA0WbOzGRaafbmczS HTTP/1.1\r\n" "X-Host: api.map.baidu.com\r\n" diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp index f4bdec955f..d2dcf972c6 100644 --- a/test/brpc_http_rpc_protocol_unittest.cpp +++ b/test/brpc_http_rpc_protocol_unittest.cpp @@ -65,12 +65,12 @@ extern bvar::CollectorSpeedLimit g_rpc_dump_sl; int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); - if (GFLAGS_NS::SetCommandLineOption("socket_max_unwritten_bytes", "2000000").empty()) { + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); + if (GFLAGS_NAMESPACE::SetCommandLineOption("socket_max_unwritten_bytes", "2000000").empty()) { std::cerr << "Fail to set -socket_max_unwritten_bytes" << std::endl; return -1; } - if (GFLAGS_NS::SetCommandLineOption("crash_on_fatal_log", "true").empty()) { + if (GFLAGS_NAMESPACE::SetCommandLineOption("crash_on_fatal_log", "true").empty()) { std::cerr << "Fail to set -crash_on_fatal_log" << std::endl; return -1; } diff --git a/test/brpc_hulu_pbrpc_protocol_unittest.cpp b/test/brpc_hulu_pbrpc_protocol_unittest.cpp index 7830b3038f..7c971dc2a8 100644 --- a/test/brpc_hulu_pbrpc_protocol_unittest.cpp +++ b/test/brpc_hulu_pbrpc_protocol_unittest.cpp @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_interceptor_unittest.cpp b/test/brpc_interceptor_unittest.cpp index b786f1039d..6238c3fefd 100644 --- a/test/brpc_interceptor_unittest.cpp +++ b/test/brpc_interceptor_unittest.cpp @@ -32,7 +32,7 @@ DECLARE_bool(use_http_error_code); int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 14b0131cf4..509456e71c 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -1191,11 +1191,11 @@ TEST_F(LoadBalancerTest, invalid_lb_params) { } TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { - GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_size", "20"); - GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); + GFLAGS_NAMESPACE::SetCommandLineOption("circuit_breaker_short_window_size", "20"); + GFLAGS_NAMESPACE::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); // Those two lines force the interval of first hc to 3s - GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "3000"); - GFLAGS_NS::SetCommandLineOption("circuit_breaker_min_isolation_duration_ms", "3000"); + GFLAGS_NAMESPACE::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "3000"); + GFLAGS_NAMESPACE::SetCommandLineOption("circuit_breaker_min_isolation_duration_ms", "3000"); const char* lb_algo[] = { "random:min_working_instances=2 hold_seconds=2", "rr:min_working_instances=2 hold_seconds=2" }; diff --git a/test/brpc_mongo_protocol_unittest.cpp b/test/brpc_mongo_protocol_unittest.cpp index 17c3dee4d2..64e3bf394c 100644 --- a/test/brpc_mongo_protocol_unittest.cpp +++ b/test/brpc_mongo_protocol_unittest.cpp @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_public_pbrpc_protocol_unittest.cpp b/test/brpc_public_pbrpc_protocol_unittest.cpp index 82c9fc52d9..e92f5ed917 100644 --- a/test/brpc_public_pbrpc_protocol_unittest.cpp +++ b/test/brpc_public_pbrpc_protocol_unittest.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_rdma_unittest.cpp b/test/brpc_rdma_unittest.cpp index 6cf3eddfea..26a8236116 100644 --- a/test/brpc_rdma_unittest.cpp +++ b/test/brpc_rdma_unittest.cpp @@ -1955,7 +1955,7 @@ TEST_F(RdmaTest, try_memory_pool_empty) { int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); #if BRPC_WITH_RDMA rdma::FLAGS_rdma_trace_verbose = true; rdma::FLAGS_rdma_memory_pool_max_regions = 2; diff --git a/test/brpc_rtmp_unittest.cpp b/test/brpc_rtmp_unittest.cpp index 10cd842ed7..5853f7778d 100644 --- a/test/brpc_rtmp_unittest.cpp +++ b/test/brpc_rtmp_unittest.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_server_unittest.cpp b/test/brpc_server_unittest.cpp index 70f7ed3654..676f16626d 100644 --- a/test/brpc_server_unittest.cpp +++ b/test/brpc_server_unittest.cpp @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 59075b2bdb..4852ab7e74 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -66,7 +66,7 @@ void EchoProcessHuluRequest(brpc::InputMessageBase* msg_base); int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::Protocol dummy_protocol = { brpc::policy::ParseHuluMessage, brpc::SerializeRequestDefault, @@ -591,8 +591,8 @@ class HealthCheckTestServiceImpl : public test::HealthCheckTestService { TEST_F(SocketTest, app_level_health_check) { int old_health_check_interval = brpc::FLAGS_health_check_interval; - GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); - GFLAGS_NS::SetCommandLineOption("health_check_interval", "1"); + GFLAGS_NAMESPACE::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); + GFLAGS_NAMESPACE::SetCommandLineOption("health_check_interval", "1"); butil::EndPoint point(butil::IP_ANY, 7777); brpc::ChannelOptions options; @@ -644,10 +644,10 @@ TEST_F(SocketTest, app_level_health_check) { ASSERT_GT(cntl.response_attachment().size(), (size_t)0); } - GFLAGS_NS::SetCommandLineOption("health_check_path", ""); + GFLAGS_NAMESPACE::SetCommandLineOption("health_check_path", ""); char hc_buf[8]; snprintf(hc_buf, sizeof(hc_buf), "%d", old_health_check_interval); - GFLAGS_NS::SetCommandLineOption("health_check_interval", hc_buf); + GFLAGS_NAMESPACE::SetCommandLineOption("health_check_interval", hc_buf); } TEST_F(SocketTest, health_check) { diff --git a/test/brpc_sofa_pbrpc_protocol_unittest.cpp b/test/brpc_sofa_pbrpc_protocol_unittest.cpp index c875f7bd4b..4cf91b4fd4 100644 --- a/test/brpc_sofa_pbrpc_protocol_unittest.cpp +++ b/test/brpc_sofa_pbrpc_protocol_unittest.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp index 3c64ba765b..a7ef1c209e 100644 --- a/test/brpc_ssl_unittest.cpp +++ b/test/brpc_ssl_unittest.cpp @@ -45,7 +45,7 @@ void ExtractHostnames(X509* x, std::vector* hostnames); int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::GlobalInitializeOrDie(); return RUN_ALL_TESTS(); } diff --git a/test/bthread_butex_multi_tag_unittest.cpp b/test/bthread_butex_multi_tag_unittest.cpp index 98057d4a8e..e41fefddaf 100644 --- a/test/bthread_butex_multi_tag_unittest.cpp +++ b/test/bthread_butex_multi_tag_unittest.cpp @@ -27,7 +27,7 @@ DECLARE_int32(task_group_ntags); int main(int argc, char* argv[]) { FLAGS_task_group_ntags = 3; testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/bthread_key_unittest.cpp b/test/bthread_key_unittest.cpp index a7f11e7653..4319fb4180 100644 --- a/test/bthread_key_unittest.cpp +++ b/test/bthread_key_unittest.cpp @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) { bthread::FLAGS_key_table_list_size = 20; bthread::FLAGS_borrow_from_globle_size = 20; testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/bthread_setconcurrency_unittest.cpp b/test/bthread_setconcurrency_unittest.cpp index aa1d674c22..4d269b642b 100644 --- a/test/bthread_setconcurrency_unittest.cpp +++ b/test/bthread_setconcurrency_unittest.cpp @@ -140,13 +140,13 @@ void* add_concurrency_proc(void*) { bool set_min_concurrency(int num) { std::stringstream ss; ss << num; - std::string ret = GFLAGS_NS::SetCommandLineOption("bthread_min_concurrency", ss.str().c_str()); + std::string ret = GFLAGS_NAMESPACE::SetCommandLineOption("bthread_min_concurrency", ss.str().c_str()); return !ret.empty(); } int get_min_concurrency() { std::string ret; - GFLAGS_NS::GetCommandLineOption("bthread_min_concurrency", &ret); + GFLAGS_NAMESPACE::GetCommandLineOption("bthread_min_concurrency", &ret); return atoi(ret.c_str()); } @@ -194,7 +194,7 @@ TEST(BthreadTest, min_concurrency) { int current_tag(int tag) { std::stringstream ss; ss << tag; - std::string ret = GFLAGS_NS::SetCommandLineOption("bthread_current_tag", ss.str().c_str()); + std::string ret = GFLAGS_NAMESPACE::SetCommandLineOption("bthread_current_tag", ss.str().c_str()); return !(ret.empty()); } @@ -208,7 +208,7 @@ int concurrency_by_tag(int num) { std::stringstream ss; ss << num; std::string ret = - GFLAGS_NS::SetCommandLineOption("bthread_concurrency_by_tag", ss.str().c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("bthread_concurrency_by_tag", ss.str().c_str()); return !(ret.empty()); } diff --git a/test/bthread_unittest.cpp b/test/bthread_unittest.cpp index d160523403..0286db9904 100644 --- a/test/bthread_unittest.cpp +++ b/test/bthread_unittest.cpp @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); int rc = RUN_ALL_TESTS(); return rc; } diff --git a/test/butil_unittest_main.cpp b/test/butil_unittest_main.cpp index 96277e6423..c7c6965c1e 100644 --- a/test/butil_unittest_main.cpp +++ b/test/butil_unittest_main.cpp @@ -27,8 +27,8 @@ DEFINE_bool(disable_coredump, false, "Never core dump"); int main(int argc, char** argv) { butil::AtExitManager at_exit; testing::InitGoogleTest(&argc, argv); - - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_disable_coredump) { rlimit core_limit; core_limit.rlim_cur = 0; @@ -36,7 +36,7 @@ int main(int argc, char** argv) { setrlimit(RLIMIT_CORE, &core_limit); } #if !BRPC_WITH_GLOG - CHECK(!GFLAGS_NS::SetCommandLineOption("crash_on_fatal_log", "true").empty()); + CHECK(!GFLAGS_NAMESPACE::SetCommandLineOption("crash_on_fatal_log", "true").empty()); #endif return RUN_ALL_TESTS(); } diff --git a/test/bvar_file_dumper_unittest.cpp b/test/bvar_file_dumper_unittest.cpp index 9e80cef10d..9a6bb0a095 100644 --- a/test/bvar_file_dumper_unittest.cpp +++ b/test/bvar_file_dumper_unittest.cpp @@ -34,7 +34,7 @@ TEST_F(FileDumperTest, filters) { bvar::Adder a3("a_error"); bvar::Adder a4("process_*"); bvar::Adder a5("default"); - GFLAGS_NS::SetCommandLineOption("bvar_dump_interval", "1"); - GFLAGS_NS::SetCommandLineOption("bvar_dump", "true"); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_dump_interval", "1"); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_dump", "true"); sleep(2); } diff --git a/test/bvar_multi_dimension_unittest.cpp b/test/bvar_multi_dimension_unittest.cpp index 974090d0a6..8d0e479d0d 100644 --- a/test/bvar_multi_dimension_unittest.cpp +++ b/test/bvar_multi_dimension_unittest.cpp @@ -401,17 +401,17 @@ TEST_F(MultiDimensionTest, mlatencyrecorder) { std::string old_bvar_latency_p2; std::string old_bvar_latency_p3; - GFLAGS_NS::GetCommandLineOption("bvar_dump_interval", &old_bvar_dump_interval); - GFLAGS_NS::GetCommandLineOption("mbvar_dump", &old_mbvar_dump); - GFLAGS_NS::GetCommandLineOption("bvar_latency_p1", &old_bvar_latency_p1); - GFLAGS_NS::GetCommandLineOption("bvar_latency_p2", &old_bvar_latency_p2); - GFLAGS_NS::GetCommandLineOption("bvar_latency_p3", &old_bvar_latency_p3); - - GFLAGS_NS::SetCommandLineOption("bvar_dump_interval", "1"); - GFLAGS_NS::SetCommandLineOption("mbvar_dump", "true"); - GFLAGS_NS::SetCommandLineOption("bvar_latency_p1", "60"); - GFLAGS_NS::SetCommandLineOption("bvar_latency_p2", "70"); - GFLAGS_NS::SetCommandLineOption("bvar_latency_p3", "80"); + GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_interval", &old_bvar_dump_interval); + GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump", &old_mbvar_dump); + GFLAGS_NAMESPACE::GetCommandLineOption("bvar_latency_p1", &old_bvar_latency_p1); + GFLAGS_NAMESPACE::GetCommandLineOption("bvar_latency_p2", &old_bvar_latency_p2); + GFLAGS_NAMESPACE::GetCommandLineOption("bvar_latency_p3", &old_bvar_latency_p3); + + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_dump_interval", "1"); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump", "true"); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_latency_p1", "60"); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_latency_p2", "70"); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_latency_p3", "80"); bvar::MultiDimension my_mlatencyrecorder("client_request_count_mlatencyrecorder", labels); std::list labels_value = {"tc", "get", "200"}; @@ -424,11 +424,11 @@ TEST_F(MultiDimensionTest, mlatencyrecorder) { ASSERT_LE(7, my_latencyrecorder->qps()); ASSERT_EQ(7, my_latencyrecorder->count()); - GFLAGS_NS::SetCommandLineOption("bvar_dump_interval", old_bvar_dump_interval.c_str()); - GFLAGS_NS::SetCommandLineOption("mbvar_dump", old_mbvar_dump.c_str()); - GFLAGS_NS::SetCommandLineOption("bvar_latency_p1", old_bvar_latency_p1.c_str()); - GFLAGS_NS::SetCommandLineOption("bvar_latency_p2", old_bvar_latency_p2.c_str()); - GFLAGS_NS::SetCommandLineOption("bvar_latency_p3", old_bvar_latency_p3.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_dump_interval", old_bvar_dump_interval.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump", old_mbvar_dump.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_latency_p1", old_bvar_latency_p1.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_latency_p2", old_bvar_latency_p2.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_latency_p3", old_bvar_latency_p3.c_str()); } TEST_F(MultiDimensionTest, mstatus) { diff --git a/test/bvar_mvariable_unittest.cpp b/test/bvar_mvariable_unittest.cpp index 8e783317c3..5ab171c4d8 100644 --- a/test/bvar_mvariable_unittest.cpp +++ b/test/bvar_mvariable_unittest.cpp @@ -158,15 +158,15 @@ TEST_F(MVariableTest, dump) { std::string old_mbvar_dump_prefix; std::string old_mbvar_dump_format; - GFLAGS_NS::GetCommandLineOption("bvar_dump_interval", &old_bvar_dump_interval); - GFLAGS_NS::GetCommandLineOption("mbvar_dump", &old_mbvar_dump); - GFLAGS_NS::GetCommandLineOption("mbvar_dump_prefix", &old_mbvar_dump_prefix); - GFLAGS_NS::GetCommandLineOption("mbvar_dump_format", &old_mbvar_dump_format); + GFLAGS_NAMESPACE::GetCommandLineOption("bvar_dump_interval", &old_bvar_dump_interval); + GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump", &old_mbvar_dump); + GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump_prefix", &old_mbvar_dump_prefix); + GFLAGS_NAMESPACE::GetCommandLineOption("mbvar_dump_format", &old_mbvar_dump_format); - GFLAGS_NS::SetCommandLineOption("bvar_dump_interval", "1"); - GFLAGS_NS::SetCommandLineOption("mbvar_dump", "true"); - GFLAGS_NS::SetCommandLineOption("mbvar_dump_prefix", "my_mdump_prefix"); - GFLAGS_NS::SetCommandLineOption("mbvar_dump_format", "common"); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_dump_interval", "1"); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump", "true"); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump_prefix", "my_mdump_prefix"); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump_format", "common"); bvar::MultiDimension > my_madder("dump_adder", labels); std::list labels_value1 {"gz", "post", "200"}; @@ -218,10 +218,10 @@ TEST_F(MVariableTest, dump) { *my_latencyrecorder1 << 3 << 6 << 9; sleep(2); - GFLAGS_NS::SetCommandLineOption("bvar_dump_interval", old_bvar_dump_interval.c_str()); - GFLAGS_NS::SetCommandLineOption("mbvar_dump", old_mbvar_dump.c_str()); - GFLAGS_NS::SetCommandLineOption("mbvar_dump_prefix", old_mbvar_dump_prefix.c_str()); - GFLAGS_NS::SetCommandLineOption("mbvar_dump_format", old_mbvar_dump_format.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("bvar_dump_interval", old_bvar_dump_interval.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump", old_mbvar_dump.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump_prefix", old_mbvar_dump_prefix.c_str()); + GFLAGS_NAMESPACE::SetCommandLineOption("mbvar_dump_format", old_mbvar_dump_format.c_str()); } TEST_F(MVariableTest, test_describe_exposed) { diff --git a/test/bvar_variable_unittest.cpp b/test/bvar_variable_unittest.cpp index 263a1ede3f..7450da6910 100644 --- a/test/bvar_variable_unittest.cpp +++ b/test/bvar_variable_unittest.cpp @@ -396,6 +396,6 @@ TEST_F(VariableTest, recursive_mutex) { int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); } diff --git a/test/logging_unittest.cc b/test/logging_unittest.cc index 018b2aa535..a431e01b60 100644 --- a/test/logging_unittest.cc +++ b/test/logging_unittest.cc @@ -59,8 +59,8 @@ class LoggingTest : public testing::Test { ::logging::FLAGS_crash_on_fatal_log = _old_crash_on_fatal_log; if (::logging::FLAGS_v != 0) { // Clear -verbose to avoid affecting other tests. - ASSERT_FALSE(GFLAGS_NS::SetCommandLineOption("v", "0").empty()); - ASSERT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", "").empty()); + ASSERT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("v", "0").empty()); + ASSERT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "").empty()); } } private: @@ -218,11 +218,11 @@ TEST_F(LoggingTest, log_at) { TEST_F(LoggingTest, vlog_sanity) { ::logging::FLAGS_crash_on_fatal_log = false; - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("v", "1").empty()); + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("v", "1").empty()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "logging_unittest=1").empty()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "logging_UNITTEST=2").empty()); for (int i = 0; i < 10; ++i) { @@ -238,7 +238,7 @@ TEST_F(LoggingTest, vlog_sanity) { VLOG_NE(0) << "always on"; EXPECT_EQ("always on", LOG_STREAM(INFO).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "logging_unittest=0").empty()); for (int i = 0; i < 10; ++i) { VLOG_NE(i) << "vlog " << i; @@ -246,7 +246,7 @@ TEST_F(LoggingTest, vlog_sanity) { EXPECT_EQ("", LOG_STREAM(VERBOSE).content_str()); EXPECT_EQ("vlog 0", LOG_STREAM(INFO).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "logging_unittest=0,logging_unittest=1").empty()); for (int i = 0; i < 10; ++i) { VLOG_NE(i) << "vlog " << i; @@ -254,7 +254,7 @@ TEST_F(LoggingTest, vlog_sanity) { EXPECT_EQ("vlog 1", LOG_STREAM(VERBOSE).content_str()); EXPECT_EQ("vlog 0", LOG_STREAM(INFO).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "logging_unittest=1,logging_unittest=0").empty()); for (int i = 0; i < 10; ++i) { VLOG_NE(i) << "vlog " << i; @@ -262,14 +262,14 @@ TEST_F(LoggingTest, vlog_sanity) { EXPECT_EQ("", LOG_STREAM(VERBOSE).content_str()); EXPECT_EQ("vlog 0", LOG_STREAM(INFO).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", "").empty()); + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "").empty()); for (int i = 0; i < 10; ++i) { VLOG_NE(i) << "vlog " << i; } EXPECT_EQ("vlog 1", LOG_STREAM(VERBOSE).content_str()); EXPECT_EQ("vlog 0", LOG_STREAM(INFO).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "logg?ng_*=2").empty()); for (int i = 0; i < 10; ++i) { VLOG_NE(i) << "vlog " << i; @@ -277,7 +277,7 @@ TEST_F(LoggingTest, vlog_sanity) { EXPECT_EQ("vlog 1vlog 2", LOG_STREAM(VERBOSE).content_str()); EXPECT_EQ("vlog 0", LOG_STREAM(INFO).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "foo=3,logging_unittest=3, logg?ng_*=2 , logging_*=1 ").empty()); for (int i = 0; i < 10; ++i) { VLOG_NE(i) << "vlog " << i; @@ -290,7 +290,7 @@ TEST_F(LoggingTest, vlog_sanity) { } EXPECT_EQ("vlog 1vlog 3", LOG_STREAM(VERBOSE).content_str()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption( + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption( "vmodule", "foo/bar0/0=2,foo/bar/1=3, 2=4, foo/*/3=5, */ba?/4=6," "/5=7,/foo/bar/6=8,foo2/bar/7=9,foo/bar/8=9").empty()); @@ -373,8 +373,8 @@ TEST_F(LoggingTest, debug_level) { DLOG(NOTICE) << foo(&run_foo); DLOG(DEBUG) << foo(&run_foo); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("vmodule", "").empty()); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("v", "1").empty()); + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("vmodule", "").empty()); + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("v", "1").empty()); DVLOG(1) << foo(&run_foo); DVLOG2("a/b/c", 1) << foo(&run_foo); @@ -470,7 +470,7 @@ void CheckFunctionName() { ASSERT_NE(std::string::npos, log_str.find("specified_file.cc:12345 log_at")); ::logging::SetLogSink(old_sink); - EXPECT_FALSE(GFLAGS_NS::SetCommandLineOption("v", "1").empty()); + EXPECT_FALSE(GFLAGS_NAMESPACE::SetCommandLineOption("v", "1").empty()); VLOG(100) << "test" << noflush; ASSERT_EQ(func_name, VLOG_STREAM(100).func()); } From 0608aa1e13d59e6af233efa0e2be95bbee4912d1 Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Sun, 19 Jan 2025 21:28:55 +0800 Subject: [PATCH 5/6] Fix gflag namespace of example and tools (#2879) --- CMakeLists.txt | 13 +------------ example/BUILD.bazel | 1 - example/asynchronous_echo_c++/CMakeLists.txt | 13 +------------ example/asynchronous_echo_c++/client.cpp | 2 +- example/asynchronous_echo_c++/server.cpp | 2 +- example/auto_concurrency_limiter/CMakeLists.txt | 13 +------------ example/auto_concurrency_limiter/client.cpp | 2 +- example/auto_concurrency_limiter/server.cpp | 2 +- example/backup_request_c++/CMakeLists.txt | 13 +------------ example/backup_request_c++/client.cpp | 2 +- example/backup_request_c++/server.cpp | 2 +- .../baidu_proxy_and_generic_call/CMakeLists.txt | 13 +------------ example/baidu_proxy_and_generic_call/client.cpp | 2 +- example/baidu_proxy_and_generic_call/proxy.cpp | 2 +- example/baidu_proxy_and_generic_call/server.cpp | 2 +- example/bthread_tag_echo_c++/CMakeLists.txt | 13 +------------ example/bthread_tag_echo_c++/client.cpp | 2 +- example/bthread_tag_echo_c++/server.cpp | 4 ++-- example/cancel_c++/CMakeLists.txt | 13 +------------ example/cancel_c++/client.cpp | 2 +- example/cancel_c++/server.cpp | 2 +- example/cascade_echo_c++/CMakeLists.txt | 13 +------------ example/cascade_echo_c++/client.cpp | 4 ++-- example/cascade_echo_c++/server.cpp | 4 ++-- example/coroutine/coroutine_server.cpp | 4 ++-- example/dynamic_partition_echo_c++/CMakeLists.txt | 13 +------------ example/dynamic_partition_echo_c++/client.cpp | 2 +- example/dynamic_partition_echo_c++/server.cpp | 2 +- example/echo_c++/CMakeLists.txt | 13 +------------ example/echo_c++/client.cpp | 2 +- example/echo_c++/server.cpp | 2 +- example/grpc_c++/CMakeLists.txt | 14 +------------- example/grpc_c++/client.cpp | 4 ++-- example/grpc_c++/server.cpp | 2 +- example/http_c++/CMakeLists.txt | 14 +------------- example/http_c++/benchmark_http.cpp | 2 +- example/http_c++/http_client.cpp | 2 +- example/http_c++/http_server.cpp | 2 +- example/memcache_c++/CMakeLists.txt | 13 +------------ example/memcache_c++/client.cpp | 2 +- example/multi_threaded_echo_c++/CMakeLists.txt | 13 +------------ example/multi_threaded_echo_c++/client.cpp | 2 +- example/multi_threaded_echo_c++/server.cpp | 4 ++-- example/multi_threaded_echo_fns_c++/CMakeLists.txt | 13 +------------ example/multi_threaded_echo_fns_c++/client.cpp | 2 +- example/multi_threaded_echo_fns_c++/server.cpp | 2 +- example/nshead_extension_c++/CMakeLists.txt | 13 +------------ example/nshead_extension_c++/client.cpp | 2 +- example/nshead_extension_c++/server.cpp | 2 +- example/nshead_pb_extension_c++/CMakeLists.txt | 13 +------------ example/nshead_pb_extension_c++/client.cpp | 2 +- example/nshead_pb_extension_c++/server.cpp | 2 +- example/parallel_echo_c++/CMakeLists.txt | 13 +------------ example/parallel_echo_c++/client.cpp | 2 +- example/parallel_echo_c++/server.cpp | 2 +- example/partition_echo_c++/CMakeLists.txt | 13 +------------ example/partition_echo_c++/client.cpp | 2 +- example/partition_echo_c++/server.cpp | 2 +- example/rdma_performance/CMakeLists.txt | 12 +----------- example/rdma_performance/client.cpp | 2 +- example/rdma_performance/server.cpp | 2 +- example/redis_c++/CMakeLists.txt | 13 +------------ example/redis_c++/redis_cli.cpp | 2 +- example/redis_c++/redis_press.cpp | 2 +- example/rpcz_echo_c++/CMakeLists.txt | 13 +------------ example/rpcz_echo_c++/client.cpp | 2 +- example/rpcz_echo_c++/server.cpp | 2 +- example/selective_echo_c++/CMakeLists.txt | 13 +------------ example/selective_echo_c++/client.cpp | 2 +- example/selective_echo_c++/server.cpp | 2 +- .../session_data_and_thread_local/CMakeLists.txt | 13 +------------ example/session_data_and_thread_local/client.cpp | 2 +- example/session_data_and_thread_local/server.cpp | 2 +- example/streaming_batch_echo_c++/CMakeLists.txt | 13 +------------ example/streaming_batch_echo_c++/client.cpp | 2 +- example/streaming_batch_echo_c++/server.cpp | 2 +- example/streaming_echo_c++/CMakeLists.txt | 13 +------------ example/streaming_echo_c++/client.cpp | 2 +- example/streaming_echo_c++/server.cpp | 2 +- example/thrift_extension_c++/client2.cpp | 2 +- tools/BUILD | 1 - tools/parallel_http/parallel_http.cpp | 2 +- tools/rpc_press/rpc_press.cpp | 2 +- tools/rpc_replay/rpc_replay.cpp | 2 +- tools/rpc_view/rpc_view.cpp | 10 +++++----- tools/trackme_server/trackme_server.cpp | 2 +- 86 files changed, 94 insertions(+), 383 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 284f27fe10..afc2de4d31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,17 +114,6 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") find_package(GFLAGS REQUIRED) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() - include_directories( ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR} @@ -144,7 +133,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wno-deprecated-declarations -Wno-inconsistent-missing-override") endif() -set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} -DGFLAGS_NS=${GFLAGS_NS} -DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=${WITH_DEBUG_BTHREAD_SCHE_SAFETY_VAL} -DBRPC_DEBUG_LOCK=${WITH_DEBUG_LOCK_VAL}") +set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} -DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=${WITH_DEBUG_BTHREAD_SCHE_SAFETY_VAL} -DBRPC_DEBUG_LOCK=${WITH_DEBUG_LOCK_VAL}") if(WITH_MESALINK) set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DUSE_MESALINK") endif() diff --git a/example/BUILD.bazel b/example/BUILD.bazel index afc525a331..b38cd5a156 100644 --- a/example/BUILD.bazel +++ b/example/BUILD.bazel @@ -28,7 +28,6 @@ COPTS = [ "-fPIC", "-Wno-unused-parameter", "-fno-omit-frame-pointer", - "-DGFLAGS_NS=google", ] + select({ "//bazel/config:brpc_with_glog": ["-DBRPC_WITH_GLOG=1"], "//conditions:default": ["-DBRPC_WITH_GLOG=0"], diff --git a/example/asynchronous_echo_c++/CMakeLists.txt b/example/asynchronous_echo_c++/CMakeLists.txt index 2946e29963..37cb5f380c 100644 --- a/example/asynchronous_echo_c++/CMakeLists.txt +++ b/example/asynchronous_echo_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/asynchronous_echo_c++/client.cpp b/example/asynchronous_echo_c++/client.cpp index e77918cbb8..b52297b4b5 100644 --- a/example/asynchronous_echo_c++/client.cpp +++ b/example/asynchronous_echo_c++/client.cpp @@ -51,7 +51,7 @@ void HandleEchoResponse( int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/asynchronous_echo_c++/server.cpp b/example/asynchronous_echo_c++/server.cpp index 7aad241f6a..dcce19a80b 100644 --- a/example/asynchronous_echo_c++/server.cpp +++ b/example/asynchronous_echo_c++/server.cpp @@ -87,7 +87,7 @@ class EchoServiceImpl : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/auto_concurrency_limiter/CMakeLists.txt b/example/auto_concurrency_limiter/CMakeLists.txt index 4d4802c8d4..a496dd572b 100644 --- a/example/auto_concurrency_limiter/CMakeLists.txt +++ b/example/auto_concurrency_limiter/CMakeLists.txt @@ -51,16 +51,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -69,8 +59,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/auto_concurrency_limiter/client.cpp b/example/auto_concurrency_limiter/client.cpp index 13377f04ba..d33325ddf9 100644 --- a/example/auto_concurrency_limiter/client.cpp +++ b/example/auto_concurrency_limiter/client.cpp @@ -215,7 +215,7 @@ void RunCase(test::ControlService_Stub &cntl_stub, int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); Expose(); brpc::Channel channel; diff --git a/example/auto_concurrency_limiter/server.cpp b/example/auto_concurrency_limiter/server.cpp index 5d7314548d..61f826fab7 100644 --- a/example/auto_concurrency_limiter/server.cpp +++ b/example/auto_concurrency_limiter/server.cpp @@ -271,7 +271,7 @@ class ControlServiceImpl : public test::ControlService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); bthread::FLAGS_bthread_concurrency= FLAGS_server_bthread_concurrency; brpc::Server server; diff --git a/example/backup_request_c++/CMakeLists.txt b/example/backup_request_c++/CMakeLists.txt index 5b91114b50..3c8d34a0a8 100644 --- a/example/backup_request_c++/CMakeLists.txt +++ b/example/backup_request_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/backup_request_c++/client.cpp b/example/backup_request_c++/client.cpp index dfbb5856dc..07005e3770 100644 --- a/example/backup_request_c++/client.cpp +++ b/example/backup_request_c++/client.cpp @@ -35,7 +35,7 @@ DEFINE_int32(backup_request_ms, 2, "Timeout for sending backup request"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/backup_request_c++/server.cpp b/example/backup_request_c++/server.cpp index 198120f19b..9bc8a578b2 100644 --- a/example/backup_request_c++/server.cpp +++ b/example/backup_request_c++/server.cpp @@ -78,7 +78,7 @@ class SleepyEchoService : public EchoService int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/baidu_proxy_and_generic_call/CMakeLists.txt b/example/baidu_proxy_and_generic_call/CMakeLists.txt index 88c691dff5..7e34d0a83d 100644 --- a/example/baidu_proxy_and_generic_call/CMakeLists.txt +++ b/example/baidu_proxy_and_generic_call/CMakeLists.txt @@ -51,16 +51,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -69,8 +59,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/baidu_proxy_and_generic_call/client.cpp b/example/baidu_proxy_and_generic_call/client.cpp index d8040740a8..b8fd3101bb 100644 --- a/example/baidu_proxy_and_generic_call/client.cpp +++ b/example/baidu_proxy_and_generic_call/client.cpp @@ -34,7 +34,7 @@ DEFINE_int32(interval_ms, 1000, "Milliseconds between consecutive requests"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/baidu_proxy_and_generic_call/proxy.cpp b/example/baidu_proxy_and_generic_call/proxy.cpp index 81e1176ba2..a7f24fbcc5 100644 --- a/example/baidu_proxy_and_generic_call/proxy.cpp +++ b/example/baidu_proxy_and_generic_call/proxy.cpp @@ -111,7 +111,7 @@ class BaiduMasterServiceImpl : public brpc::BaiduMasterService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/baidu_proxy_and_generic_call/server.cpp b/example/baidu_proxy_and_generic_call/server.cpp index b3f161736e..64d4936696 100644 --- a/example/baidu_proxy_and_generic_call/server.cpp +++ b/example/baidu_proxy_and_generic_call/server.cpp @@ -78,7 +78,7 @@ class EchoServiceImpl : public EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/bthread_tag_echo_c++/CMakeLists.txt b/example/bthread_tag_echo_c++/CMakeLists.txt index 3dd7a24522..d91aa6ca23 100644 --- a/example/bthread_tag_echo_c++/CMakeLists.txt +++ b/example/bthread_tag_echo_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/bthread_tag_echo_c++/client.cpp b/example/bthread_tag_echo_c++/client.cpp index 2af1a8a66f..2b5a9e0bb5 100644 --- a/example/bthread_tag_echo_c++/client.cpp +++ b/example/bthread_tag_echo_c++/client.cpp @@ -84,7 +84,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/bthread_tag_echo_c++/server.cpp b/example/bthread_tag_echo_c++/server.cpp index ed4ba4d6c3..0d14bd1dcf 100644 --- a/example/bthread_tag_echo_c++/server.cpp +++ b/example/bthread_tag_echo_c++/server.cpp @@ -74,10 +74,10 @@ static void* my_background_task(void*) { int main(int argc, char* argv[]) { std::string help_str = "dummy help infomation"; - GFLAGS_NS::SetUsageMessage(help_str); + GFLAGS_NAMESPACE::SetUsageMessage(help_str); // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_h) { fprintf(stderr, "%s\n%s\n%s", help_str.c_str(), help_str.c_str(), help_str.c_str()); diff --git a/example/cancel_c++/CMakeLists.txt b/example/cancel_c++/CMakeLists.txt index d6246c67fe..b8d64ddad5 100644 --- a/example/cancel_c++/CMakeLists.txt +++ b/example/cancel_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/cancel_c++/client.cpp b/example/cancel_c++/client.cpp index b1ba1aeb6a..dd23b679e9 100644 --- a/example/cancel_c++/client.cpp +++ b/example/cancel_c++/client.cpp @@ -45,7 +45,7 @@ class CancelRPC : public google::protobuf::Closure { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/cancel_c++/server.cpp b/example/cancel_c++/server.cpp index 5fa5e17acf..b85ec09a97 100644 --- a/example/cancel_c++/server.cpp +++ b/example/cancel_c++/server.cpp @@ -73,7 +73,7 @@ class EchoServiceImpl : public EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/cascade_echo_c++/CMakeLists.txt b/example/cascade_echo_c++/CMakeLists.txt index bfb11025fd..453067b105 100644 --- a/example/cascade_echo_c++/CMakeLists.txt +++ b/example/cascade_echo_c++/CMakeLists.txt @@ -57,16 +57,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -75,8 +65,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/cascade_echo_c++/client.cpp b/example/cascade_echo_c++/client.cpp index cb545b6e32..25a1b52fa7 100644 --- a/example/cascade_echo_c++/client.cpp +++ b/example/cascade_echo_c++/client.cpp @@ -87,8 +87,8 @@ void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::SetUsageMessage("Send EchoRequest to server every second"); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::SetUsageMessage("Send EchoRequest to server every second"); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/cascade_echo_c++/server.cpp b/example/cascade_echo_c++/server.cpp index de19e660fd..c329073c56 100644 --- a/example/cascade_echo_c++/server.cpp +++ b/example/cascade_echo_c++/server.cpp @@ -85,8 +85,8 @@ class CascadeEchoService : public EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::SetUsageMessage("A server that may call itself"); - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::SetUsageMessage("A server that may call itself"); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/coroutine/coroutine_server.cpp b/example/coroutine/coroutine_server.cpp index 9df50b04b6..51ef7fcba0 100644 --- a/example/coroutine/coroutine_server.cpp +++ b/example/coroutine/coroutine_server.cpp @@ -111,9 +111,9 @@ int main(int argc, char* argv[]) { bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY); // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_enable_coroutine) { - GFLAGS_NS::SetCommandLineOption("usercode_in_coroutine", "true"); + GFLAGS_NAMESPACE::SetCommandLineOption("usercode_in_coroutine", "true"); } // Generally you only need one Server. diff --git a/example/dynamic_partition_echo_c++/CMakeLists.txt b/example/dynamic_partition_echo_c++/CMakeLists.txt index a5724d2ce8..cf79c8cb09 100644 --- a/example/dynamic_partition_echo_c++/CMakeLists.txt +++ b/example/dynamic_partition_echo_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/dynamic_partition_echo_c++/client.cpp b/example/dynamic_partition_echo_c++/client.cpp index 6c83b086ef..fd25514ccd 100644 --- a/example/dynamic_partition_echo_c++/client.cpp +++ b/example/dynamic_partition_echo_c++/client.cpp @@ -122,7 +122,7 @@ class MyPartitionParser : public brpc::PartitionParser { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/dynamic_partition_echo_c++/server.cpp b/example/dynamic_partition_echo_c++/server.cpp index 0047e01c6a..e86affaa91 100644 --- a/example/dynamic_partition_echo_c++/server.cpp +++ b/example/dynamic_partition_echo_c++/server.cpp @@ -94,7 +94,7 @@ class EchoServiceImpl : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_server_num <= 0) { LOG(ERROR) << "server_num must be positive"; diff --git a/example/echo_c++/CMakeLists.txt b/example/echo_c++/CMakeLists.txt index 54fdd5707a..02d2477914 100644 --- a/example/echo_c++/CMakeLists.txt +++ b/example/echo_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/echo_c++/client.cpp b/example/echo_c++/client.cpp index 337aa6e90d..3cc83f7203 100644 --- a/example/echo_c++/client.cpp +++ b/example/echo_c++/client.cpp @@ -34,7 +34,7 @@ DEFINE_int32(interval_ms, 1000, "Milliseconds between consecutive requests"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/echo_c++/server.cpp b/example/echo_c++/server.cpp index d1f0605178..cc0050aea5 100644 --- a/example/echo_c++/server.cpp +++ b/example/echo_c++/server.cpp @@ -94,7 +94,7 @@ class EchoServiceImpl : public EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/grpc_c++/CMakeLists.txt b/example/grpc_c++/CMakeLists.txt index 6250d2aba9..3d947688d2 100644 --- a/example/grpc_c++/CMakeLists.txt +++ b/example/grpc_c++/CMakeLists.txt @@ -55,17 +55,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -74,8 +63,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/grpc_c++/client.cpp b/example/grpc_c++/client.cpp index 0ce4b90b7c..4318ed885e 100644 --- a/example/grpc_c++/client.cpp +++ b/example/grpc_c++/client.cpp @@ -33,9 +33,9 @@ DEFINE_bool(gzip, false, "compress body using gzip"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_gzip) { - GFLAGS_NS::SetCommandLineOption("http_body_compress_threshold", 0); + GFLAGS_NAMESPACE::SetCommandLineOption("http_body_compress_threshold", 0); } // A Channel represents a communication line to a Server. Notice that diff --git a/example/grpc_c++/server.cpp b/example/grpc_c++/server.cpp index 50e21dba76..7658556e65 100644 --- a/example/grpc_c++/server.cpp +++ b/example/grpc_c++/server.cpp @@ -47,7 +47,7 @@ class GreeterImpl : public helloworld::Greeter { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/http_c++/CMakeLists.txt b/example/http_c++/CMakeLists.txt index c5e7d40a5a..66c4deec97 100644 --- a/example/http_c++/CMakeLists.txt +++ b/example/http_c++/CMakeLists.txt @@ -62,17 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -81,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/http_c++/benchmark_http.cpp b/example/http_c++/benchmark_http.cpp index 3ddcfe14bb..7fc879d190 100644 --- a/example/http_c++/benchmark_http.cpp +++ b/example/http_c++/benchmark_http.cpp @@ -74,7 +74,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/http_c++/http_client.cpp b/example/http_c++/http_client.cpp index d9984c886f..23222dee9b 100644 --- a/example/http_c++/http_client.cpp +++ b/example/http_c++/http_client.cpp @@ -38,7 +38,7 @@ DECLARE_bool(http_verbose); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (argc != 2) { LOG(ERROR) << "Usage: ./http_client \"http(s)://www.foo.com\""; diff --git a/example/http_c++/http_server.cpp b/example/http_c++/http_server.cpp index 3a806c43ea..05c9a0ee4c 100644 --- a/example/http_c++/http_server.cpp +++ b/example/http_c++/http_server.cpp @@ -225,7 +225,7 @@ class HttpSSEServiceImpl : public HttpSSEService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/memcache_c++/CMakeLists.txt b/example/memcache_c++/CMakeLists.txt index 7236f01c43..e3e70f96b7 100644 --- a/example/memcache_c++/CMakeLists.txt +++ b/example/memcache_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/memcache_c++/client.cpp b/example/memcache_c++/client.cpp index 01b03651d3..5f32198867 100644 --- a/example/memcache_c++/client.cpp +++ b/example/memcache_c++/client.cpp @@ -101,7 +101,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_exptime < 0) { FLAGS_exptime = 0; } diff --git a/example/multi_threaded_echo_c++/CMakeLists.txt b/example/multi_threaded_echo_c++/CMakeLists.txt index 896483afc5..d57886b6f1 100644 --- a/example/multi_threaded_echo_c++/CMakeLists.txt +++ b/example/multi_threaded_echo_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/multi_threaded_echo_c++/client.cpp b/example/multi_threaded_echo_c++/client.cpp index 0b7ea28ce1..fa9768c726 100644 --- a/example/multi_threaded_echo_c++/client.cpp +++ b/example/multi_threaded_echo_c++/client.cpp @@ -85,7 +85,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/multi_threaded_echo_c++/server.cpp b/example/multi_threaded_echo_c++/server.cpp index b747487f2a..54ca096016 100644 --- a/example/multi_threaded_echo_c++/server.cpp +++ b/example/multi_threaded_echo_c++/server.cpp @@ -56,10 +56,10 @@ DEFINE_bool(h, false, "print help information"); int main(int argc, char* argv[]) { std::string help_str = "dummy help infomation"; - GFLAGS_NS::SetUsageMessage(help_str); + GFLAGS_NAMESPACE::SetUsageMessage(help_str); // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_h) { fprintf(stderr, "%s\n%s\n%s", help_str.c_str(), help_str.c_str(), help_str.c_str()); diff --git a/example/multi_threaded_echo_fns_c++/CMakeLists.txt b/example/multi_threaded_echo_fns_c++/CMakeLists.txt index c934f7aa88..0805485d95 100644 --- a/example/multi_threaded_echo_fns_c++/CMakeLists.txt +++ b/example/multi_threaded_echo_fns_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/multi_threaded_echo_fns_c++/client.cpp b/example/multi_threaded_echo_fns_c++/client.cpp index cec7f0d463..895b3e5523 100644 --- a/example/multi_threaded_echo_fns_c++/client.cpp +++ b/example/multi_threaded_echo_fns_c++/client.cpp @@ -91,7 +91,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/multi_threaded_echo_fns_c++/server.cpp b/example/multi_threaded_echo_fns_c++/server.cpp index c9576e68ca..2e837bbf46 100644 --- a/example/multi_threaded_echo_fns_c++/server.cpp +++ b/example/multi_threaded_echo_fns_c++/server.cpp @@ -97,7 +97,7 @@ class EchoServiceImpl : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_server_num <= 0) { LOG(ERROR) << "server_num must be positive"; diff --git a/example/nshead_extension_c++/CMakeLists.txt b/example/nshead_extension_c++/CMakeLists.txt index 5aa496ac63..244bca6876 100644 --- a/example/nshead_extension_c++/CMakeLists.txt +++ b/example/nshead_extension_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/nshead_extension_c++/client.cpp b/example/nshead_extension_c++/client.cpp index b5263d5286..bfc48b6f7e 100644 --- a/example/nshead_extension_c++/client.cpp +++ b/example/nshead_extension_c++/client.cpp @@ -35,7 +35,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/nshead_extension_c++/server.cpp b/example/nshead_extension_c++/server.cpp index b59c2c0442..1cbd57289c 100644 --- a/example/nshead_extension_c++/server.cpp +++ b/example/nshead_extension_c++/server.cpp @@ -51,7 +51,7 @@ class MyNsheadProtocol : public brpc::NsheadService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::Server server; brpc::ServerOptions options; diff --git a/example/nshead_pb_extension_c++/CMakeLists.txt b/example/nshead_pb_extension_c++/CMakeLists.txt index 0516a9ebe6..b630294965 100644 --- a/example/nshead_pb_extension_c++/CMakeLists.txt +++ b/example/nshead_pb_extension_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/nshead_pb_extension_c++/client.cpp b/example/nshead_pb_extension_c++/client.cpp index b5263d5286..bfc48b6f7e 100644 --- a/example/nshead_pb_extension_c++/client.cpp +++ b/example/nshead_pb_extension_c++/client.cpp @@ -35,7 +35,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/nshead_pb_extension_c++/server.cpp b/example/nshead_pb_extension_c++/server.cpp index 4f67ecd8a6..d87c9a2743 100644 --- a/example/nshead_pb_extension_c++/server.cpp +++ b/example/nshead_pb_extension_c++/server.cpp @@ -97,7 +97,7 @@ class MyNsheadProtocol : public brpc::NsheadPbServiceAdaptor { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::Server server; example::EchoServiceImpl echo_service_impl; diff --git a/example/parallel_echo_c++/CMakeLists.txt b/example/parallel_echo_c++/CMakeLists.txt index b70d7571be..7cdb412ae5 100644 --- a/example/parallel_echo_c++/CMakeLists.txt +++ b/example/parallel_echo_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/parallel_echo_c++/client.cpp b/example/parallel_echo_c++/client.cpp index 933e2b655a..54ce661dd8 100644 --- a/example/parallel_echo_c++/client.cpp +++ b/example/parallel_echo_c++/client.cpp @@ -94,7 +94,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/parallel_echo_c++/server.cpp b/example/parallel_echo_c++/server.cpp index 364b29ed61..c57e0011ce 100644 --- a/example/parallel_echo_c++/server.cpp +++ b/example/parallel_echo_c++/server.cpp @@ -52,7 +52,7 @@ class EchoServiceImpl : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/partition_echo_c++/CMakeLists.txt b/example/partition_echo_c++/CMakeLists.txt index 2e09c388ca..4d845c724e 100644 --- a/example/partition_echo_c++/CMakeLists.txt +++ b/example/partition_echo_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/partition_echo_c++/client.cpp b/example/partition_echo_c++/client.cpp index 83fa001e7a..b60a63d032 100644 --- a/example/partition_echo_c++/client.cpp +++ b/example/partition_echo_c++/client.cpp @@ -123,7 +123,7 @@ class MyPartitionParser : public brpc::PartitionParser { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/partition_echo_c++/server.cpp b/example/partition_echo_c++/server.cpp index 4c2053f832..aa65d41b7a 100644 --- a/example/partition_echo_c++/server.cpp +++ b/example/partition_echo_c++/server.cpp @@ -94,7 +94,7 @@ class EchoServiceImpl : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_server_num <= 0) { LOG(ERROR) << "server_num must be positive"; diff --git a/example/rdma_performance/CMakeLists.txt b/example/rdma_performance/CMakeLists.txt index de730720be..2812b0b03b 100644 --- a/example/rdma_performance/CMakeLists.txt +++ b/example/rdma_performance/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,7 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS} -DBRPC_WITH_RDMA=1") +set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_RDMA=1") set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/rdma_performance/client.cpp b/example/rdma_performance/client.cpp index e6013b55ca..57d0c06c93 100644 --- a/example/rdma_performance/client.cpp +++ b/example/rdma_performance/client.cpp @@ -272,7 +272,7 @@ void Test(int thread_num, int attachment_size) { } int main(int argc, char* argv[]) { - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Initialize RDMA environment in advance. if (FLAGS_use_rdma) { diff --git a/example/rdma_performance/server.cpp b/example/rdma_performance/server.cpp index 9920cbb24d..d3d00057f4 100644 --- a/example/rdma_performance/server.cpp +++ b/example/rdma_performance/server.cpp @@ -63,7 +63,7 @@ class PerfTestServiceImpl : public PerfTestService { } int main(int argc, char* argv[]) { - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::Server server; test::PerfTestServiceImpl perf_test_service_impl; diff --git a/example/redis_c++/CMakeLists.txt b/example/redis_c++/CMakeLists.txt index fc4745c872..e29dcbeb45 100644 --- a/example/redis_c++/CMakeLists.txt +++ b/example/redis_c++/CMakeLists.txt @@ -67,16 +67,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -85,8 +75,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/redis_c++/redis_cli.cpp b/example/redis_c++/redis_cli.cpp index d4cbf63a95..02124aa34e 100644 --- a/example/redis_c++/redis_cli.cpp +++ b/example/redis_c++/redis_cli.cpp @@ -77,7 +77,7 @@ static int cli_getc(FILE *stream) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/redis_c++/redis_press.cpp b/example/redis_c++/redis_press.cpp index 7c4e5a5c9b..165b8bf1f9 100644 --- a/example/redis_c++/redis_press.cpp +++ b/example/redis_c++/redis_press.cpp @@ -97,7 +97,7 @@ static void* sender(void* void_args) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/rpcz_echo_c++/CMakeLists.txt b/example/rpcz_echo_c++/CMakeLists.txt index e377acc1d1..d1f1d924be 100644 --- a/example/rpcz_echo_c++/CMakeLists.txt +++ b/example/rpcz_echo_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/rpcz_echo_c++/client.cpp b/example/rpcz_echo_c++/client.cpp index ad80de0f50..8cb86866fe 100644 --- a/example/rpcz_echo_c++/client.cpp +++ b/example/rpcz_echo_c++/client.cpp @@ -37,7 +37,7 @@ DEFINE_int32(interval_ms, 1000, "Milliseconds between consecutive requests"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // brpc::FLAGS_enable_rpcz = true; // A Channel represents a communication line to a Server. Notice that diff --git a/example/rpcz_echo_c++/server.cpp b/example/rpcz_echo_c++/server.cpp index 0f5f7f26f5..8503e99583 100644 --- a/example/rpcz_echo_c++/server.cpp +++ b/example/rpcz_echo_c++/server.cpp @@ -132,7 +132,7 @@ class EchoServiceImpl : public EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/selective_echo_c++/CMakeLists.txt b/example/selective_echo_c++/CMakeLists.txt index 4931121821..809bd22a59 100644 --- a/example/selective_echo_c++/CMakeLists.txt +++ b/example/selective_echo_c++/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/selective_echo_c++/client.cpp b/example/selective_echo_c++/client.cpp index 99f9f0fd52..6f0c413a2b 100644 --- a/example/selective_echo_c++/client.cpp +++ b/example/selective_echo_c++/client.cpp @@ -86,7 +86,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/selective_echo_c++/server.cpp b/example/selective_echo_c++/server.cpp index cd075ac7a8..0705a32890 100644 --- a/example/selective_echo_c++/server.cpp +++ b/example/selective_echo_c++/server.cpp @@ -93,7 +93,7 @@ class EchoServiceImpl : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_server_num <= 0) { LOG(ERROR) << "server_num must be positive"; diff --git a/example/session_data_and_thread_local/CMakeLists.txt b/example/session_data_and_thread_local/CMakeLists.txt index ea1c838174..27f60e58ac 100644 --- a/example/session_data_and_thread_local/CMakeLists.txt +++ b/example/session_data_and_thread_local/CMakeLists.txt @@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") if(CMAKE_VERSION VERSION_LESS "3.1.3") diff --git a/example/session_data_and_thread_local/client.cpp b/example/session_data_and_thread_local/client.cpp index f0cc9892a4..f075e70451 100644 --- a/example/session_data_and_thread_local/client.cpp +++ b/example/session_data_and_thread_local/client.cpp @@ -85,7 +85,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/session_data_and_thread_local/server.cpp b/example/session_data_and_thread_local/server.cpp index 5d5efc1c71..c196c33edc 100644 --- a/example/session_data_and_thread_local/server.cpp +++ b/example/session_data_and_thread_local/server.cpp @@ -211,7 +211,7 @@ void AsyncJob::run() { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // The factory to create MySessionLocalData. Must be valid when server is running. MySessionLocalDataFactory session_local_data_factory; diff --git a/example/streaming_batch_echo_c++/CMakeLists.txt b/example/streaming_batch_echo_c++/CMakeLists.txt index 1d152ef9a0..c434067257 100644 --- a/example/streaming_batch_echo_c++/CMakeLists.txt +++ b/example/streaming_batch_echo_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/streaming_batch_echo_c++/client.cpp b/example/streaming_batch_echo_c++/client.cpp index ea58a191b8..23f2b06d3a 100644 --- a/example/streaming_batch_echo_c++/client.cpp +++ b/example/streaming_batch_echo_c++/client.cpp @@ -55,7 +55,7 @@ class StreamClientReceiver : public brpc::StreamInputHandler { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/streaming_batch_echo_c++/server.cpp b/example/streaming_batch_echo_c++/server.cpp index 3690344a8f..88ea8981de 100644 --- a/example/streaming_batch_echo_c++/server.cpp +++ b/example/streaming_batch_echo_c++/server.cpp @@ -91,7 +91,7 @@ class StreamingBatchEchoService : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/streaming_echo_c++/CMakeLists.txt b/example/streaming_echo_c++/CMakeLists.txt index ebefaf4f06..571991e0b4 100644 --- a/example/streaming_echo_c++/CMakeLists.txt +++ b/example/streaming_echo_c++/CMakeLists.txt @@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) endif() include_directories(${GFLAGS_INCLUDE_PATH}) -execute_process( - COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS -) -if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") - execute_process( - COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" - OUTPUT_VARIABLE GFLAGS_NS - ) -endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") include(CheckFunctionExists) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) @@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") if(CMAKE_VERSION VERSION_LESS "3.1.3") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/example/streaming_echo_c++/client.cpp b/example/streaming_echo_c++/client.cpp index d593625138..619f579a61 100644 --- a/example/streaming_echo_c++/client.cpp +++ b/example/streaming_echo_c++/client.cpp @@ -31,7 +31,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/example/streaming_echo_c++/server.cpp b/example/streaming_echo_c++/server.cpp index 072105c70a..808d88d03b 100644 --- a/example/streaming_echo_c++/server.cpp +++ b/example/streaming_echo_c++/server.cpp @@ -82,7 +82,7 @@ class StreamingEchoService : public example::EchoService { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // Generally you only need one Server. brpc::Server server; diff --git a/example/thrift_extension_c++/client2.cpp b/example/thrift_extension_c++/client2.cpp index 276dbac065..c6caa0a890 100644 --- a/example/thrift_extension_c++/client2.cpp +++ b/example/thrift_extension_c++/client2.cpp @@ -79,7 +79,7 @@ static void* sender(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program. diff --git a/tools/BUILD b/tools/BUILD index a836cb0449..3abad2412c 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -25,7 +25,6 @@ COPTS = [ "-fPIC", "-Wno-unused-parameter", "-fno-omit-frame-pointer", - "-DGFLAGS_NS=google", ] + select({ "//bazel/config:brpc_with_glog": ["-DBRPC_WITH_GLOG=1"], "//conditions:default": ["-DBRPC_WITH_GLOG=0"], diff --git a/tools/parallel_http/parallel_http.cpp b/tools/parallel_http/parallel_http.cpp index 6b863e0b63..24ae855cde 100644 --- a/tools/parallel_http/parallel_http.cpp +++ b/tools/parallel_http/parallel_http.cpp @@ -99,7 +99,7 @@ void* access_thread(void* void_args) { int main(int argc, char** argv) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // if (FLAGS_path.empty() || FLAGS_path[0] != '/') { // FLAGS_path = "/" + FLAGS_path; diff --git a/tools/rpc_press/rpc_press.cpp b/tools/rpc_press/rpc_press.cpp index 997a9fb03c..cb69ccfc16 100644 --- a/tools/rpc_press/rpc_press.cpp +++ b/tools/rpc_press/rpc_press.cpp @@ -97,7 +97,7 @@ bool set_press_options(pbrpcframework::PressOptions* options){ int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); // set global log option if (FLAGS_dummy_port >= 0) { diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp index 2065c238e5..c3cd7c4c3a 100644 --- a/tools/rpc_replay/rpc_replay.cpp +++ b/tools/rpc_replay/rpc_replay.cpp @@ -217,7 +217,7 @@ static void* replay_thread(void* arg) { int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_dir.empty() || !butil::DirectoryExists(butil::FilePath(FLAGS_dir))) { diff --git a/tools/rpc_view/rpc_view.cpp b/tools/rpc_view/rpc_view.cpp index 51de9150da..cdfb523d14 100644 --- a/tools/rpc_view/rpc_view.cpp +++ b/tools/rpc_view/rpc_view.cpp @@ -82,13 +82,13 @@ class ViewServiceImpl : public ViewService { const std::string* newtarget = server_cntl->http_request().uri().GetQuery("changetarget"); if (newtarget) { - if (GFLAGS_NS::SetCommandLineOption("target", newtarget->c_str()).empty()) { + if (GFLAGS_NAMESPACE::SetCommandLineOption("target", newtarget->c_str()).empty()) { server_cntl->SetFailed("Fail to change value of -target"); return; } target = *newtarget; } else { - if (!GFLAGS_NS::GetCommandLineOption("target", &target)) { + if (!GFLAGS_NAMESPACE::GetCommandLineOption("target", &target)) { server_cntl->SetFailed("Fail to get value of -target"); return; } @@ -153,15 +153,15 @@ class ViewServiceImpl : public ViewService { }; int main(int argc, char* argv[]) { - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_target.empty() && (argc != 2 || - GFLAGS_NS::SetCommandLineOption("target", argv[1]).empty())) { + GFLAGS_NAMESPACE::SetCommandLineOption("target", argv[1]).empty())) { LOG(ERROR) << "Usage: ./rpc_view :"; return -1; } // This keeps ad-hoc creation of channels reuse previous connections. - GFLAGS_NS::SetCommandLineOption("defer_close_second", "10"); + GFLAGS_NAMESPACE::SetCommandLineOption("defer_close_second", "10"); brpc::Server server; server.set_version("rpc_view_server"); diff --git a/tools/trackme_server/trackme_server.cpp b/tools/trackme_server/trackme_server.cpp index 541f544a98..76e09da9ea 100644 --- a/tools/trackme_server/trackme_server.cpp +++ b/tools/trackme_server/trackme_server.cpp @@ -88,7 +88,7 @@ class TrackMeServiceImpl : public brpc::TrackMeService { }; int main(int argc, char* argv[]) { - GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); + GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); brpc::Server server; server.set_version("trackme_server"); From 041cec5fb84a5b4458bac6275ea7d34e048bc3f1 Mon Sep 17 00:00:00 2001 From: Bright Chen <1021774709@qq.com> Date: Sun, 19 Jan 2025 21:57:57 +0800 Subject: [PATCH 6/6] Release 1.12.1 --- CMakeLists.txt | 2 +- MODULE.bazel | 2 +- RELEASE_VERSION | 2 +- package/rpm/brpc.spec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afc2de4d31..30076bf26e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) endif() -set(BRPC_VERSION 1.12.0) +set(BRPC_VERSION 1.12.1) SET(CPACK_GENERATOR "DEB") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "brpc authors") diff --git a/MODULE.bazel b/MODULE.bazel index e041b67a03..07955f2565 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = 'brpc', - version = '1.12.0', + version = '1.12.1', compatibility_level = 1, ) diff --git a/RELEASE_VERSION b/RELEASE_VERSION index 0eed1a29ef..f8f4f03b3d 100644 --- a/RELEASE_VERSION +++ b/RELEASE_VERSION @@ -1 +1 @@ -1.12.0 +1.12.1 diff --git a/package/rpm/brpc.spec b/package/rpm/brpc.spec index 4348347426..85eb549d0f 100644 --- a/package/rpm/brpc.spec +++ b/package/rpm/brpc.spec @@ -18,7 +18,7 @@ # Name: brpc -Version: 1.12.0 +Version: 1.12.1 Release: 1%{?dist} Summary: Industrial-grade RPC framework using C++ Language.