[brpc] branch master updated: remove unnecessary libthriftnb

2023-07-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 2a42a262 remove unnecessary libthriftnb
 new 46159064 Merge pull request #2325 from day253/thrift
2a42a262 is described below

commit 2a42a262962263c2e33090721a48b0362a79fb0b
Author: day253 <9634619+day...@users.noreply.github.com>
AuthorDate: Mon Jul 24 00:12:32 2023 +0800

remove unnecessary libthriftnb
---
 CMakeLists.txt   |  1 -
 example/asynchronous_echo_c++/CMakeLists.txt |  5 -
 example/auto_concurrency_limiter/CMakeLists.txt  |  1 -
 example/backup_request_c++/CMakeLists.txt|  5 -
 example/cancel_c++/CMakeLists.txt|  5 -
 example/cascade_echo_c++/CMakeLists.txt  |  5 -
 example/dynamic_partition_echo_c++/CMakeLists.txt|  5 -
 example/echo_c++/CMakeLists.txt  |  5 -
 example/grpc_c++/CMakeLists.txt  |  1 -
 example/http_c++/CMakeLists.txt  |  5 -
 example/memcache_c++/CMakeLists.txt  |  5 -
 example/multi_threaded_echo_c++/CMakeLists.txt   |  5 -
 example/multi_threaded_echo_fns_c++/CMakeLists.txt   |  5 -
 example/nshead_extension_c++/CMakeLists.txt  |  5 -
 example/nshead_pb_extension_c++/CMakeLists.txt   |  5 -
 example/parallel_echo_c++/CMakeLists.txt |  5 -
 example/partition_echo_c++/CMakeLists.txt|  5 -
 example/rdma_performance/CMakeLists.txt  |  5 -
 example/redis_c++/CMakeLists.txt |  5 -
 example/selective_echo_c++/CMakeLists.txt|  5 -
 example/session_data_and_thread_local/CMakeLists.txt |  5 -
 example/streaming_echo_c++/CMakeLists.txt|  5 -
 src/CMakeLists.txt   | 10 +-
 23 files changed, 5 insertions(+), 103 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ac815d6..9328f21b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,7 +224,6 @@ set(DYNAMIC_LIB
 ${PROTOC_LIB}
 ${CMAKE_THREAD_LIBS_INIT}
 ${THRIFT_LIB}
-${THRIFTNB_LIB}
 ${OPENSSL_CRYPTO_LIBRARY}
 dl
 z)
diff --git a/example/asynchronous_echo_c++/CMakeLists.txt 
b/example/asynchronous_echo_c++/CMakeLists.txt
index 4a118b19..1c8da4e5 100644
--- a/example/asynchronous_echo_c++/CMakeLists.txt
+++ b/example/asynchronous_echo_c++/CMakeLists.txt
@@ -39,10 +39,6 @@ find_library(THRIFT_LIB NAMES thrift)
 if (NOT THRIFT_LIB)
 set(THRIFT_LIB "")
 endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-set(THRIFTNB_LIB "")
-endif()
 
 find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
 if(LINK_SO)
@@ -119,7 +115,6 @@ set(DYNAMIC_LIB
 ${OPENSSL_CRYPTO_LIBRARY}
 ${OPENSSL_SSL_LIBRARY}
 ${THRIFT_LIB}
-${THRIFTNB_LIB}
 dl
 )
 
diff --git a/example/auto_concurrency_limiter/CMakeLists.txt 
b/example/auto_concurrency_limiter/CMakeLists.txt
index 88b78427..213b357b 100644
--- a/example/auto_concurrency_limiter/CMakeLists.txt
+++ b/example/auto_concurrency_limiter/CMakeLists.txt
@@ -108,7 +108,6 @@ set(DYNAMIC_LIB
 ${OPENSSL_CRYPTO_LIBRARY}
 ${OPENSSL_SSL_LIBRARY}
 ${THRIFT_LIB}
-${THRIFTNB_LIB}
 dl
 )
 
diff --git a/example/backup_request_c++/CMakeLists.txt 
b/example/backup_request_c++/CMakeLists.txt
index fc39ba3c..5a520a4d 100644
--- a/example/backup_request_c++/CMakeLists.txt
+++ b/example/backup_request_c++/CMakeLists.txt
@@ -39,10 +39,6 @@ find_library(THRIFT_LIB NAMES thrift)
 if (NOT THRIFT_LIB)
 set(THRIFT_LIB "")
 endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-set(THRIFTNB_LIB "")
-endif()
 
 find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
 if(LINK_SO)
@@ -119,7 +115,6 @@ set(DYNAMIC_LIB
 ${OPENSSL_CRYPTO_LIBRARY}
 ${OPENSSL_SSL_LIBRARY}
 ${THRIFT_LIB}
-${THRIFTNB_LIB}
 dl
 )
 
diff --git a/example/cancel_c++/CMakeLists.txt 
b/example/cancel_c++/CMakeLists.txt
index ea611e03..c8f4d7f3 100644
--- a/example/cancel_c++/CMakeLists.txt
+++ b/example/cancel_c++/CMakeLists.txt
@@ -39,10 +39,6 @@ find_library(THRIFT_LIB NAMES thrift)
 if (NOT THRIFT_LIB)
 set(THRIFT_LIB "")
 endif()
-find_library(THRIFTNB_LIB NAMES thriftnb)
-if (NOT THRIFTNB_LIB)
-set(THRIFTNB_LIB "")
-endif()
 
 find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
 if(LINK_SO)
@@ -119,7 +115,6 @@ set(DYNAMIC_LIB
 ${OPENSSL_CRYPTO_LIBRARY}
 ${OPENSSL_SSL_LIBRARY}
 ${THRIFT_LIB}
-${THRIFTNB_LIB}
 dl
 )
 
diff --git a/example/cascade_echo_c++/CMakeLists.txt 
b/example/cascade_echo_c++/CMakeLists.txt
index 6ca2e25d..56248abd 100644
--- a/example/cascade_echo_c++/CMakeLists

[brpc] branch master updated (b36ce2c3 -> f504c77d)

2023-06-07 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


from b36ce2c3 Log function name (#2247)
 add d1a2fcfd + Add graceful exit for SIGHUP
 new f504c77d Merge pull request #2272 from apache/graceful-quit-on-sighup

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/controller.cpp | 20 
 1 file changed, 20 insertions(+)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[brpc] 01/01: Merge pull request #2272 from apache/graceful-quit-on-sighup

2023-06-07 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git

commit f504c77dd847e302c23a0097b12465a27507b6cf
Merge: b36ce2c3 d1a2fcfd
Author: jamesge 
AuthorDate: Wed Jun 7 23:04:58 2023 +0800

Merge pull request #2272 from apache/graceful-quit-on-sighup

Add graceful exit GFLAG for SIGHUP

 src/brpc/controller.cpp | 20 
 1 file changed, 20 insertions(+)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[brpc] branch master updated: reject initializing FlatMap when nbucket is 0

2023-03-17 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 1be060d5 reject initializing FlatMap when nbucket is 0
1be060d5 is described below

commit 1be060d57e2693b437fb4a7a774840d23e685fe4
Author: gejun.0 
AuthorDate: Sat Mar 18 13:25:34 2023 +0800

reject initializing FlatMap when nbucket is 0
---
 src/butil/containers/flat_map_inl.h |  8 -
 test/brpc_channel_unittest.cpp  | 68 ++---
 test/flat_map_unittest.cpp  | 55 +++---
 3 files changed, 84 insertions(+), 47 deletions(-)

diff --git a/src/butil/containers/flat_map_inl.h 
b/src/butil/containers/flat_map_inl.h
index 3bd64e64..f79fcb86 100644
--- a/src/butil/containers/flat_map_inl.h
+++ b/src/butil/containers/flat_map_inl.h
@@ -41,6 +41,7 @@ inline uint32_t find_next_prime(uint32_t nbucket) {
 return nbucket;
 }
 
+// NOTE: find_power2(0) = 0
 inline uint64_t find_power2(uint64_t b) {
 b -= 1;
 b |= (b >> 1);
@@ -61,7 +62,8 @@ inline size_t flatmap_round(size_t nbucket) {
 #ifdef FLAT_MAP_ROUND_BUCKET_BY_USE_NEXT_PRIME
 return find_next_prime(nbucket);
 #else
-return find_power2(nbucket);
+// the lowerbound fixes the corner case of nbucket=0 which results in 
coredump during seeking the map.
+return nbucket <= 8 ? 8 : find_power2(nbucket);
 #endif
 }
 
@@ -328,6 +330,10 @@ int FlatMap<_K, _T, _H, _E, _S, _A>::init(size_t nbucket, 
u_int load_factor) {
 LOG(ERROR) << "Already initialized";
 return -1;
 }
+if (nbucket == 0) {
+LOG(WARNING) << "Fail to init FlatMap, nbucket=" << nbucket; 
+return -1;
+}
 if (load_factor < 10 || load_factor > 100) {
 LOG(ERROR) << "Invalid load_factor=" << load_factor;
 return -1;
diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp
index 644e983b..4de8e350 100644
--- a/test/brpc_channel_unittest.cpp
+++ b/test/brpc_channel_unittest.cpp
@@ -1981,46 +1981,46 @@ TEST_F(ChannelTest, parse_hostname) {
 ASSERT_EQ(0, channel.Init("localhost:", ));
 ASSERT_EQ("localhost:", channel._service_name);
 
-ASSERT_EQ(0, channel.Init("http://baidu.com;, ));
-ASSERT_EQ("baidu.com", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com:80;, ));
-ASSERT_EQ("baidu.com:80", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com;, 80, ));
-ASSERT_EQ("baidu.com:80", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com:;, ));
-ASSERT_EQ("baidu.com:", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com;, , ));
-ASSERT_EQ("baidu.com:", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com;, "rr", ));
-ASSERT_EQ("baidu.com", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com:80;, "rr", ));
-ASSERT_EQ("baidu.com:80", channel._service_name);
-ASSERT_EQ(0, channel.Init("http://baidu.com:;, "rr", ));
-ASSERT_EQ("baidu.com:", channel._service_name);
-
-ASSERT_EQ(0, channel.Init("https://baidu.com;, ));
-ASSERT_EQ("baidu.com", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com:443;, ));
-ASSERT_EQ("baidu.com:443", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com;, 443, ));
-ASSERT_EQ("baidu.com:443", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com:1443;, ));
-ASSERT_EQ("baidu.com:1443", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com;, 1443, ));
-ASSERT_EQ("baidu.com:1443", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com;, "rr", ));
-ASSERT_EQ("baidu.com", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com:443;, "rr", ));
-ASSERT_EQ("baidu.com:443", channel._service_name);
-ASSERT_EQ(0, channel.Init("https://baidu.com:1443;, "rr", ));
-ASSERT_EQ("baidu.com:1443", channel._service_name);
+ASSERT_EQ(0, channel.Init("http://www.baidu.com;, ));
+ASSERT_EQ("www.baidu.com", channel._service_name);
+ASSERT_EQ(0, channel.Init("http://www.baidu.com:80;, ));
+ASSERT_EQ("www.baidu.com:80", channel._service_name);
+ASSERT_EQ(0, channel.Init("http://www.baidu.com;, 80, ));
+ASSERT_EQ("www.baidu.com:80", channel._service_name);
+ASS

[brpc] branch master updated (2ec8f469 -> 3b0a96e6)

2023-03-09 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


from 2ec8f469 fix gtest build cmd in doc (#2154)
 add a92d74f9 Add _Alloc template parameters for FlatMap and FlatSet
 add 6c93f7ae + Remove allocator inside FlatMap and reuse the one in _pool
 new 3b0a96e6 Merge pull request #2149 from apache/addallocator

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/butil/containers/flat_map.h | 24 ++---
 src/butil/containers/flat_map_inl.h | 98 +++--
 src/butil/single_threaded_pool.h| 19 +--
 3 files changed, 82 insertions(+), 59 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[brpc] 01/01: Merge pull request #2149 from apache/addallocator

2023-03-09 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git

commit 3b0a96e684daa2b43eb351dccc749f3c4be1af15
Merge: 2ec8f469 6c93f7ae
Author: jamesge 
AuthorDate: Thu Mar 9 18:02:45 2023 +0800

Merge pull request #2149 from apache/addallocator

Add _Alloc template parameters for FlatMap and FlatSet

 src/butil/containers/flat_map.h | 24 ++---
 src/butil/containers/flat_map_inl.h | 98 +++--
 src/butil/single_threaded_pool.h| 19 +--
 3 files changed, 82 insertions(+), 59 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[brpc] branch master updated (ef469983 -> 60b9acaf)

2023-02-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


from ef469983 naming timer sampling and worker threads (#2136)
 new a6151a5c feat: dns resolve support ipv6
 new 776f9d99 feat: use sockaddr2endpoint resolve ipv6
 new 60b9acaf Merge pull request #2139 from jsl422/dnsipv6

The 2912 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/policy/domain_naming_service.cpp | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: FlatMap's value supports unique_ptr

2022-12-12 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 50e41d0a FlatMap's value supports unique_ptr
50e41d0a is described below

commit 50e41d0a0b36634b4f275d2bc204ed3ec908bcde
Author: gejun.0 
AuthorDate: Tue Dec 13 10:47:38 2022 +0800

FlatMap's value supports unique_ptr
---
 src/butil/containers/flat_map.h | 8 
 src/butil/containers/flat_map_inl.h | 8 
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/butil/containers/flat_map.h b/src/butil/containers/flat_map.h
index 6f2deafe..6789c3c7 100644
--- a/src/butil/containers/flat_map.h
+++ b/src/butil/containers/flat_map.h
@@ -361,11 +361,15 @@ public:
 // ^^^
 const K& first_ref() const { return _key; }
 T& second_ref() { return _value; }
+T&& second_movable_ref() { return std::move(_value); }
 value_type& value_ref() { return *reinterpret_cast(this); }
 inline static const K& first_ref_from_value(const value_type& v)
 { return v.first; }
 inline static const T& second_ref_from_value(const value_type& v)
 { return v.second; }
+inline static T&& second_movable_ref_from_value(value_type& v)
+{ return std::move(v.second); }
+
 private:
 const K _key;
 T _value;
@@ -378,12 +382,16 @@ public:
 explicit FlatMapElement(const K& k) : _key(k) {}
 const K& first_ref() const { return _key; }
 FlatMapVoid& second_ref() { return second_ref_from_value(_key); }
+FlatMapVoid& second_movable_ref() { return second_ref(); }
 value_type& value_ref() { return _key; }
 inline static const K& first_ref_from_value(value_type& v) { return v; }
 inline static FlatMapVoid& second_ref_from_value(value_type&) {
 static FlatMapVoid dummy;
 return dummy;
 }
+inline static const FlatMapVoid& second_movable_ref_from_value(value_type& 
v) {
+return second_ref_from_value(v);
+}
 private:
 K _key;
 };
diff --git a/src/butil/containers/flat_map_inl.h 
b/src/butil/containers/flat_map_inl.h
index ad5598c2..e98c88b5 100644
--- a/src/butil/containers/flat_map_inl.h
+++ b/src/butil/containers/flat_map_inl.h
@@ -394,7 +394,7 @@ size_t FlatMap<_K, _T, _H, _E, _S>::erase(const K2& key, 
_T* old_value) {
 }
 if (_eql(first_node.element().first_ref(), key)) {
 if (old_value) {
-*old_value = first_node.element().second_ref();
+*old_value = first_node.element().second_movable_ref();
 }
 if (first_node.next == NULL) {
 first_node.element().~Element();
@@ -420,7 +420,7 @@ size_t FlatMap<_K, _T, _H, _E, _S>::erase(const K2& key, 
_T* old_value) {
 first_node.next = p->next;
 const_cast<_K&>(first_node.element().first_ref()) =
 p->element().first_ref();
-first_node.element().second_ref() = p->element().second_ref();
+first_node.element().second_ref() = 
p->element().second_movable_ref();
 p->element().~Element();
 _pool.back(p);
 }
@@ -432,7 +432,7 @@ size_t FlatMap<_K, _T, _H, _E, _S>::erase(const K2& key, 
_T* old_value) {
 while (p) {
 if (_eql(p->element().first_ref(), key)) {
 if (old_value) {
-*old_value = p->element().second_ref();
+*old_value = p->element().second_movable_ref();
 }
 last_p->next = p->next;
 p->element().~Element();
@@ -616,7 +616,7 @@ bool FlatMap<_K, _T, _H, _E, _S>::resize(size_t nbucket2) {
 }
 for (iterator it = begin(); it != end(); ++it) {
 new_map[Element::first_ref_from_value(*it)] = 
-Element::second_ref_from_value(*it);
+Element::second_movable_ref_from_value(*it);
 }
 new_map.swap(*this);
 return true;


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (d0052a60 -> b7883255)

2022-11-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


from d0052a60 Early return for IOBuf::append_user_data when size == 0 
(#2009)
 add 5b62c4e5 - Make BUTIL_RAPIDJSON_NAMESPACE_BEGIN::GenericDocument's 
handler method public to enable outside custom parser/writer
 new b7883255 Merge pull request #2026 from apache/custom-rapidjson

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/butil/third_party/rapidjson/document.h | 13 +
 1 file changed, 13 insertions(+)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/01: Merge pull request #2026 from apache/custom-rapidjson

2022-11-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit b788325528d886639e66aa0d46c571c163ec959a
Merge: d0052a60 5b62c4e5
Author: jamesge 
AuthorDate: Tue Nov 29 11:41:02 2022 +0800

Merge pull request #2026 from apache/custom-rapidjson

Make GenericDocument's handler public to enable ouside parser/writer

 src/butil/third_party/rapidjson/document.h | 13 +
 1 file changed, 13 insertions(+)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Refresh write timestamp when returning a Socket to its pool; change default value of -idle_timeout_second to 30

2022-11-13 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new c3d58348 Refresh write timestamp when returning a Socket to its pool; 
change default value of -idle_timeout_second to 30
c3d58348 is described below

commit c3d583484615bbc9424d634d08c7e9c4805825fd
Author: gejun.0 
AuthorDate: Mon Nov 14 14:18:48 2022 +0800

Refresh write timestamp when returning a Socket to its pool; change default 
value of -idle_timeout_second to 30
---
 src/brpc/socket.cpp | 4 
 src/brpc/socket_map.cpp | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp
index b477127a..e5097f90 100644
--- a/src/brpc/socket.cpp
+++ b/src/brpc/socket.cpp
@@ -2594,6 +2594,10 @@ int Socket::ReturnToPool() {
 // - sp must be released after returning to pool because it owns pool
 _connection_type_for_progressive_read = CONNECTION_TYPE_UNKNOWN;
 _controller_released_socket.store(false, butil::memory_order_relaxed);
+// Reset the write timestamp to make the returned connection live (longer)
+// This is useful for using a fake Socket + SocketConnection impl. to 
integrate
+// 3rd-party client into bRPC (like MySQL Client).
+_last_writetime_us.store(butil::cpuwide_time_us(), 
butil::memory_order_relaxed);
 pool->ReturnSocket(this);
 sp->RemoveRefManually();
 return 0;
diff --git a/src/brpc/socket_map.cpp b/src/brpc/socket_map.cpp
index 512e70a7..d169afd8 100644
--- a/src/brpc/socket_map.cpp
+++ b/src/brpc/socket_map.cpp
@@ -35,7 +35,7 @@ DEFINE_int32(health_check_interval, 3,
 // NOTE: Must be limited to positive to guarantee correctness of 
SocketMapRemove.
 BRPC_VALIDATE_GFLAG(health_check_interval, PositiveInteger);
 
-DEFINE_int32(idle_timeout_second, 10, 
+DEFINE_int32(idle_timeout_second, 30, 
  "Pooled connections without data transmission for so many "
  "seconds will be closed. No effect for non-positive values");
 BRPC_VALIDATE_GFLAG(idle_timeout_second, PassValidate);


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add a flag to manage http body on error

2022-11-08 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new cc629b60 add a flag to manage http body on error
cc629b60 is described below

commit cc629b60450335665deb8d475c6ea970d93226ef
Author: gejun.0 
AuthorDate: Wed Nov 9 12:53:33 2022 +0800

add a flag to manage http body on error
---
 src/brpc/controller.h | 11 +++
 src/brpc/policy/http_rpc_protocol.cpp | 18 +++---
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index 41f1267d..658cc695 100644
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -143,6 +143,7 @@ friend void policy::ProcessThriftRequest(InputMessageBase*);
 static const uint32_t FLAGS_ALWAYS_PRINT_PRIMITIVE_FIELDS = (1 << 18);
 static const uint32_t FLAGS_HEALTH_CHECK_CALL = (1 << 19);
 static const uint32_t FLAGS_PB_SINGLE_REPEATED_TO_ARRAY = (1 << 20);
+static const uint32_t FLAGS_MANAGE_HTTP_BODY_ON_ERROR = (1 << 21);
 
 public:
 struct Inheritable {
@@ -398,6 +399,16 @@ public:
 // directly instead of being serialized into protobuf messages.
 butil::IOBuf& response_attachment() { return _response_attachment; }
 
+// Response Body of a failed HTTP call is set to be ErrorText() by default,
+// even if response_attachment() is non-empty.
+// If this flag is true, the http body of a failed HTTP call will not be
+// replaced by ErrorText() and should be managed by user self.
+void manage_http_body_on_error(bool manage_or_not)
+{ set_flag(FLAGS_MANAGE_HTTP_BODY_ON_ERROR, manage_or_not); }
+
+bool does_manage_http_body_on_error() const
+{ return has_flag(FLAGS_MANAGE_HTTP_BODY_ON_ERROR); }
+
 // Create a ProgressiveAttachment to write (often after RPC).
 // If `stop_style' is FORCE_STOP, the underlying socket will be failed
 // immediately when the socket becomes idle or server is stopped.
diff --git a/src/brpc/policy/http_rpc_protocol.cpp 
b/src/brpc/policy/http_rpc_protocol.cpp
index 6e32598f..6927e377 100644
--- a/src/brpc/policy/http_rpc_protocol.cpp
+++ b/src/brpc/policy/http_rpc_protocol.cpp
@@ -847,7 +847,9 @@ HttpResponseSender::~HttpResponseSender() {
 
 bool grpc_compressed = false;
 if (cntl->Failed()) {
-cntl->response_attachment().clear();
+if (!cntl->does_manage_http_body_on_error()) {
+cntl->response_attachment().clear();
+}
 if (!is_grpc) {
 // Set status-code with default value(converted from error code)
 // if user did not set it.
@@ -858,12 +860,14 @@ HttpResponseSender::~HttpResponseSender() {
 res_header->SetHeader(common->ERROR_CODE,
   butil::string_printf("%d", 
cntl->ErrorCode()));
 
-// Fill body with ErrorText.
-// user may compress the output and change content-encoding. 
However
-// body is error-text right now, remove the header.
-res_header->RemoveHeader(common->CONTENT_ENCODING);
-res_header->set_content_type(common->CONTENT_TYPE_TEXT);
-cntl->response_attachment().append(cntl->ErrorText());
+if (!cntl->does_manage_http_body_on_error()) {
+// Fill body with ErrorText.
+// user may compress the output and change content-encoding. 
However
+// body is error-text right now, remove the header.
+res_header->RemoveHeader(common->CONTENT_ENCODING);
+res_header->set_content_type(common->CONTENT_TYPE_TEXT);
+cntl->response_attachment().append(cntl->ErrorText());
+}
 }
 } else if (cntl->has_progressive_writer()) {
 // Transfer-Encoding is supported since HTTP/1.1


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: fix issues in FlatMap

2022-09-29 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 51bf10c2 fix issues in FlatMap
51bf10c2 is described below

commit 51bf10c214411cd490b6537659b24d91c50357fc
Author: gejun.0 
AuthorDate: Thu Sep 29 18:49:25 2022 +0800

fix issues in FlatMap
---
 src/butil/containers/flat_map_inl.h | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/butil/containers/flat_map_inl.h 
b/src/butil/containers/flat_map_inl.h
index e5948920..ad5598c2 100644
--- a/src/butil/containers/flat_map_inl.h
+++ b/src/butil/containers/flat_map_inl.h
@@ -567,10 +567,12 @@ void FlatMap<_K, _T, _H, _E, _S>::save_iterator(
 template 
 typename FlatMap<_K, _T, _H, _E, _S>::const_iterator
 FlatMap<_K, _T, _H, _E, _S>::restore_iterator(const PositionHint& hint) const {
-if (hint.nbucket != _nbucket/*resized*/ ||
-hint.offset >= _nbucket/*invalid hint*/) {
-return begin();  // restart
-}
+if (hint.nbucket != _nbucket)  // resized
+return begin(); // restart
+
+if (hint.offset >= _nbucket) // invalid hint, stop the iteration
+return end();
+
 Bucket& first_node = _buckets[hint.offset];
 if (hint.at_entry) {
 return const_iterator(this, hint.offset);
@@ -604,6 +606,10 @@ bool FlatMap<_K, _T, _H, _E, _S>::resize(size_t nbucket2) {
 }
 
 FlatMap new_map;
+// NOTE: following functors must be kept after resizing otherwise the 
+// internal state is lost.
+new_map._hashfn = _hashfn; 
+new_map._eql = _eql;
 if (new_map.init(nbucket2, _load_factor) != 0) {
 LOG(ERROR) << "Fail to init new_map, nbucket=" << nbucket2;
 return false;


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Support -escape_log

2022-08-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new df031bee Support -escape_log
df031bee is described below

commit df031bee2c5370fb471744b220259ca1a6164c4a
Author: gejun.0 
AuthorDate: Tue Aug 30 16:57:54 2022 +0800

Support -escape_log
---
 src/butil/logging.cc | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/butil/logging.cc b/src/butil/logging.cc
index 09b3ddaf..fa0dbae8 100644
--- a/src/butil/logging.cc
+++ b/src/butil/logging.cc
@@ -21,6 +21,7 @@
 
 #include 
 DEFINE_bool(log_as_json, false, "Print log as a valid JSON");
+DEFINE_bool(escape_log, false, "Escape log content before printing");
 
 #if !BRPC_WITH_GLOG
 
@@ -565,12 +566,36 @@ static void PrintLogPrefixAsJSON(
 os << "\"C\":\"" << file << ':' << line << "\"";
 }
 
+void EscapeJson(std::ostream& os, const butil::StringPiece& s) {
+for (auto it = s.begin(); it != s.end(); it++) {
+auto c = *it;
+switch (c) {
+case '"': os << "\\\""; break;
+case '\\': os << ""; break;
+case '\b': os << "\\b"; break;
+case '\f': os << "\\f"; break;
+case '\n': os << "\\n"; break;
+case '\r': os << "\\r"; break;
+case '\t': os << "\\t"; break;
+default: os << c;
+}
+}
+}
+
+inline void OutputLog(std::ostream& os, const butil::StringPiece& s) {
+if (FLAGS_escape_log) {
+EscapeJson(os, s);
+} else {
+os.write(s.data(), s.length());
+}
+}
+
 void PrintLog(std::ostream& os,
   int severity, const char* file, int line,
   const butil::StringPiece& content) {
 if (!FLAGS_log_as_json) {
 PrintLogPrefix(os, severity, file, line);
-os.write(content.data(), content.size());
+OutputLog(os, content);
 } else {
 os << '{';
 PrintLogPrefixAsJSON(os, severity, file, line);
@@ -582,7 +607,7 @@ void PrintLog(std::ostream& os,
 } else {
 os << ',';
 }
-os.write(content.data(), content.size());
+OutputLog(os, content);
 if (pair_quote) {
 os << '"';
 } else if (!content.empty() && content[content.size()-1] != '"') {


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: expose logging::PrintLog

2022-08-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 2a50c541 expose logging::PrintLog
2a50c541 is described below

commit 2a50c541114f660d6d1d99d1efa1586fc9639039
Author: gejun.0 
AuthorDate: Tue Aug 30 15:23:14 2022 +0800

expose logging::PrintLog
---
 src/butil/logging.cc | 8 
 src/butil/logging.h  | 5 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/butil/logging.cc b/src/butil/logging.cc
index 9db75cde..09b3ddaf 100644
--- a/src/butil/logging.cc
+++ b/src/butil/logging.cc
@@ -466,7 +466,7 @@ static void PrintLogSeverity(std::ostream& os, int 
severity) {
 }
 }
 
-static void PrintLogPrefix(
+void PrintLogPrefix(
 std::ostream& os, int severity, const char* file, int line) {
 PrintLogSeverity(os, severity);
 #if defined(OS_LINUX)
@@ -565,9 +565,9 @@ static void PrintLogPrefixAsJSON(
 os << "\"C\":\"" << file << ':' << line << "\"";
 }
 
-static void PrintLog(std::ostream& os,
- int severity, const char* file, int line,
- const butil::StringPiece& content) {
+void PrintLog(std::ostream& os,
+  int severity, const char* file, int line,
+  const butil::StringPiece& content) {
 if (!FLAGS_log_as_json) {
 PrintLogPrefix(os, severity, file, line);
 os.write(content.data(), content.size());
diff --git a/src/butil/logging.h b/src/butil/logging.h
index f92cd780..e2a41098 100644
--- a/src/butil/logging.h
+++ b/src/butil/logging.h
@@ -319,6 +319,11 @@ private:
 // Returns previous sink.
 BUTIL_EXPORT LogSink* SetLogSink(LogSink* sink);
 
+// Print |content| with other info into |os|.
+void PrintLog(std::ostream& os,
+  int severity, const char* file, int line,
+  const butil::StringPiece& content);
+
 // The LogSink mainly for unit-testing. Logs will be appended to it.
 class StringSink : public LogSink, public std::string {
 public:


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: minor fix

2022-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 33d4fe5a minor fix
33d4fe5a is described below

commit 33d4fe5a364574e2381d19042de640148ba174b4
Author: gejun.0 
AuthorDate: Sat Aug 27 13:17:30 2022 +0800

minor fix
---
 src/brpc/builtin/hotspots_service.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/brpc/builtin/hotspots_service.cpp 
b/src/brpc/builtin/hotspots_service.cpp
index e6bb8944..500cb759 100644
--- a/src/brpc/builtin/hotspots_service.cpp
+++ b/src/brpc/builtin/hotspots_service.cpp
@@ -410,13 +410,15 @@ static void DisplayResult(Controller* cntl,
 const std::string* base_name = cntl->http_request().uri().GetQuery("base");
 const std::string* display_type_query = 
cntl->http_request().uri().GetQuery("display_type");
 DisplayType display_type = DisplayType::kDot;
+#if defined(OS_LINUX)
+const char* flamegraph_tool = getenv("FLAMEGRAPH_PL_PATH");
+#endif
 if (display_type_query) {
 display_type = StringToDisplayType(*display_type_query);
 if (display_type == DisplayType::kUnknown) {
 return cntl->SetFailed(EINVAL, "Invalid display_type=%s", 
display_type_query->c_str());
 }
 #if defined(OS_LINUX)
-const char* flamegraph_tool = getenv("FLAMEGRAPH_PL_PATH");
 if (display_type == DisplayType::kFlameGraph && !flamegraph_tool) {
 return cntl->SetFailed(EINVAL, "Failed to find environment 
variable "
 "FLAMEGRAPH_PL_PATH, please read cpu_profiler doc"


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: fix some warnings for clang and revert changes on ALIGNAS/ALIGNOF

2022-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 261f5b23 fix some warnings for clang and revert changes on 
ALIGNAS/ALIGNOF
261f5b23 is described below

commit 261f5b23caf885f84374ed1f5695182d42909c3b
Author: gejun 
AuthorDate: Sat Aug 27 13:03:03 2022 +0800

fix some warnings for clang and revert changes on ALIGNAS/ALIGNOF
---
 src/brpc/builtin/hotspots_service.cpp |  5 +++--
 src/butil/compiler_specific.h | 24 
 test/baidu_time_unittest.cpp  |  2 +-
 test/brpc_protobuf_json_unittest.cpp  |  8 
 test/find_cstr_unittest.cpp   |  2 +-
 test/flat_map_unittest.cpp|  9 +
 test/rand_util_unittest.cc|  2 +-
 7 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/src/brpc/builtin/hotspots_service.cpp 
b/src/brpc/builtin/hotspots_service.cpp
index 9d53881a..e6bb8944 100644
--- a/src/brpc/builtin/hotspots_service.cpp
+++ b/src/brpc/builtin/hotspots_service.cpp
@@ -409,7 +409,6 @@ static void DisplayResult(Controller* cntl,
 const bool show_ccount = cntl->http_request().uri().GetQuery("ccount");
 const std::string* base_name = cntl->http_request().uri().GetQuery("base");
 const std::string* display_type_query = 
cntl->http_request().uri().GetQuery("display_type");
-const char* flamegraph_tool = getenv("FLAMEGRAPH_PL_PATH");
 DisplayType display_type = DisplayType::kDot;
 if (display_type_query) {
 display_type = StringToDisplayType(*display_type_query);
@@ -417,6 +416,7 @@ static void DisplayResult(Controller* cntl,
 return cntl->SetFailed(EINVAL, "Invalid display_type=%s", 
display_type_query->c_str());
 }
 #if defined(OS_LINUX)
+const char* flamegraph_tool = getenv("FLAMEGRAPH_PL_PATH");
 if (display_type == DisplayType::kFlameGraph && !flamegraph_tool) {
 return cntl->SetFailed(EINVAL, "Failed to find environment 
variable "
 "FLAMEGRAPH_PL_PATH, please read cpu_profiler doc"
@@ -888,7 +888,8 @@ static void StartProfiling(ProfilingType type,
 return cntl->SetFailed(EINVAL, "Invalid display_type=%s", 
display_type_query->c_str());
 }
 #if defined(OS_LINUX)
-if (display_type == DisplayType::kFlameGraph && 
!getenv("FLAMEGRAPH_PL_PATH")) {
+const char* flamegraph_tool = getenv("FLAMEGRAPH_PL_PATH");
+if (display_type == DisplayType::kFlameGraph && !flamegraph_tool) {
 return cntl->SetFailed(EINVAL, "Failed to find environment 
variable "
 "FLAMEGRAPH_PL_PATH, please read cpu_profiler doc"
 
"(https://github.com/brpc/brpc/blob/master/docs/cn/cpu_profiler.md)");
diff --git a/src/butil/compiler_specific.h b/src/butil/compiler_specific.h
index 9da98a4a..d05da9dc 100644
--- a/src/butil/compiler_specific.h
+++ b/src/butil/compiler_specific.h
@@ -124,14 +124,10 @@
 // Use like:
 //   class ALIGNAS(16) MyClass { ... }
 //   ALIGNAS(16) int array[4];
-#if defined(BUTIL_CXX11_ENABLED)
-# define ALIGNAS(byte_alignment) alignas(byte_alignment)
-#else
-# if defined(COMPILER_MSVC)
-#  define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
-# elif defined(COMPILER_GCC)
-#  define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
-# endif
+#if defined(COMPILER_MSVC)
+# define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
+#elif defined(COMPILER_GCC)
+# define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
 #endif
 
 // Return the byte alignment of the given type (available at compile time).  
Use
@@ -139,14 +135,10 @@
 // http://goo.gl/isH0C
 // Use like:
 //   ALIGNOF(int32_t)  // this would be 4
-#if defined(BUTIL_CXX11_ENABLED)
-# define ALIGNOF(type) alignof(type)
-#else
-# if defined(COMPILER_MSVC)
-#  define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type))
-# elif defined(COMPILER_GCC)
-#  define ALIGNOF(type) __alignof__(type)
-# endif
+#if defined(COMPILER_MSVC)
+# define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type))
+#elif defined(COMPILER_GCC)
+# define ALIGNOF(type) __alignof__(type)
 #endif
 
 // Annotate a virtual method indicating it must be overriding a virtual
diff --git a/test/baidu_time_unittest.cpp b/test/baidu_time_unittest.cpp
index 4af509a3..d5741895 100644
--- a/test/baidu_time_unittest.cpp
+++ b/test/baidu_time_unittest.cpp
@@ -99,7 +99,7 @@ TEST(BaiduTimeTest, cost_of_timer) {
 s += butil::monotonic_time_ns();
 }
 t1.stop();
-printf("monotonic_time_ns takes %" PRId64 "ns\n", t1.n_elapsed() / N);
+print

[incubator-brpc] branch master updated: fixes for gcc on arm64

2022-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 233f99ff fixes for gcc on arm64
 new 2f31176f Merge branch 'master' of github.com:apache/incubator-brpc
233f99ff is described below

commit 233f99ff5ed130479800dbd5821487571064be55
Author: gejun.0 
AuthorDate: Sat Aug 27 12:05:31 2022 +0800

fixes for gcc on arm64
---
 config_brpc.sh   |  9 +
 src/butil/containers/case_ignored_flat_map.h |  7 ---
 src/butil/iobuf.cpp  |  9 -
 test/Makefile|  2 +-
 test/bthread_execution_queue_unittest.cpp| 16 ++--
 test/bthread_key_unittest.cpp|  9 -
 test/cacheline_unittest.cpp  |  2 +-
 test/flat_map_unittest.cpp   |  1 +
 8 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/config_brpc.sh b/config_brpc.sh
index cf04b726..d0de0fdb 100755
--- a/config_brpc.sh
+++ b/config_brpc.sh
@@ -318,6 +318,8 @@ append_to_output "CXX=$CXX"
 append_to_output "GCC_VERSION=$GCC_VERSION"
 append_to_output "STATIC_LINKINGS=$STATIC_LINKINGS"
 append_to_output "DYNAMIC_LINKINGS=$DYNAMIC_LINKINGS"
+
+# CPP means C PreProcessing, not C PlusPlus
 CPPFLAGS="-DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS"
 
 # Avoid over-optimizations of TLS variables by GCC>=4.8
@@ -355,6 +357,13 @@ if [ $WITH_MESALINK != 0 ]; then
 fi
 
 append_to_output "CPPFLAGS=${CPPFLAGS}"
+append_to_output "# without the flag, linux+arm64 may crash due to folding on 
TLS.
+ifeq (\$(CC),gcc)
+  ifeq (\$(shell uname -p),aarch64) 
+CPPFLAGS+=-fno-gcse
+  endif
+endif
+"
 
 append_to_output "ifeq (\$(NEED_LIBPROTOC), 1)"
 PROTOC_LIB=$(find $PROTOBUF_LIB -name "libprotoc.*" | head -n1)
diff --git a/src/butil/containers/case_ignored_flat_map.h 
b/src/butil/containers/case_ignored_flat_map.h
index 6bc1a9af..30cfdda6 100644
--- a/src/butil/containers/case_ignored_flat_map.h
+++ b/src/butil/containers/case_ignored_flat_map.h
@@ -24,11 +24,12 @@
 
 namespace butil {
 
-// NOTE: Using ascii_tolower instead of ::tolower shortens 150ns in
+// Using ascii_tolower instead of ::tolower shortens 150ns in
 // FlatMapTest.perf_small_string_map (with -O2 added, -O0 by default)
-inline char ascii_tolower(char c) {
+// note: using char caused crashes on ubuntu 20.04 aarch64 (VM on apple M1)
+inline char ascii_tolower(int/*note*/ c) {
 extern const signed char* const g_tolower_map;
-return g_tolower_map[(int)c];
+return g_tolower_map[c];
 }
 
 struct CaseIgnoredHasher {
diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp
index 515f7021..214c7663 100644
--- a/src/butil/iobuf.cpp
+++ b/src/butil/iobuf.cpp
@@ -100,14 +100,14 @@ static ssize_t sys_pwritev(int fd, const struct iovec 
*vector,
 }
 
 inline iov_function get_preadv_func() {
+#if defined(OS_MACOSX)
+return user_preadv;
+#endif
 butil::fd_guard fd(open("/dev/zero", O_RDONLY));
 if (fd < 0) {
 PLOG(WARNING) << "Fail to open /dev/zero";
 return user_preadv;
 }
-#if defined(OS_MACOSX)
-return user_preadv;
-#endif
 char dummy[1];
 iovec vec = { dummy, sizeof(dummy) };
 const int rc = syscall(SYS_preadv, (int)fd, , 1, 0);
@@ -141,8 +141,7 @@ inline iov_function get_pwritev_func() {
 
 #else   // ARCH_CPU_X86_64
 
-#warning "We don't check whether the kernel supports SYS_preadv or SYS_pwritev 
" \
- "when the arch is not X86_64, use user space preadv/pwritev directly"
+#warning "We don't check if the kernel supports SYS_preadv or SYS_pwritev on 
non-X86_64, use impl. on pread/pwrite directly"
 
 inline iov_function get_preadv_func() {
 return user_preadv;
diff --git a/test/Makefile b/test/Makefile
index 5aa90e8b..871a99ed 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -27,8 +27,8 @@ ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0)
 CXXFLAGS+=-msse4 -msse4.2
   endif
 endif
-#not solved yet
 ifeq ($(CC),gcc)
+  # FIXME(jge): not solved yet
  ifeq ($(shell test $(GCC_VERSION) -ge 7; echo $$?),0)
CXXFLAGS+=-Wno-aligned-new
  endif
diff --git a/test/bthread_execution_queue_unittest.cpp 
b/test/bthread_execution_queue_unittest.cpp
index 8c70cbe4..8fb810d9 100644
--- a/test/bthread_execution_queue_unittest.cpp
+++ b/test/bthread_execution_queue_unittest.cpp
@@ -76,16 +76,12 @@ TEST_F(ExecutionQueueTest, single_thread) {
 }
 
 struct PushArg {
-bthread::ExecutionQueueId id;
-butil::atomic total_num;
-butil::atomic total_time;
-butil::atomic expected_value;
-volatile bool stopped;
-bool wait_task_completed;
-
-PushArg() {
-memset(this, 0, sizeof(*this));

[incubator-brpc] branch master updated: Fix override issue in pb

2022-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 86beca89 Fix override issue in pb
86beca89 is described below

commit 86beca89fe8b1c1dbf1f95b37c31d9b77630dde4
Author: gejun 
AuthorDate: Fri Aug 26 21:07:11 2022 +0800

Fix override issue in pb
---
 src/brpc/esp_message.h  |  9 +
 src/brpc/memcache.h | 17 +
 src/brpc/nshead_message.h   |  9 +
 src/brpc/pb_compat.h| 34 ++
 src/brpc/redis.h| 17 +
 src/brpc/serialized_request.h   |  9 +
 tools/rpc_press/json_loader.cpp |  4 +---
 7 files changed, 68 insertions(+), 31 deletions(-)

diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h
index 1c24707b..ce271d45 100644
--- a/src/brpc/esp_message.h
+++ b/src/brpc/esp_message.h
@@ -27,6 +27,7 @@
 #include "brpc/esp_head.h"
 #include "butil/iobuf.h"   
 #include "brpc/proto_base.pb.h"
+#include "brpc/pb_compat.h"
 
 namespace brpc {
 
@@ -53,7 +54,7 @@ public:
 
 // implements Message --
 
-EspMessage* New() const override;
+EspMessage* New() const PB_319_OVERRIDE;
 #if GOOGLE_PROTOBUF_VERSION >= 3006000
 EspMessage* New(::google::protobuf::Arena* arena) const override;
 #endif
@@ -66,11 +67,11 @@ public:
 
 int ByteSize() const;
 bool MergePartialFromCodedStream(
-::google::protobuf::io::CodedInputStream* input) override;
+::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
 void SerializeWithCachedSizes(
-::google::protobuf::io::CodedOutputStream* output) const override;
+::google::protobuf::io::CodedOutputStream* output) const 
PB_310_OVERRIDE;
 ::google::protobuf::uint8* SerializeWithCachedSizesToArray(
-::google::protobuf::uint8* output) const override;
+::google::protobuf::uint8* output) const PB_310_OVERRIDE;
 int GetCachedSize() const override { return ByteSize(); }
 
 protected:
diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h
index d0aaa542..a34ccd60 100644
--- a/src/brpc/memcache.h
+++ b/src/brpc/memcache.h
@@ -25,6 +25,7 @@
 #include "butil/iobuf.h"
 #include "butil/strings/string_piece.h"
 #include "brpc/proto_base.pb.h"
+#include "brpc/pb_compat.h"
 
 namespace brpc {
 
@@ -89,7 +90,7 @@ public:
 const butil::IOBuf& raw_buffer() const { return _buf; }
 
 // Protobuf methods.
-MemcacheRequest* New() const override;
+MemcacheRequest* New() const PB_319_OVERRIDE;
 #if GOOGLE_PROTOBUF_VERSION >= 3006000
 MemcacheRequest* New(::google::protobuf::Arena* arena) const override;
 #endif
@@ -102,10 +103,10 @@ public:
   
 int ByteSize() const;
 bool MergePartialFromCodedStream(
-::google::protobuf::io::CodedInputStream* input) override;
+::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
 void SerializeWithCachedSizes(
-::google::protobuf::io::CodedOutputStream* output) const override;
-::google::protobuf::uint8* 
SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const 
override;
+::google::protobuf::io::CodedOutputStream* output) const 
PB_310_OVERRIDE;
+::google::protobuf::uint8* 
SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const 
PB_310_OVERRIDE;
 int GetCachedSize() const override { return _cached_size_; }
 
 static const ::google::protobuf::Descriptor* descriptor();
@@ -202,7 +203,7 @@ public:
   
 // implements Message --
   
-MemcacheResponse* New() const override;
+MemcacheResponse* New() const PB_319_OVERRIDE;
 #if GOOGLE_PROTOBUF_VERSION >= 3006000
 MemcacheResponse* New(::google::protobuf::Arena* arena) const override;
 #endif
@@ -215,10 +216,10 @@ public:
   
 int ByteSize() const;
 bool MergePartialFromCodedStream(
-::google::protobuf::io::CodedInputStream* input) override;
+::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
 void SerializeWithCachedSizes(
-::google::protobuf::io::CodedOutputStream* output) const override;
-::google::protobuf::uint8* 
SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const 
override;
+::google::protobuf::io::CodedOutputStream* output) const 
PB_310_OVERRIDE;
+::google::protobuf::uint8* 
SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const 
PB_310_OVERRIDE;
 int GetCachedSize() const override { return _cached_size_; }
 
 static const ::google::protobuf::Descriptor* descriptor();
diff --git a/src/brpc/nshead_message.h b/src/brpc/ns

[incubator-brpc] branch master updated: fix ALIGNAS/ALIGNOF/BAIDU_CACHELINE_ALIGMENT

2022-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 4d2ca6b1 fix ALIGNAS/ALIGNOF/BAIDU_CACHELINE_ALIGMENT
4d2ca6b1 is described below

commit 4d2ca6b1e4fba37cfea80d6855087aafe63a4099
Author: gejun.0 
AuthorDate: Fri Aug 26 18:49:38 2022 +0800

fix ALIGNAS/ALIGNOF/BAIDU_CACHELINE_ALIGMENT
---
 src/brpc/policy/auto_concurrency_limiter.h |  4 ++--
 src/brpc/server.h  |  3 +--
 src/bthread/execution_queue_inl.h  |  6 ++---
 src/bthread/mutex.cpp  |  2 +-
 src/bthread/work_stealing_queue.h  |  2 +-
 src/butil/compiler_specific.h  | 36 ++
 6 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/src/brpc/policy/auto_concurrency_limiter.h 
b/src/brpc/policy/auto_concurrency_limiter.h
index 751e8337..7d694247 100644
--- a/src/brpc/policy/auto_concurrency_limiter.h
+++ b/src/brpc/policy/auto_concurrency_limiter.h
@@ -73,12 +73,12 @@ private:
 double _explore_ratio;
   
 // modified per sample.
-butil::atomic BAIDU_CACHELINE_ALIGNMENT _last_sampling_time_us;
+BAIDU_CACHELINE_ALIGNMENT butil::atomic _last_sampling_time_us;
 butil::Mutex _sw_mutex;
 SampleWindow _sw;
 
 // modified per request.
-butil::atomic BAIDU_CACHELINE_ALIGNMENT _total_succ_req;
+BAIDU_CACHELINE_ALIGNMENT butil::atomic _total_succ_req;
 };
 
 }  // namespace policy
diff --git a/src/brpc/server.h b/src/brpc/server.h
index 8c7a3959..261bfdce 100644
--- a/src/brpc/server.h
+++ b/src/brpc/server.h
@@ -691,8 +691,7 @@ friend class Controller;
 // mutable is required for `ServerPrivateAccessor' to change this bvar
 mutable bvar::Adder _nerror_bvar;
 mutable bvar::PerSecond > _eps_bvar;
-mutable int32_t BAIDU_CACHELINE_ALIGNMENT _concurrency;
-
+BAIDU_CACHELINE_ALIGNMENT mutable int32_t _concurrency;
 };
 
 // Get the data attached to current searching thread. The data is created by
diff --git a/src/bthread/execution_queue_inl.h 
b/src/bthread/execution_queue_inl.h
index 20fdab24..a346786d 100644
--- a/src/bthread/execution_queue_inl.h
+++ b/src/bthread/execution_queue_inl.h
@@ -223,9 +223,9 @@ private:
 
 // Don't change the order of _head, _versioned_ref and _stopped unless you 
 // see improvement of performance in test
-butil::atomic BAIDU_CACHELINE_ALIGNMENT _head;
-butil::atomic BAIDU_CACHELINE_ALIGNMENT _versioned_ref;
-butil::atomic BAIDU_CACHELINE_ALIGNMENT _stopped;
+BAIDU_CACHELINE_ALIGNMENT butil::atomic _head;
+BAIDU_CACHELINE_ALIGNMENT butil::atomic _versioned_ref;
+BAIDU_CACHELINE_ALIGNMENT butil::atomic _stopped;
 butil::atomic _high_priority_tasks;
 uint64_t _this_id;
 void* _meta;
diff --git a/src/bthread/mutex.cpp b/src/bthread/mutex.cpp
index e044eae2..f0dfc044 100644
--- a/src/bthread/mutex.cpp
+++ b/src/bthread/mutex.cpp
@@ -253,7 +253,7 @@ void ContentionProfiler::flush_to_disk(bool ending) {
 
 // If contention profiler is on, this variable will be set with a valid
 // instance. NULL otherwise.
-static ContentionProfiler* BAIDU_CACHELINE_ALIGNMENT g_cp = NULL;
+BAIDU_CACHELINE_ALIGNMENT static ContentionProfiler* g_cp = NULL;
 // Need this version to solve an issue that non-empty entries left by
 // previous contention profilers should be detected and overwritten.
 static uint64_t g_cp_version = 0;
diff --git a/src/bthread/work_stealing_queue.h 
b/src/bthread/work_stealing_queue.h
index 3750ac5e..357f1414 100644
--- a/src/bthread/work_stealing_queue.h
+++ b/src/bthread/work_stealing_queue.h
@@ -149,7 +149,7 @@ private:
 butil::atomic _bottom;
 size_t _capacity;
 T* _buffer;
-butil::atomic BAIDU_CACHELINE_ALIGNMENT _top;
+BAIDU_CACHELINE_ALIGNMENT butil::atomic _top;
 };
 
 }  // namespace bthread
diff --git a/src/butil/compiler_specific.h b/src/butil/compiler_specific.h
index 36fb651c..9da98a4a 100644
--- a/src/butil/compiler_specific.h
+++ b/src/butil/compiler_specific.h
@@ -124,10 +124,14 @@
 // Use like:
 //   class ALIGNAS(16) MyClass { ... }
 //   ALIGNAS(16) int array[4];
-#if defined(COMPILER_MSVC)
-#define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
-#elif defined(COMPILER_GCC)
-#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
+#if defined(BUTIL_CXX11_ENABLED)
+# define ALIGNAS(byte_alignment) alignas(byte_alignment)
+#else
+# if defined(COMPILER_MSVC)
+#  define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
+# elif defined(COMPILER_GCC)
+#  define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
+# endif
 #endif
 
 // Return the byte alignment of the given type (available at compile time).  
Use
@@ -135,10 +139,14 @@
 // http://goo.gl/isH0C
 // Use like:
 //   ALIGNOF(int32_t)  // this would be 4
-#if defined(COMPILER_M

[incubator-brpc] branch master updated: handle override related warnings

2022-08-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new ef50cd19 handle override related warnings
ef50cd19 is described below

commit ef50cd193cac4d0ef8c2b5a67e9cf0e2e28ae436
Author: gejun.0 
AuthorDate: Thu Aug 25 16:18:34 2022 +0800

handle override related warnings
---
 src/brpc/esp_message.h| 18 +-
 src/brpc/memcache.h   | 42 +-
 src/brpc/nshead_message.h | 18 +-
 src/brpc/redis.h  | 40 
 src/brpc/serialized_request.h | 22 +++---
 src/brpc/thrift_message.h | 20 ++--
 6 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h
index a17fd917..1c24707b 100644
--- a/src/brpc/esp_message.h
+++ b/src/brpc/esp_message.h
@@ -53,25 +53,25 @@ public:
 
 // implements Message --
 
-EspMessage* New() const;
+EspMessage* New() const override;
 #if GOOGLE_PROTOBUF_VERSION >= 3006000
 EspMessage* New(::google::protobuf::Arena* arena) const override;
 #endif
-void CopyFrom(const ::google::protobuf::Message& from);
-void MergeFrom(const ::google::protobuf::Message& from);
+void CopyFrom(const ::google::protobuf::Message& from) override;
+void MergeFrom(const ::google::protobuf::Message& from) override;
 void CopyFrom(const EspMessage& from);
 void MergeFrom(const EspMessage& from);
-void Clear();
-bool IsInitialized() const;
+void Clear() override;
+bool IsInitialized() const override;
 
 int ByteSize() const;
 bool MergePartialFromCodedStream(
-::google::protobuf::io::CodedInputStream* input);
+::google::protobuf::io::CodedInputStream* input) override;
 void SerializeWithCachedSizes(
-::google::protobuf::io::CodedOutputStream* output) const;
+::google::protobuf::io::CodedOutputStream* output) const override;
 ::google::protobuf::uint8* SerializeWithCachedSizesToArray(
-::google::protobuf::uint8* output) const;
-int GetCachedSize() const { return ByteSize(); }
+::google::protobuf::uint8* output) const override;
+int GetCachedSize() const override { return ByteSize(); }
 
 protected:
 ::google::protobuf::Metadata GetMetadata() const override;
diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h
index ab464573..d0aaa542 100644
--- a/src/brpc/memcache.h
+++ b/src/brpc/memcache.h
@@ -89,24 +89,24 @@ public:
 const butil::IOBuf& raw_buffer() const { return _buf; }
 
 // Protobuf methods.
-MemcacheRequest* New() const;
+MemcacheRequest* New() const override;
 #if GOOGLE_PROTOBUF_VERSION >= 3006000
 MemcacheRequest* New(::google::protobuf::Arena* arena) const override;
 #endif
-void CopyFrom(const ::google::protobuf::Message& from);
-void MergeFrom(const ::google::protobuf::Message& from);
+void CopyFrom(const ::google::protobuf::Message& from) override;
+void MergeFrom(const ::google::protobuf::Message& from) override;
 void CopyFrom(const MemcacheRequest& from);
 void MergeFrom(const MemcacheRequest& from);
-void Clear();
-bool IsInitialized() const;
+void Clear() override;
+bool IsInitialized() const override;
   
 int ByteSize() const;
 bool MergePartialFromCodedStream(
-::google::protobuf::io::CodedInputStream* input);
+::google::protobuf::io::CodedInputStream* input) override;
 void SerializeWithCachedSizes(
-::google::protobuf::io::CodedOutputStream* output) const;
-::google::protobuf::uint8* 
SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
-int GetCachedSize() const { return _cached_size_; }
+::google::protobuf::io::CodedOutputStream* output) const override;
+::google::protobuf::uint8* 
SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const 
override;
+int GetCachedSize() const override { return _cached_size_; }
 
 static const ::google::protobuf::Descriptor* descriptor();
 
@@ -124,7 +124,7 @@ private:
 
 void SharedCtor();
 void SharedDtor();
-void SetCachedSize(int size) const;
+void SetCachedSize(int size) const override;
 
 int _pipelined_count;
 butil::IOBuf _buf;
@@ -202,29 +202,29 @@ public:
   
 // implements Message --
   
-MemcacheResponse* New() const;
+MemcacheResponse* New() const override;
 #if GOOGLE_PROTOBUF_VERSION >= 3006000
 MemcacheResponse* New(::google::protobuf::Arena* arena) const override;
 #endif
-void CopyFrom(const ::google::protobuf:

[incubator-brpc] branch master updated: fix the problem that the first bthread keytable on worker pthread will be deleted twice

2022-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new e1f7c9bc fix the problem that the first bthread keytable on worker 
pthread will be deleted twice
 new a0fc1a2c Merge pull request #1884 from 
chenBright/fix_double_delete_keytable
e1f7c9bc is described below

commit e1f7c9bc5b959de132fb96610875b866020edda9
Author: chenguangming 
AuthorDate: Fri Aug 12 19:24:06 2022 +0800

fix the problem that the first bthread keytable on worker pthread will be 
deleted twice
---
 src/bthread/key.cpp | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/bthread/key.cpp b/src/bthread/key.cpp
index a4a08407..ca5e079d 100644
--- a/src/bthread/key.cpp
+++ b/src/bthread/key.cpp
@@ -446,10 +446,14 @@ int bthread_setspecific(bthread_key_t key, void* data) {
 bthread::TaskGroup* const g = bthread::tls_task_group;
 if (g) {
 g->current_task()->local_storage.keytable = kt;
-}
-if (!bthread::tls_ever_created_keytable) {
-bthread::tls_ever_created_keytable = true;
-CHECK_EQ(0, butil::thread_atexit(bthread::cleanup_pthread, kt));
+} else {
+// Only cleanup keytable created by pthread.
+// keytable created by bthread will be deleted
+// in `return_keytable' or `bthread_keytable_pool_destroy'.
+if (!bthread::tls_ever_created_keytable) {
+bthread::tls_ever_created_keytable = true;
+CHECK_EQ(0, butil::thread_atexit(bthread::cleanup_pthread, 
kt));
+}
 }
 }
 return kt->set_data(key, data);


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Fix UDS ut failed on MacOS

2022-07-18 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 30dfef16 Fix UDS ut failed on MacOS
 new 0e10bdb9 Merge pull request #1843 from wwbmmm/fix-uds-ut-on-mac
30dfef16 is described below

commit 30dfef1665601fd6efe3996417749aa45d997565
Author: wwbmmm 
AuthorDate: Mon Jul 18 17:55:48 2022 +0800

Fix UDS ut failed on MacOS
---
 src/butil/details/extended_endpoint.hpp |  8 +++-
 test/endpoint_unittest.cpp  | 23 ++-
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/butil/details/extended_endpoint.hpp 
b/src/butil/details/extended_endpoint.hpp
index e969d9d7..36a67719 100644
--- a/src/butil/details/extended_endpoint.hpp
+++ b/src/butil/details/extended_endpoint.hpp
@@ -163,6 +163,9 @@ public:
 eep->_u.in6.sin6_flowinfo = 0u;
 eep->_u.in6.sin6_scope_id = 0u;
 eep->_socklen = sizeof(_u.in6);
+#if defined(OS_MACOSX)
+eep->_u.in6.sin6_len = eep->_socklen;
+#endif
 }
 } else if (sp.starts_with("unix:")) { // ignore port
 sp.remove_prefix(5); // remove `unix:'
@@ -174,6 +177,9 @@ public:
 int size = sp.copy(eep->_u.un.sun_path, sp.size());
 eep->_u.un.sun_path[size] = '\0';
 eep->_socklen = offsetof(sockaddr_un, sun_path) + size + 1;
+#if defined(OS_MACOSX)
+eep->_u.un.sun_len = eep->_socklen;
+#endif
 }
 }
 if (eep) {
@@ -374,4 +380,4 @@ inline bool 
GlobalEndPointSet::Equals::operator()(ExtendedEndPoint* const& p1, E
 } // namespace details
 } // namespace butil
 
-#endif // BUTIL_DETAILS_EXTENDED_ENDPOINT_H
\ No newline at end of file
+#endif // BUTIL_DETAILS_EXTENDED_ENDPOINT_H
diff --git a/test/endpoint_unittest.cpp b/test/endpoint_unittest.cpp
index 8b515ef3..4cb7f757 100644
--- a/test/endpoint_unittest.cpp
+++ b/test/endpoint_unittest.cpp
@@ -156,9 +156,6 @@ void* server_proc(void* arg) {
 sockaddr_storage ss;
 socklen_t len = sizeof(ss);
 int fd = accept(listen_fd, (sockaddr*), );
-if (fd > 0) {
-close(fd);
-}
 return (void*)(int64_t)fd;
 }
 
@@ -190,7 +187,9 @@ static void test_listen_connect(const std::string& 
server_addr, const std::strin
 
 void* ret = nullptr;
 pthread_join(pid, );
-ASSERT_GT((int64_t)ret, 0);
+int server_fd = (int)(int64_t)ret;
+ASSERT_GT(server_fd, 0);
+close(server_fd);
 close(listen_fd);
 }
 
@@ -238,12 +237,12 @@ TEST(EndPointTest, unix_socket) {
 ASSERT_EQ(0, butil::str2endpoint("unix://a.sock", 123, ));
 ASSERT_EQ(std::string("unix://a.sock"), 
butil::endpoint2str(point).c_str());
 
-ASSERT_EQ(-1, 
butil::str2endpoint("unix:tooloo"
-"ooong.sock", ));
-ASSERT_EQ(0, butil::str2endpoint(" 
unix:l"
-"ooong.sock", ));
-
ASSERT_EQ(std::string("unix:l"
-"ooong.sock"), 
butil::endpoint2str(point).c_str());
+std::string long_path = "unix:";
+long_path.append(sizeof(sockaddr_un::sun_path) - 1, 'a');
+ASSERT_EQ(0, butil::str2endpoint(long_path.c_str(), ));
+ASSERT_EQ(long_path, butil::endpoint2str(point).c_str());
+long_path.push_back('a');
+ASSERT_EQ(-1, butil::str2endpoint(long_path.c_str(), ));
 char buf[128] = {0}; // braft use this size of buffer
 size_t ret = snprintf(buf, sizeof(buf), "%s:%d", 
butil::endpoint2str(point).c_str(), INT_MAX);
 ASSERT_LT(ret, sizeof(buf) - 1);
@@ -383,9 +382,7 @@ TEST(EndPointTest, endpoint_sockaddr_conv_ipv6) {
 
 in6_addr expect_in6_addr;
 bzero(_in6_addr, sizeof(expect_in6_addr));
-expect_in6_addr.__in6_u.__u6_addr8[15] = 1;
-// jge: mac monterey上应该这样,但准确判定条件不明
-//expect_in6_addr.__u6_addr.__u6_addr8[15] = 1;
+expect_in6_addr.s6_addr[15] = 1;
 
 sockaddr_storage ss;
 const sockaddr_in6* sa6 = (sockaddr_in6*) 


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add CXXFLAGS in compiling protoc-gen-mcpack

2022-06-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new d7be1d9c add CXXFLAGS in compiling protoc-gen-mcpack
d7be1d9c is described below

commit d7be1d9cf90687c687c778e522fa9da79b7824ee
Author: jamesge 
AuthorDate: Wed Jun 29 09:27:35 2022 +0800

add CXXFLAGS in compiling protoc-gen-mcpack
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index e2e1a6b2..3d5978d4 100644
--- a/Makefile
+++ b/Makefile
@@ -241,9 +241,9 @@ clean_debug:
 protoc-gen-mcpack: src/idl_options.pb.cc src/mcpack2pb/generator.o libbrpc.a
@echo "> Linking $@"
 ifeq ($(SYSTEM),Linux)
-   $(CXX) -o $@ $(HDRPATHS) $(LIBPATHS) -std=c++0x -Xlinker "-(" $^ 
-Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
+   $(CXX) -o $@ $(CXXFLAGS) $(HDRPATHS) $(LIBPATHS) -std=c++0x -Xlinker 
"-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" 
$(DYNAMIC_LINKINGS)
 else ifeq ($(SYSTEM),Darwin)
-   $(CXX) -o $@ $(HDRPATHS) $(LIBPATHS) -std=c++0x $^ $(STATIC_LINKINGS) 
$(DYNAMIC_LINKINGS)
+   $(CXX) -o $@ $(CXXFLAGS) $(HDRPATHS) $(LIBPATHS) -std=c++0x $^ 
$(STATIC_LINKINGS) $(DYNAMIC_LINKINGS)
 endif
 
 # force generation of pb headers before compiling to avoid fail-to-import 
issues in compiling pb.cc


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (f8314301 -> e4db5e4f)

2022-06-11 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


from f8314301 Merge pull request #1784 from wwbmmm/fix-dl-sym
 new e0956d32 Merge pull request #1 from apache/master
 new 674afc11 add try catch for thrift
 new c6cf613d update catch exception
 new e278a05c update exception
 new d63b6779 update exception
 new 72f7c0e7 update exception
 new e4db5e4f Merge pull request #1790 from 
lzfhust/thrift_protocol_exception

The 2555 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/policy/thrift_protocol.cpp | 51 -
 1 file changed, 28 insertions(+), 23 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Elaborate how-to-build steps for MacOS

2022-06-08 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 9556320a Elaborate how-to-build steps for MacOS
9556320a is described below

commit 9556320afc049419e0021ba404d106a72de5d215
Author: James Ge 
AuthorDate: Wed Jun 8 20:11:08 2022 +0800

Elaborate how-to-build steps for MacOS
---
 docs/cn/getting_started.md | 28 +---
 docs/en/getting_started.md | 31 ++-
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md
index b4af85a5..2602f5b4 100644
--- a/docs/cn/getting_started.md
+++ b/docs/cn/getting_started.md
@@ -213,6 +213,10 @@ $ make
 
 注意:在相同硬件条件下,MacOS版brpc的性能可能明显差于Linux版。如果你的服务是性能敏感的,请不要使用MacOS作为你的生产环境。
 
+### Apple Silicon
+
+master HEAD已支持M1系列芯片,M2未测试过。欢迎通过issues向我们报告遗留的warning/error。
+
 ### 依赖准备
 
 安装依赖:
@@ -225,22 +229,17 @@ brew install openssl git gnu-getopt coreutils gflags 
protobuf leveldb
 brew install gperftools
 ```
 
-如果你要运行测试,那么要安装并编译googletest(它没有被默认编译):
+如果你要运行测试,需安装gtest。先运行`brew install 
googletest`看看homebrew是否支持(老版本没有),没有的话请下载和编译googletest:
 ```shell
 git clone https://github.com/google/googletest -b release-1.10.0 && cd 
googletest/googletest && mkdir build && cd build && cmake 
-DCMAKE_CXX_FLAGS="-std=c++11" .. && make
 ```
-在编译完成后,复制include/和lib/目录到/usr/local/include和/usr/local/lib目录中,以便于让所有应用都能使用gtest。
-
-### Monterey
-Monterey中openssl的安装位置可能不再位于`/usr/local/opt/openssl`,很可能会在`/opt/homebrew/Cellar`目录下,如果编译时报告找不到openssl,可考虑设置软链如下:
-```shell
-sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl
-```
-请注意上述命令中openssl的目录可能随环境变化而变化,你可以通过`brew info openssl`查看。
+在编译完成后,复制`include/`和`lib/`目录到`/usr/local/include`和`/usr/local/lib`目录中,以便于让所有应用都能使用gtest。
 
-### Apple Silicon
+### OpenSSL
+Monterey中openssl的安装位置可能不再位于`/usr/local/opt/openssl`,很可能会在`/opt/homebrew/Cellar`目录下,如果编译时报告找不到openssl:
 
-master HEAD已支持M1系列芯片,M2未测试过。欢迎通过issues向我们报告遗留的warning/error。
+* 先运行`brew link openssl --force`看看`/user/local/opt/openssl`是否出现了
+* 没有的话可以自行设置软链:`sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 
/usr/local/opt/openssl`。请注意此命令中openssl的目录可能随环境变化而变化,可通过`brew info openssl`查看。
 
 ### 使用config_brpc.sh编译brpc
 git克隆brpc,进入到项目目录然后运行:
@@ -248,6 +247,13 @@ git克隆brpc,进入到项目目录然后运行:
 $ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib 
--cc=clang --cxx=clang++
 $ make
 ```
+MacOS Monterey下的brew安装路径可能改变,如有路径相关的错误,可考虑设置如下:
+
+```shell
+$ sh config_brpc.sh --headers=/opt/homebrew/include --libs=/opt/homebrew/lib 
--cc=clang --cxx=clang++
+$ make
+```
+
 不想链接调试符号,添加选项`--nodebugsymbols`,然后编译将会得到更轻量的二进制文件。
 
 使用glog版的brpc,添加选项`--with-glog`。
diff --git a/docs/en/getting_started.md b/docs/en/getting_started.md
index 03e34cf6..c500f580 100644
--- a/docs/en/getting_started.md
+++ b/docs/en/getting_started.md
@@ -217,6 +217,10 @@ Same with [here](#compile-brpc-with-cmake)
 
 Note: With same environment, the performance of the MacOS version is worse 
than the Linux version. If your service is performance-critical, do not use 
MacOS as your production environment.
 
+### Apple Silicon
+
+The code at master HEAD already supports M1 series chips. M2 series are not 
tested yet. Please feel free to report remaining warnings/errors to us by 
issues.
+
 ### Prepare deps
 
 Install dependencies:
@@ -229,25 +233,18 @@ If you need to enable cpu/heap profilers in examples:
 brew install gperftools
 ```
 
-If you need to run tests, download and compile googletest (which is not 
compiled yet):
+If you need to run tests, googletest is required. Run `brew install 
googletest` first to see if it works. If not (old homebrew does not have 
googletest), you can download and compile googletest by your own:
 ```shell
 git clone https://github.com/google/googletest -b release-1.10.0 && cd 
googletest/googletest && mkdir build && cd build && cmake 
-DCMAKE_CXX_FLAGS="-std=c++11" .. && make
 ```
-After the compilation, copy include/ and lib/ into /usr/local/include and 
/usr/local/lib respectively to expose gtest to all apps
+After the compilation, copy `include/` and `lib/` into `/usr/local/include` 
and `/usr/local/lib` respectively to expose gtest to all apps
 
-### Monterey
+### OpenSSL
 
-openssl installed in Monterey may not be found at `/usr/local/opt/openssl`, 
instead it's probably put under `/opt/homebrew/Cellar`. If the compiler cannot 
find openssl, consider making a soft link like below:
+openssl installed in Monterey may not be found at `/usr/local/opt/openssl`, 
instead it's probably put under `/opt/homebrew/Cellar`. If the compiler cannot 
find openssl:
 
-```shell
-sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl
-```
-
-Please note that the directory of ins

[incubator-brpc] branch master updated: Support apple silicon

2022-06-08 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new efa9989e Support apple silicon
efa9989e is described below

commit efa9989e99dce0bb5f8e26818574748c7ef45059
Author: James Ge 
AuthorDate: Wed Jun 8 16:49:33 2022 +0800

Support apple silicon
---
 Makefile| 10 +++--
 config_brpc.sh  | 21 ++
 docs/cn/getting_started.md  | 33 +++
 docs/en/getting_started.md  | 25 
 src/brpc/span.h |  2 +-
 src/bthread/context.cpp | 97 +
 src/bthread/context.h   | 19 +
 src/bthread/key.cpp |  2 +-
 src/bthread/task_group.cpp  |  2 +-
 src/butil/time.h| 26 
 test/{BUILD => BUILD.bazel} |  0
 test/CMakeLists.txt |  2 +-
 test/Makefile   |  4 +-
 test/endpoint_unittest.cpp  |  2 +
 14 files changed, 196 insertions(+), 49 deletions(-)

diff --git a/Makefile b/Makefile
index 3538e47c..e2e1a6b2 100644
--- a/Makefile
+++ b/Makefile
@@ -41,13 +41,15 @@ endif
 
 #required by butil/crc32.cc to boost performance for 10x
 ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0)
-   CXXFLAGS+=-msse4 -msse4.2
+  ifeq ($(shell uname -p),i386)  #note: i386 is processor family type, not the 
32-bit x86 arch
+CXXFLAGS+=-msse4 -msse4.2
+  endif
 endif
 #not solved yet
 ifeq ($(CC),gcc)
- ifeq ($(shell test $(GCC_VERSION) -ge 7; echo $$?),0)
-   CXXFLAGS+=-Wno-aligned-new
- endif
+  ifeq ($(shell test $(GCC_VERSION) -ge 7; echo $$?),0)
+CXXFLAGS+=-Wno-aligned-new
+  endif
 endif
 
 BUTIL_SOURCES = \
diff --git a/config_brpc.sh b/config_brpc.sh
index f52911db..842f100f 100755
--- a/config_brpc.sh
+++ b/config_brpc.sh
@@ -154,16 +154,21 @@ find_dir_of_header_or_die() {
 }
 
 if [ "$SYSTEM" = "Darwin" ]; then
-OPENSSL_LIB="/usr/local/opt/openssl/lib"
-OPENSSL_HDR="/usr/local/opt/openssl/include"
-else
-# User specified path of openssl, if not given it's empty
-OPENSSL_LIB=$(find_dir_of_lib ssl)
-# Inconvenient to check these headers in baidu-internal
-#PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h)
-OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h 
mesalink/openssl/ssl.h)
+if [ -d "/usr/local/opt/openssl" ]; then
+LIBS_IN="/usr/local/opt/openssl/lib $LIBS_IN"
+HDRS_IN="/usr/local/opt/openssl/include $HDRS_IN"
+elif [ -d "/opt/homebrew/Cellar" ]; then
+LIBS_IN="/opt/homebrew/Cellar $LIBS_IN"
+HDRS_IN="/opt/homebrew/Cellar $HDRS_IN"
+fi
 fi
 
+# User specified path of openssl, if not given it's empty
+OPENSSL_LIB=$(find_dir_of_lib ssl)
+# Inconvenient to check these headers in baidu-internal
+#PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h)
+OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h mesalink/openssl/ssl.h)
+
 if [ $WITH_MESALINK != 0 ]; then
 MESALINK_HDR=$(find_dir_of_header_or_die mesalink/openssl/ssl.h)
 OPENSSL_HDR="$OPENSSL_HDR\n$MESALINK_HDR"
diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md
index 53ef0f50..b4af85a5 100644
--- a/docs/cn/getting_started.md
+++ b/docs/cn/getting_started.md
@@ -20,7 +20,7 @@ brpc有如下依赖:
 ## Ubuntu/LinuxMint/WSL
 ### 依赖准备
 
-安装通用依赖,[gflags](https://github.com/gflags/gflags), 
[protobuf](https://github.com/google/protobuf), 
[leveldb](https://github.com/google/leveldb):
+安装依赖:
 ```shell
 sudo apt-get install -y git g++ make libssl-dev libgflags-dev libprotobuf-dev 
libprotoc-dev protobuf-compiler libleveldb-dev
 ```
@@ -113,14 +113,9 @@ CentOS一般需要安装EPEL,否则很多包都默认不可用。
 sudo yum install epel-release
 ```
 
-安装通用依赖:
+安装依赖:
 ```shell
-sudo yum install git gcc-c++ make openssl-devel
-```
-
-安装 [gflags](https://github.com/gflags/gflags), 
[protobuf](https://github.com/google/protobuf), 
[leveldb](https://github.com/google/leveldb):
-```shell
-sudo yum install gflags-devel protobuf-devel protobuf-compiler leveldb-devel
+sudo yum install git gcc-c++ make openssl-devel gflags-devel protobuf-devel 
protobuf-compiler leveldb-devel
 ```
 
 如果你要在样例中启用cpu/heap的profiler:
@@ -216,18 +211,13 @@ $ make
 
 ## MacOS
 
-注意:在相同运行环境下,当前Mac版brpc的性能比Linux版差2.5倍。如果你的服务是性能敏感的,请不要使用MacOs作为你的生产环境。
+注意:在相同硬件条件下,MacOS版brpc的性能可能明显差于Linux版。如果你的服务是性能敏感的,请不要使用MacOS作为你的生产环境。
 
 ### 依赖准备
 
-安装通用依赖:
-```shell
-brew install openssl git gnu-getopt coreutils
-```
-
-安装[gflags](https://github.com/gflags/gflags),[protobuf](https://github.com/google/protobuf),[leveldb](https://github.com/google/leveldb):
+安装依赖:
 ```shell
-brew install gflags protobuf leveldb
+brew install openssl git gnu-getopt coreutils gflags protobuf leveldb
 ```
 
 如果你要在样例中启用cpu/heap的profiler:
@@ -241,6 +231,17 @@ git clone https://github

[incubator-brpc] branch master updated: json2pb::JsonToProtoMessage() supports parsing multiple jsons

2022-06-05 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 958a4c3a json2pb::JsonToProtoMessage() supports parsing multiple jsons
958a4c3a is described below

commit 958a4c3a0c2b5811400e042a216d651fd11e02a1
Author: jamesge 
AuthorDate: Sun Jun 5 17:59:30 2022 +0800

json2pb::JsonToProtoMessage() supports parsing multiple jsons
---
 src/butil/iobuf.h|   6 +-
 src/butil/strings/string_util.h  |   4 ++
 src/butil/third_party/rapidjson/reader.h |   5 ++
 src/json2pb/json_to_pb.cpp   | 106 +--
 src/json2pb/json_to_pb.h |  33 --
 src/json2pb/rapidjson.h  |   1 +
 test/addressbook.proto   |   2 +-
 test/brpc_protobuf_json_unittest.cpp | 106 +++
 8 files changed, 219 insertions(+), 44 deletions(-)

diff --git a/src/butil/iobuf.h b/src/butil/iobuf.h
index c2743096..8e2bfe47 100644
--- a/src/butil/iobuf.h
+++ b/src/butil/iobuf.h
@@ -296,9 +296,9 @@ public:
 // Returns bytes copied.
 size_t copy_to(void* buf, size_t n = (size_t)-1L, size_t pos = 0) const;
 
-// NOTE: first parameter is not std::string& because user may passes
-// a pointer of std::string by mistake, in which case, compiler would
-// call the void* version which crashes definitely.
+// NOTE: first parameter is not std::string& because user may pass in
+// a pointer of std::string by mistake, in which case, the void* overload
+// would be wrongly called.
 size_t copy_to(std::string* s, size_t n = (size_t)-1L, size_t pos = 0) 
const;
 size_t append_to(std::string* s, size_t n = (size_t)-1L, size_t pos = 0) 
const;
 
diff --git a/src/butil/strings/string_util.h b/src/butil/strings/string_util.h
index 23bc01e4..4d78e20f 100644
--- a/src/butil/strings/string_util.h
+++ b/src/butil/strings/string_util.h
@@ -377,6 +377,10 @@ inline bool IsWhitespace(wchar_t c) {
   return wcschr(butil::kWhitespaceWide, c) != NULL;
 }
 
+inline bool IsBlankString(const butil::StringPiece ) {
+return butil::ContainsOnlyChars(s, " \r\n\t");
+}
+
 // Return a byte string in human-readable format with a unit suffix. Not
 // appropriate for use in any UI; use of FormatBytes and friends in ui/base is
 // highly recommended instead. TODO(avi): Figure out how to get callers to use
diff --git a/src/butil/third_party/rapidjson/reader.h 
b/src/butil/third_party/rapidjson/reader.h
index 552eca03..fd6398b5 100644
--- a/src/butil/third_party/rapidjson/reader.h
+++ b/src/butil/third_party/rapidjson/reader.h
@@ -430,6 +430,11 @@ public:
 
RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentRootNotSingular, is.Tell());
 RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
 }
+} else {
+// jge: Update parseResult_.Offset() when 
kParseStopwhendoneflag
+// is set which means the user needs to know where to resume
+// parsing in next calls to JsonToProtoMessage()
+SetParseError(kParseErrorNone, is.Tell());
 }
 }
 
diff --git a/src/json2pb/json_to_pb.cpp b/src/json2pb/json_to_pb.cpp
index e87c3922..fc9a31a0 100644
--- a/src/json2pb/json_to_pb.cpp
+++ b/src/json2pb/json_to_pb.cpp
@@ -25,6 +25,8 @@
 #include  
 #include 
 #include "butil/strings/string_number_conversions.h"
+#include "butil/third_party/rapidjson/error/error.h"
+#include "butil/third_party/rapidjson/rapidjson.h"
 #include "json_to_pb.h"
 #include "zero_copy_stream_reader.h"   // ZeroCopyStreamReader
 #include "encode_decode.h"
@@ -33,12 +35,19 @@
 #include "protobuf_map.h"
 #include "rapidjson.h"
 
-#define J2PERROR(perr, fmt, ...)\
+
+#define J2PERROR(perr, fmt, ...)\
+J2PERROR_WITH_PB((::google::protobuf::Message*)nullptr, perr, fmt, 
##__VA_ARGS__)
+
+#define J2PERROR_WITH_PB(pb, perr, fmt, ...)\
 if (perr) { \
 if (!perr->empty()) {   \
 perr->append(", ", 2);  \
 }   \
-butil::string_appendf(perr, fmt, ##__VA_ARGS__); \
+butil::string_appendf(perr, fmt, ##__VA_ARGS__);\
+if ((pb) != nullptr) {\
+butil::string_appendf(perr, " [%s]", 
(pb)->GetDescriptor()->name().c_str());  \
+}  

[incubator-brpc] branch master updated (28227f56 -> bf6791d8)

2022-05-18 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


from 28227f56 Update oncall.md
 add bf6791d8 comment fix

No new revisions were added by this update.

Summary of changes:
 src/brpc/shared_object.h  |  4 ++--
 src/brpc/socket_message.h | 18 --
 2 files changed, 10 insertions(+), 12 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Exclude mesalink/openssl/ssl.h when find openssl

2021-12-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new a7525c2  Exclude mesalink/openssl/ssl.h when find openssl
 new d3452d7  Merge pull request #1623 from wasphin/feature/exclude-mesalink
a7525c2 is described below

commit a7525c20ed7bbf4d2143e6d2c733a99da794cfe0
Author: wxf 
AuthorDate: Thu Dec 2 09:37:17 2021 +0800

Exclude mesalink/openssl/ssl.h when find openssl

Resolve #1622
---
 config_brpc.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config_brpc.sh b/config_brpc.sh
index 1720031..f52911d 100755
--- a/config_brpc.sh
+++ b/config_brpc.sh
@@ -161,7 +161,7 @@ else
 OPENSSL_LIB=$(find_dir_of_lib ssl)
 # Inconvenient to check these headers in baidu-internal
 #PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h)
-OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h)
+OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h 
mesalink/openssl/ssl.h)
 fi
 
 if [ $WITH_MESALINK != 0 ]; then

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Fix typo

2021-12-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 3a6a0b9  Fix typo
 new 39aa541  Merge pull request #1613 from egolearner/patch-1
3a6a0b9 is described below

commit 3a6a0b9369ca9252f44c41b3368f0b1229f9d70c
Author: egolearner <45122959+egolear...@users.noreply.github.com>
AuthorDate: Thu Nov 25 10:56:15 2021 +0800

Fix typo
---
 docs/cn/client.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/cn/client.md b/docs/cn/client.md
index 566ebf1..8c52e23 100755
--- a/docs/cn/client.md
+++ b/docs/cn/client.md
@@ -755,7 +755,7 @@ http/h2 body的压缩方法见[client压缩request body](http_client.md#压缩re
 
 支持的压缩方法有:
 
-- brpc::CompressTypeSnappy : 
[snanpy压缩](http://google.github.io/snappy/),压缩和解压显著快于其他压缩方法,但压缩率最低。
+- brpc::CompressTypeSnappy : 
[snappy压缩](http://google.github.io/snappy/),压缩和解压显著快于其他压缩方法,但压缩率最低。
 - brpc::CompressTypeGzip : 
[gzip压缩](http://en.wikipedia.org/wiki/Gzip),显著慢于snappy,但压缩率高
 - brpc::CompressTypeZlib : 
[zlib压缩](http://en.wikipedia.org/wiki/Zlib),比gzip快10%~20%,压缩率略好于gzip,但速度仍明显慢于snappy。
 

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (cff40a9 -> bcf7fd8)

2021-12-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from cff40a9  Merge pull request #1635 from mahongweichina/master
 new 91a48f4  Update gifs in docs to remove hostname and ip
 new 87bc97a  Update rpc_press doc to remove specific hostname
 new bcf7fd8  Merge pull request #1636 from wwbmmm/update_pics

The 2374 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/cn/rpc_press.md|   2 +-
 docs/images/heap_profiler_3.gif | Bin 362001 -> 2247904 bytes
 docs/images/vars_1.gif  | Bin 202182 -> 1117263 bytes
 docs/images/vars_2.gif  | Bin 305617 -> 1632482 bytes
 4 files changed, 1 insertion(+), 1 deletion(-)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add cases.md

2021-09-08 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 4de5ef3  add cases.md
 new 1a03ff8  Merge pull request #1551 from tanzhongyi003/master
4de5ef3 is described below

commit 4de5ef3ef1024120bfffdd51ddc67a5a805b1c11
Author: tanzhongyi003 
AuthorDate: Thu Sep 9 09:36:51 2021 +0800

add cases.md
---
 community/cases.md | 21 +
 1 file changed, 21 insertions(+)

diff --git a/community/cases.md b/community/cases.md
new file mode 100644
index 000..e005843
--- /dev/null
+++ b/community/cases.md
@@ -0,0 +1,21 @@
+# brpc的应用案例集合
+
+## what is this
+这里列出brpc在各个企业中的落地场景,包括企业名称,应用项目作用,集群规模和QPS统计,使用的版本信息等
+
+## Why this
+列出各个案例,一来方便用户进行参考,了解brpc可以用在哪些场景下;
+二来方便社区开发者统计brpc的版本,规模等情况
+
+# Case List
+## 落地case的sample (如果有多个场景,可以合并也可以分开)
+* 公司名称: xxx公司
+* 落地项目: 例如app的个性化推荐系统的预测服务
+* 集群规模: 例如100台
+* QPS: 例如峰值1000万, 均值100万
+* 使用版本: 例如社区版本0.9.7
+
+## brpc在 百度的落地情况一
+* 公司名称: 百度
+* 落地项目: 
+

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/01: Merge pull request #1519 from apache/tanzhongyi003-patch-1

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 2a8edc6e041621c7d1a33b9273a1ce7446929b61
Merge: c26cfff 3fdc980
Author: jamesge 
AuthorDate: Sat Aug 14 16:51:35 2021 +0800

Merge pull request #1519 from apache/tanzhongyi003-patch-1

Update NOTICE

 NOTICE | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (c26cfff -> 2a8edc6)

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from c26cfff  Merge pull request #1515 from 
guodongxiaren/translate_getting_started
 add 3fdc980  Update NOTICE
 new 2a8edc6  Merge pull request #1519 from apache/tanzhongyi003-patch-1

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 NOTICE | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (732f57b -> c26cfff)

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 732f57b  Merge pull request #1520 from apache/tanzhongyi003-patch-2
 new 80d1590  Tanslate getting_started.md into Chinese
 new fe1611e  english version and chinese version
 new 802531f  Update getting_started.md
 new c26cfff  Merge pull request #1515 from 
guodongxiaren/translate_getting_started

The 2267 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/cn/getting_started.md | 208 +++--
 docs/{cn => en}/getting_started.md |   2 +
 docs/en/thrift.md  |   2 +-
 3 files changed, 108 insertions(+), 104 deletions(-)
 copy docs/{cn => en}/getting_started.md (99%)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (d15d340 -> 732f57b)

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from d15d340  Merge pull request #1521 from apache/tanzhongyi003-patch-3
 add 2f04fde  Update get_brpc_revision.sh
 new 732f57b  Merge pull request #1520 from apache/tanzhongyi003-patch-2

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tools/get_brpc_revision.sh | 15 +++
 1 file changed, 15 insertions(+)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/01: Merge pull request #1520 from apache/tanzhongyi003-patch-2

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 732f57bc0931f8099568683b230c353b26f5f08c
Merge: d15d340 2f04fde
Author: jamesge 
AuthorDate: Sat Aug 14 16:50:25 2021 +0800

Merge pull request #1520 from apache/tanzhongyi003-patch-2

Update get_brpc_revision.sh

 tools/get_brpc_revision.sh | 15 +++
 1 file changed, 15 insertions(+)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (38f04c9 -> d15d340)

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 38f04c9  Merge pull request #1517 from tanzhongyi003/master
 add 0253a28  Update gdb_bthread_stack.py
 new d15d340  Merge pull request #1521 from apache/tanzhongyi003-patch-3

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tools/gdb_bthread_stack.py | 17 +
 1 file changed, 17 insertions(+)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/01: Merge pull request #1521 from apache/tanzhongyi003-patch-3

2021-08-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit d15d340134d8e6527cc12cf8118b48c4dc38283d
Merge: 38f04c9 0253a28
Author: jamesge 
AuthorDate: Sat Aug 14 16:50:11 2021 +0800

Merge pull request #1521 from apache/tanzhongyi003-patch-3

Update gdb_bthread_stack.py

 tools/gdb_bthread_stack.py | 17 +
 1 file changed, 17 insertions(+)

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add oncall.md

2021-08-12 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 757cede  add oncall.md
 new 38f04c9  Merge pull request #1517 from tanzhongyi003/master
757cede is described below

commit 757cede699d2805a293943a41e72fa8797fb96fc
Author: tanzhongyi003 
AuthorDate: Fri Aug 13 09:31:01 2021 +0800

add oncall.md
---
 community/oncall.md | 40 
 1 file changed, 40 insertions(+)

diff --git a/community/oncall.md b/community/oncall.md
new file mode 100644
index 000..c18fba8
--- /dev/null
+++ b/community/oncall.md
@@ -0,0 +1,40 @@
+# 值周工程师的职责如下
+
+## 1. 每天查看github上brpc项目待处理的Pull Request和Issue列表,负责问题的处理
+
+  *  包括标记issue,回复issue,关闭issue等;
+  *  判断issue是否是长期Issue,如果是则标记为Pending
+  *  判断Issue的类型,例如bug,enhancement, discussion等
+  *  把issue分配到熟悉该模块的贡献者(可在微信群里询问谁来负责)
+
+
+
+
+## 2. 轮值时间为一周
+  *  即从周日早上到下周六晚上
+
+
+## 3. 轮值结束需要
+  *  编写值周report,并发送到dev@brpc.apache.org邮件群中
+  *  提醒下一位轮值同学
+
+
+## 4. 值周顺序如下
+  * 朱佳顺 
+  * 李磊
+  * 蔡道进
+  * 何磊
+
+
+## 5. 值周记录如下
+
+|  时间   | 值周人  | 值周report|
+|    |   | --- |
+|   | 朱佳顺 | 
+|  21/06/2021 to 27/06/2021 | 李磊 | 
https://lists.apache.org/thread.html/rc9eb911bc6465c16bd8bb14f9d1f7c9548e13759101f43cf0300908a%40%3Cdev.brpc.apache.org%3E
+|   | 蔡道进 | 
+| 05/07/2021 - 12/07/2021  | 何磊 | 
https://lists.apache.org/thread.html/r3f67bc42ecdc07b25c39aedaf30aeae79039aa1cc3e6ad99364c8178%40%3Cdev.brpc.apache.org%3E
+
+
+
+

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: docs: fix server_push.md

2021-07-06 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 4653c39  docs: fix server_push.md
 new c8d2475  Merge pull request #1463 from lorinlee/fix-docs
4653c39 is described below

commit 4653c3932d28aaabb2e1cc5455a4d73435ffde61
Author: LorinLee 
AuthorDate: Tue Jul 6 23:47:03 2021 +0800

docs: fix server_push.md
---
 docs/cn/server_push.md | 2 +-
 docs/en/server_push.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/cn/server_push.md b/docs/cn/server_push.md
index c759950..5df8e59 100644
--- a/docs/cn/server_push.md
+++ b/docs/cn/server_push.md
@@ -6,7 +6,7 @@ server push指的是server端发生某事件后立刻向client端发送消息,
 
 # 远程事件
 
-和本地事件类似,分为两步:注册和通知。client发送一个代表**事件注册**的异步RPC至server,处理事件的代码写在对应的RPC回调中。此RPC同时也在等待通知,server收到请求后不直接回复,而是等到对应的本地事件触发时才调用done->Run()**通知**client发生了事件。可以看到server也是异步的。这个过程中如果连接断开,client端的RPC一般会很快失败,client可选择重试或结束。server端应通过Controller.NotifyOnFailed()及时获知连接断开的消息,并删除无用的done。
+和本地事件类似,分为两步:注册和通知。client发送一个代表**事件注册**的异步RPC至server,处理事件的代码写在对应的RPC回调中。此RPC同时也在等待通知,server收到请求后不直接回复,而是等到对应的本地事件触发时才调用done->Run()**通知**client发生了事件。可以看到server也是异步的。这个过程中如果连接断开,client端的RPC一般会很快失败,client可选择重试或结束。server端应通过Controller.NotifyOnCancel()及时获知连接断开的消息,并删除无用的done。
 
 这个模式在原理上类似[long 
polling](https://en.wikipedia.org/wiki/Push_technology#Long_polling),听上去挺古老,但可能仍是最有效的推送方式。“server
 
push“乍看是server访问client,与常见的client访问server方向相反,挺特殊的,但server发回client的response不也和“client访问server”方向相反么?为了理解response和push的区别,我们假定“client随时可能收到server推来的消息“,并推敲其中的细节:
 
diff --git a/docs/en/server_push.md b/docs/en/server_push.md
index 4b00287..c00c828 100644
--- a/docs/en/server_push.md
+++ b/docs/en/server_push.md
@@ -6,7 +6,7 @@ What "server push" refers to is: server sends a message to 
client after occurren
 
 ## Remote event
 
-Similar to local event, remote event is divided into two steps: registration 
and notification. The client sends an asynchronous RPC to the server for 
registration, and puts the event-handling code in the RPC callback. The RPC is 
also a part of the waiting for the notification, namely the server does not 
respond directly after receiving the request, instead it does not call 
done->Run() (to notify the client) until the local event triggers. As we see, 
the server is also asynchronous. If th [...]
+Similar to local event, remote event is divided into two steps: registration 
and notification. The client sends an asynchronous RPC to the server for 
registration, and puts the event-handling code in the RPC callback. The RPC is 
also a part of the waiting for the notification, namely the server does not 
respond directly after receiving the request, instead it does not call 
done->Run() (to notify the client) until the local event triggers. As we see, 
the server is also asynchronous. If th [...]
 
 This pattern is similar to [long 
polling](https://en.wikipedia.org/wiki/Push_technology#Long_polling) in some 
sense, sounds old but probably still be the most effective method. At first 
glance "server push" is server visiting client, opposite with ordinary client 
visiting server. But do you notice that, the response sent from server back to 
client is also in the opposite direction of "client visiting server"? In order 
to understand differences between response and push, let's analyze the [...]
 

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Update flat_map.h

2021-06-16 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 99338e6  Update flat_map.h
 new 0650582  Merge pull request #1352 from yanjianglu/master
99338e6 is described below

commit 99338e69b0180a7ca3fd1d825cca5708a3988e3d
Author: Jairo <947600...@qq.com>
AuthorDate: Tue Mar 9 16:46:10 2021 +0800

Update flat_map.h

Correct spelling mistakes
---
 src/butil/containers/flat_map.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/butil/containers/flat_map.h b/src/butil/containers/flat_map.h
index ef89aa6..2e4 100644
--- a/src/butil/containers/flat_map.h
+++ b/src/butil/containers/flat_map.h
@@ -247,7 +247,7 @@ public:
 { new (element_spaces) Element(other.element()); }
 bool is_valid() const { return next != (const Bucket*)-1UL; }
 void set_invalid() { next = (Bucket*)-1UL; }
-// NOTE: Only be called when in_valid() is true.
+// NOTE: Only be called when is_valid() is true.
 Element& element() {
 void* spaces = element_spaces; // Suppress strict-aliasing
 return *reinterpret_cast(spaces);

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: rm DISCLAIMER-WIP and use DISCLAIMER for 1.0 release

2021-06-16 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new b0e0332  rm DISCLAIMER-WIP and use DISCLAIMER for 1.0 release
 new b57dd31  Merge pull request #1432 from tanzhongyi003/master
b0e0332 is described below

commit b0e0332dadb6d22c4550cc3a06cb14742f05e025
Author: tanzhongyi003 
AuthorDate: Fri Jun 11 09:41:37 2021 +0800

rm DISCLAIMER-WIP and use DISCLAIMER for 1.0 release
---
 DISCLAIMER | 10 ++
 DISCLAIMER-WIP | 18 --
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/DISCLAIMER b/DISCLAIMER
new file mode 100644
index 000..e9d14bf
--- /dev/null
+++ b/DISCLAIMER
@@ -0,0 +1,10 @@
+Apache brpc is an effort undergoing incubation at 
+The Apache Software Foundation (ASF), sponsored by the name of Apache TLP 
sponsor. 
+
+Incubation is required of all newly accepted projects until a further review 
+indicates that the infrastructure, communications, and decision making process 
+have stabilized in a manner consistent with other successful ASF projects. 
+
+While incubation status is not necessarily a reflection of the completeness 
+or stability of the code, it does indicate that the project has yet to be 
+fully endorsed by the ASF.
diff --git a/DISCLAIMER-WIP b/DISCLAIMER-WIP
deleted file mode 100644
index 34769ec..000
--- a/DISCLAIMER-WIP
+++ /dev/null
@@ -1,18 +0,0 @@
-Apache brpc is an effort undergoing incubation at The Apache Software 
Foundation (ASF),
-sponsored by the Apache Incubator. Incubation is required of all newly 
accepted projects
-until a further review indicates that the infrastructure, communications, and 
decision
-making process have stabilized in a manner consistent with other successful 
ASF projects.
-While incubation status is not necessarily a reflection of the completeness or 
stability
-of the code, it does indicate that the project has yet to be fully endorsed by 
the ASF.
-
-Some of the incubating project's releases may not be fully compliant with ASF 
policy. For
-example, releases may have incomplete or un-reviewed licensing conditions. 
What follows is
-a list of known issues the project is currently aware of (note that this list, 
by definition,
-is likely to be incomplete):
-
- * Releases may have incomplete licensing conditions
-
-If you are planning to incorporate this work into your product/project, please 
be aware that
-you will need to conduct a thorough licensing review to determine the overall 
implications of
-including this work. For the current status of this project through the Apache 
Incubator
-visit: https://incubator.apache.org/projects/brpc.html

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (e9d8f84 -> 60159fc)

2021-02-02 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from e9d8f84  Merge pull request #1327 from lorinlee/fix-typo
 new 445d0c5  Fix package name in rpm spec
 new 6427794  Fix rpm build requires
 new c00c030  Fix building rpm under rhel/centos 6
 new 04a191a  Filter GLIBC_PRIVATE requires
 new 60159fc  Merge pull request #1324 from wasphin/feature/fix-rpm-spec

The 2179 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 package/rpm/brpc.spec | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Fix the compile error when using GCC compiler with asan enabled on Linux platform.

2020-12-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new c0453d9  Fix the compile error when using GCC compiler with asan 
enabled on Linux platform.
 new 25b68db  Merge pull request #1289 from warriorpaw/master
c0453d9 is described below

commit c0453d9130c60f05306ac97f40b6de9873b47e08
Author: warriorpaw 
AuthorDate: Thu Nov 19 22:28:46 2020 +0800

Fix the compile error when using GCC compiler with asan enabled on Linux 
platform.

Only reproduced and tested with x64 linux and gcc 7 / 8 / 10.
Not sure if this error exist on other platforms.
---
 src/bthread/context.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/bthread/context.cpp b/src/bthread/context.cpp
index 9c6d832..5098bc3 100644
--- a/src/bthread/context.cpp
+++ b/src/bthread/context.cpp
@@ -294,6 +294,7 @@ __asm (
 "jmp  *%edx\n"
 ".size bthread_jump_fcontext,.-bthread_jump_fcontext\n"
 ".section .note.GNU-stack,\"\",%progbits\n"
+".previous\n"
 );
 
 #endif
@@ -328,6 +329,7 @@ __asm (
 "hlt\n"
 ".size bthread_make_fcontext,.-bthread_make_fcontext\n"
 ".section .note.GNU-stack,\"\",%progbits\n"
+".previous\n"
 );
 
 #endif
@@ -371,6 +373,7 @@ __asm (
 "jmp  *%r8\n"
 ".size bthread_jump_fcontext,.-bthread_jump_fcontext\n"
 ".section .note.GNU-stack,\"\",%progbits\n"
+".previous\n"
 );
 
 #endif
@@ -397,6 +400,7 @@ __asm (
 "hlt\n"
 ".size bthread_make_fcontext,.-bthread_make_fcontext\n"
 ".section .note.GNU-stack,\"\",%progbits\n"
+".previous\n"
 );
 
 #endif


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Add rpm packaging spec

2020-12-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 5fa8506  Add rpm packaging spec
 new 2657d52  Merge pull request #1290 from wasphin/feature/packaging
5fa8506 is described below

commit 5fa850696dea206f4d2c0a93dca7bfb3d8cae9ba
Author: wxf 
AuthorDate: Sat Nov 21 16:53:30 2020 +0800

Add rpm packaging spec
---
 package/rpm/brpc.spec | 87 +++
 1 file changed, 87 insertions(+)

diff --git a/package/rpm/brpc.spec b/package/rpm/brpc.spec
new file mode 100644
index 000..002b0ab
--- /dev/null
+++ b/package/rpm/brpc.spec
@@ -0,0 +1,87 @@
+Name:  brpc
+Version:   0.9.7
+Release:   1%{?dist}
+Summary:   An industrial-grade RPC framework used throughout Baidu, with 
1,000,000+ instances(not counting clients) and thousands kinds of services.
+
+Group: Development
+License:   Apache2
+URL:   https://github.com/apache/incubator-brpc
+Source0:   incubator-brpc-%{name}.tar.gz
+
+%global __filter_GLIBC_PRIVATE 1
+
+%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%global use_devtoolset 0
+%else
+%global use_devtoolset 1
+%endif
+
+%if 0%{?use_devtoolset}
+BuildRequires: devtoolset-8-gcc-c++
+%endif
+
+BuildRequires: gflags-devel
+BuildRequires: protobuf-devel
+BuildRequires: leveldb-devel
+BuildRequires: openssl-devel
+Requires:  gflags
+Requires:  protobuf
+Requires:  leveldb
+Requires:  openssl-libs
+
+%description
+An industrial-grade RPC framework used throughout Baidu, with 1,000,000+ 
instances(not counting clients) and thousands kinds of services.
+"brpc" means "better RPC".
+
+%package devel
+Summary: The %{name} headers and shared development libraries
+Requires: %{name} = %{version}-%{release}
+%description devel
+Headers and shared object symbolic links for the %{name} library.
+
+%package static
+Summary: The %{name} static development libraries
+Requires: brpc-devel = %{version}-%{release}
+%description static
+Static %{name} libraries.
+
+%prep
+%setup -n incubator-%{name}-%{version}
+
+
+%build
+mkdir -p %{_target_platform}
+
+pushd %{_target_platform}
+
+%if 0%{?use_devtoolset}
+. /opt/rh/devtoolset-8/enable
+%endif
+
+%{cmake} ..
+
+make %{?_smp_mflags}
+popd
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+pushd %{_target_platform}
+%make_install
+popd
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%{_libdir}/libbrpc.so
+
+%files devel
+%{_includedir}/*
+%{_libdir}/pkgconfig/*
+
+%files static
+%{_libdir}/libbrpc.a
+
+%changelog
+


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (6502e0c -> 5451fc1)

2020-12-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 6502e0c  add an extra check on cutn in recordio
 new bec4cac  update status.md first latency percentile
 new b8f21a3  delete baidu inner svn code link
 new 3e6b5aa  update client.md file naming-service demo machine list
 new 5451fc1  Merge pull request #1258 from serverglen/update-doc

The 2162 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/cn/benchmark.md | 2 --
 docs/cn/client.md| 8 
 docs/cn/status.md| 2 +-
 docs/en/client.md| 8 
 docs/en/status.md| 2 +-
 5 files changed, 10 insertions(+), 12 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (4e31f54 -> 6502e0c)

2020-12-08 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 4e31f54  fix a incomplete check in recordio
 add 6502e0c  add an extra check on cutn in recordio

No new revisions were added by this update.

Summary of changes:
 src/butil/recordio.cc | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (f45d50d -> 4e31f54)

2020-12-08 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from f45d50d  Call DestroyData for ResetData returning false
 add 4e31f54  fix a incomplete check in recordio

No new revisions were added by this update.

Summary of changes:
 src/butil/recordio.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Call DestroyData for ResetData returning false

2020-12-06 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new f45d50d  Call DestroyData for ResetData returning false
f45d50d is described below

commit f45d50dca21816ac50f5c5616d71f7421b2575d8
Author: jamesge 
AuthorDate: Mon Dec 7 14:58:02 2020 +0800

Call DestroyData for ResetData returning false
---
 src/brpc/data_factory.h   | 3 ++-
 src/brpc/simple_data_pool.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/brpc/data_factory.h b/src/brpc/data_factory.h
index a487262..a0950f8 100644
--- a/src/brpc/data_factory.h
+++ b/src/brpc/data_factory.h
@@ -40,7 +40,8 @@ public:
 // Overwrite this method to reset the data before reuse. Nothing done by 
default.
 // Returns
 //   true:  the data can be kept for future reuse
-//   false: the data was already destroyed and should NOT be reused.
+//   false: the data is improper to be reused and should be sent to 
+//  DestoryData() immediately after calling this method
 virtual bool ResetData(void*) const { return true; }
 };
 
diff --git a/src/brpc/simple_data_pool.cpp b/src/brpc/simple_data_pool.cpp
index 9374da4..fe1d324 100644
--- a/src/brpc/simple_data_pool.cpp
+++ b/src/brpc/simple_data_pool.cpp
@@ -108,7 +108,7 @@ void SimpleDataPool::Return(void* data) {
 return;
 }
 if (!_factory->ResetData(data)) {
-return;
+return _factory->DestroyData(data); 
 }
 std::unique_lock mu(_mutex);
 if (_capacity == _size) {


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: SimpleDataPool::Return resets data before returning back to pool

2020-12-06 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new fb93753  SimpleDataPool::Return resets data before returning back to 
pool
fb93753 is described below

commit fb93753bc54666fb815ed2fe099b0a98a01ea61e
Author: jamesge 
AuthorDate: Mon Dec 7 12:40:16 2020 +0800

SimpleDataPool::Return resets data before returning back to pool
---
 src/brpc/data_factory.h|  15 ++-
 .../{simple_data_pool.h => simple_data_pool.cpp}   |  56 ++-
 src/brpc/simple_data_pool.h| 111 -
 3 files changed, 21 insertions(+), 161 deletions(-)

diff --git a/src/brpc/data_factory.h b/src/brpc/data_factory.h
index 4fd8bf5..a487262 100644
--- a/src/brpc/data_factory.h
+++ b/src/brpc/data_factory.h
@@ -24,19 +24,24 @@
 
 namespace brpc {
 
+//  thread safety 
+// Method implementations of this interface should be thread-safe
 class DataFactory {
 public:
 virtual ~DataFactory() {}
 
-// Implement this method to create a piece of data.
-// Notice that this method is const.
+// Implement this method to create a piece of data
 // Returns the data, NULL on error.
 virtual void* CreateData() const = 0;
 
-// Implement this method to destroy a piece of data that was created
-// by Create().
-// Notice that this method is const.
+// Implement this method to destroy data created by Create().
 virtual void DestroyData(void*) const = 0;
+
+// Overwrite this method to reset the data before reuse. Nothing done by 
default.
+// Returns
+//   true:  the data can be kept for future reuse
+//   false: the data was already destroyed and should NOT be reused.
+virtual bool ResetData(void*) const { return true; }
 };
 
 } // namespace brpc
diff --git a/src/brpc/simple_data_pool.h b/src/brpc/simple_data_pool.cpp
similarity index 69%
copy from src/brpc/simple_data_pool.h
copy to src/brpc/simple_data_pool.cpp
index 4ab3f1f..9374da4 100644
--- a/src/brpc/simple_data_pool.h
+++ b/src/brpc/simple_data_pool.cpp
@@ -16,46 +16,11 @@
 // under the License.
 
 
-#ifndef BRPC_SIMPLE_DATA_POOL_H
-#define BRPC_SIMPLE_DATA_POOL_H
-
-#include "butil/scoped_lock.h"
-#include "brpc/data_factory.h"
-
+#include "brpc/simple_data_pool.h"
 
 namespace brpc {
 
-// As the name says, this is a simple unbounded dynamic-size pool for
-// reusing void* data. We're assuming that data consumes considerable
-// memory and should be reused as much as possible, thus unlike the
-// multi-threaded allocator caching objects thread-locally, we just
-// put everything in a global list to maximize sharing. It's currently
-// used by Server to reuse session-local data. 
-class SimpleDataPool {
-public:
-struct Stat {
-unsigned nfree;
-unsigned ncreated;
-};
-
-explicit SimpleDataPool(const DataFactory* factory);
-~SimpleDataPool();
-void Reset(const DataFactory* factory);
-void Reserve(unsigned n);
-void* Borrow();
-void Return(void*);
-Stat stat() const;
-
-private:
-butil::Mutex _mutex;
-unsigned _capacity;
-unsigned _size;
-butil::atomic _ncreated;
-void** _pool;
-const DataFactory* _factory;
-};
-
-inline SimpleDataPool::SimpleDataPool(const DataFactory* factory)
+SimpleDataPool::SimpleDataPool(const DataFactory* factory)
 : _capacity(0)
 , _size(0)
 , _ncreated(0)
@@ -63,11 +28,11 @@ inline SimpleDataPool::SimpleDataPool(const DataFactory* 
factory)
 , _factory(factory) {
 }
 
-inline SimpleDataPool::~SimpleDataPool() {
+SimpleDataPool::~SimpleDataPool() {
 Reset(NULL);
 }
 
-inline void SimpleDataPool::Reset(const DataFactory* factory) {
+void SimpleDataPool::Reset(const DataFactory* factory) {
 unsigned saved_size = 0;
 void** saved_pool = NULL;
 const DataFactory* saved_factory = NULL;
@@ -92,7 +57,7 @@ inline void SimpleDataPool::Reset(const DataFactory* factory) 
{
 }
 }
 
-inline void SimpleDataPool::Reserve(unsigned n) {
+void SimpleDataPool::Reserve(unsigned n) {
 if (_capacity >= n) {
 return;
 }
@@ -124,7 +89,7 @@ inline void SimpleDataPool::Reserve(unsigned n) {
 }
 }
 
-inline void* SimpleDataPool::Borrow() {
+void* SimpleDataPool::Borrow() {
 if (_size) {
 BAIDU_SCOPED_LOCK(_mutex);
 if (_size) {
@@ -138,10 +103,13 @@ inline void* SimpleDataPool::Borrow() {
 return data;
 }
 
-inline void SimpleDataPool::Return(void* data) {
+void SimpleDataPool::Return(void* data) {
 if (data == NULL) {
 return;
 }
+if (!_factory->ResetData(data)) {
+return;
+}
 std::unique_lock mu(_mutex);
 if (_capacity == _size) {
 const unsigned new_cap = (_capacity <= 1 ? 128 : (_capacity * 3 / 2));
@@ -16

[incubator-brpc] branch master updated: fix CMakeList.txt in examples and rename BUILD to BUILD.bazel to avoid conflict with cmake

2020-12-04 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new e93e0c2  fix CMakeList.txt in examples and rename BUILD to BUILD.bazel 
to avoid conflict with cmake
e93e0c2 is described below

commit e93e0c2afef5350a05e18cebf1a9677d345af5ec
Author: jamesge 
AuthorDate: Sat Dec 5 14:51:40 2020 +0800

fix CMakeList.txt in examples and rename BUILD to BUILD.bazel to avoid 
conflict with cmake
---
 BUILD => BUILD.bazel   |   0
 docs/cn/getting_started.md |  87 +++-
 docs/cn/thrift.md  |   2 +-
 docs/en/thrift.md  |   2 +-
 example/asynchronous_echo_c++/CMakeLists.txt   |  17 ++-
 example/auto_concurrency_limiter/CMakeLists.txt|  19 +--
 example/backup_request_c++/CMakeLists.txt  |  17 ++-
 example/cancel_c++/CMakeLists.txt  |  17 ++-
 example/cascade_echo_c++/CMakeLists.txt|  17 ++-
 example/dynamic_partition_echo_c++/CMakeLists.txt  |  18 +--
 example/echo_c++/CMakeLists.txt|   9 +-
 example/echo_c++_hulu_pbrpc/CMakeLists.txt | 145 ---
 example/echo_c++_hulu_pbrpc/Makefile   |  18 ---
 example/echo_c++_hulu_pbrpc/client.cpp |  93 
 example/echo_c++_hulu_pbrpc/echo.proto |  33 -
 example/echo_c++_hulu_pbrpc/server.cpp | 120 
 example/echo_c++_sofa_pbrpc/CMakeLists.txt | 145 ---
 example/echo_c++_sofa_pbrpc/Makefile   |  18 ---
 example/echo_c++_sofa_pbrpc/client.cpp |  84 ---
 example/echo_c++_sofa_pbrpc/echo.proto |  33 -
 example/echo_c++_sofa_pbrpc/server.cpp |  98 -
 example/echo_c++_ubrpc_compack/CMakeLists.txt  | 150 
 example/echo_c++_ubrpc_compack/Makefile|  19 ---
 example/echo_c++_ubrpc_compack/client.cpp  | 133 --
 example/echo_c++_ubrpc_compack/echo.proto  |  67 -
 example/echo_c++_ubrpc_compack/idl_options.proto   |  54 ---
 example/echo_c++_ubrpc_compack/server.cpp  | 118 
 example/grpc_c++/CMakeLists.txt|  21 +--
 example/http_c++/CMakeLists.txt|  18 +--
 example/memcache_c++/CMakeLists.txt|  17 ++-
 example/multi_threaded_echo_c++/CMakeLists.txt |  31 ++--
 example/multi_threaded_echo_fns_c++/CMakeLists.txt |  18 +--
 example/multi_threaded_mcpack_c++/CMakeLists.txt   | 155 
 example/multi_threaded_mcpack_c++/Makefile |  19 ---
 example/multi_threaded_mcpack_c++/client.cpp   | 156 -
 example/multi_threaded_mcpack_c++/echo.proto   |  36 -
 .../multi_threaded_mcpack_c++/idl_options.proto|  54 ---
 example/multi_threaded_mcpack_c++/server.cpp   |  83 ---
 example/nshead_extension_c++/CMakeLists.txt|  17 ++-
 example/nshead_pb_extension_c++/CMakeLists.txt |  17 ++-
 example/parallel_echo_c++/CMakeLists.txt   |  18 +--
 example/partition_echo_c++/CMakeLists.txt  |  18 +--
 example/redis_c++/CMakeLists.txt   |  17 ++-
 example/selective_echo_c++/CMakeLists.txt  |  18 +--
 .../session_data_and_thread_local/CMakeLists.txt   |  14 +-
 example/streaming_echo_c++/CMakeLists.txt  |  17 ++-
 46 files changed, 192 insertions(+), 2085 deletions(-)

diff --git a/BUILD b/BUILD.bazel
similarity index 100%
rename from BUILD
rename to BUILD.bazel
diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md
index 0b70895..4d10ef6 100644
--- a/docs/cn/getting_started.md
+++ b/docs/cn/getting_started.md
@@ -73,28 +73,32 @@ $ sh run_tests.sh
 
 ### Compile brpc with cmake
 ```shell
-mkdir bld && cd bld && cmake .. && make
+cmake -B build && cmake --build build -j6
 ```
-To change compiler to clang, overwrite environment variable CC and CXX to 
clang and clang++.
+To help VSCode or Emacs(LSP) to understand code correctly, add 
`-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` to generate `compile_commands.json`
 
-To not link debugging symbols, use `rm -f CMakeCache.txt && cmake 
-DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller.
+To change compiler to clang, overwrite environment variable `CC` and `CXX` to 
`clang` and `clang++` respectively.
 
-To use brpc with glog, add `-DWITH_GLOG=ON`.
+To not link debugging symbols, remove `build/CMakeCache.txt` and cmake with 
`-DWITH_DEBUG_SYMBOLS=OFF`
 
-To enable [thrift support](../en/thrift.md), install thrift first and add 
`-DWITH_THRIFT=ON`.
+To use brpc with glog, cmake with `-DWITH_GLOG=ON`.
+
+To enable [thrift support](../en

[incubator-brpc] branch rdma updated (9028c39 -> 62240fe)

2020-12-03 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch rdma
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 9028c39  Merge pull request #916 from Tuvie/master
 new 6581dab  fix two bugs: 1) fd leak when destroy rdma cq channel; 2) 
listen on incorrect internal port when using rdma
 new 05c4f70  fix the bug of creating CQs on incorrect comp vector
 new 62240fe  Merge pull request #1002 from Tuvie/master

The 1873 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CMakeLists.txt   |   7 --
 example/rdma_performance/client.cpp  |   8 +-
 src/brpc/rdma/rdma_communication_manager.cpp |   9 ++-
 src/brpc/rdma/rdma_completion_queue.cpp  |  89 -
 src/brpc/rdma/rdma_completion_queue.h|   8 +-
 src/brpc/rdma/rdma_endpoint.cpp  |  16 +++-
 src/brpc/rdma/rdma_endpoint.h|  10 ++-
 src/brpc/rdma/spsc_queue.h   | 112 +++
 src/brpc/server.cpp  |  12 +--
 src/brpc/socket.cpp  |  14 +++-
 test/brpc_naming_service_unittest.cpp|  26 +++
 test/brpc_redis_unittest.cpp |  21 -
 12 files changed, 245 insertions(+), 87 deletions(-)
 create mode 100644 src/brpc/rdma/spsc_queue.h


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (29ab898 -> 8ff49b3)

2020-11-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 29ab898  Merge pull request #1295 from lrita/l_s
 new 6d06398  make butil::ScopedVector support initializer_list
 new cd6fc15  make butil::ScopedVector support initializer_list
 new 1c02d48  remove #include  in scoped_vector.h
 new 8ff49b3  Merge pull request #1291 from lrita/l_m

The 2153 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/butil/memory/scoped_vector.h |  3 +++
 test/scoped_vector_unittest.cc   | 11 +++
 2 files changed, 14 insertions(+)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (e64eb3c -> 29ab898)

2020-11-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from e64eb3c  partial fix for profiling under MacOS, symbols are not shown 
yet(even with llvm-symbolizer)
 new 1015264  make butil::BasicStringPiece support string split 
functions-family
 new 32c05be  make butil::BasicStringPiece support string split 
functions-family
 new 29ab898  Merge pull request #1295 from lrita/l_s

The 2149 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/butil/strings/string_piece.h  |   7 +++
 src/butil/strings/string_split.cc | 103 --
 src/butil/strings/string_split.h  |  28 +++
 src/butil/strings/string_util.cc  |  21 +++-
 src/butil/strings/string_util.h   |  11 +++-
 test/string_split_unittest.cc |  64 +++
 6 files changed, 218 insertions(+), 16 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (9320f1c -> e64eb3c)

2020-11-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 9320f1c  Merge pull request #1298 from apache/fix_bazel_on_macos
 new 61667b2  more accurate assertion
 new e64eb3c  partial fix for profiling under MacOS, symbols are not shown 
yet(even with llvm-symbolizer)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/builtin/hotspots_service.cpp  | 7 +--
 test/baidu_thread_local_unittest.cpp   | 6 +++---
 test/brpc_builtin_service_unittest.cpp | 6 +++---
 3 files changed, 11 insertions(+), 8 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 02/02: partial fix for profiling under MacOS, symbols are not shown yet(even with llvm-symbolizer)

2020-11-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit e64eb3ce15359263aabf2254379c9130ccff7929
Author: jamesge 
AuthorDate: Mon Nov 30 21:33:20 2020 +0800

partial fix for profiling under MacOS, symbols are not shown yet(even with 
llvm-symbolizer)
---
 src/brpc/builtin/hotspots_service.cpp  | 7 +--
 test/brpc_builtin_service_unittest.cpp | 6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/brpc/builtin/hotspots_service.cpp 
b/src/brpc/builtin/hotspots_service.cpp
index b4e8fcf..7f23a0b 100644
--- a/src/brpc/builtin/hotspots_service.cpp
+++ b/src/brpc/builtin/hotspots_service.cpp
@@ -376,6 +376,7 @@ static void NotifyWaiters(ProfilingType type, const 
Controller* cur_cntl,
 }
 
 #if defined(OS_MACOSX)
+static const char* s_pprof_binary_path = nullptr;
 static bool check_GOOGLE_PPROF_BINARY_PATH() {
 char* str = getenv("GOOGLE_PPROF_BINARY_PATH");
 if (str == NULL) {
@@ -385,6 +386,7 @@ static bool check_GOOGLE_PPROF_BINARY_PATH() {
 if (fd < 0) {
 return false;
 }
+s_pprof_binary_path = strdup(str);
 return true;
 }
 
@@ -491,13 +493,13 @@ static void DisplayResult(Controller* cntl,
 }
 cmd_builder << " 2>&1 ";
 #elif defined(OS_MACOSX)
-cmd_builder << getenv("GOOGLE_PPROF_BINARY_PATH") << " "
+cmd_builder << s_pprof_binary_path << " "
 << DisplayTypeToPProfArgument(display_type)
 << (show_ccount ? " -contentions " : "");
 if (base_name) {
 cmd_builder << "-base " << *base_name << ' ';
 }
-cmd_builder << prof_name << " 2>&1 ";
+cmd_builder << GetProgramName() << " " << prof_name << " 2>&1 ";
 #endif
 
 const std::string cmd = cmd_builder.str();
@@ -517,6 +519,7 @@ static void DisplayResult(Controller* cntl,
 errno = 0; // read_command_output may not set errno, clear it to make 
sure if
// we see non-zero errno, it's real error.
 butil::IOBufBuilder pprof_output;
+RPC_VLOG << "Running cmd=" << cmd;
 const int rc = butil::read_command_output(pprof_output, cmd.c_str());
 if (rc != 0) {
 butil::FilePath pprof_path(pprof_tool);
diff --git a/test/brpc_builtin_service_unittest.cpp 
b/test/brpc_builtin_service_unittest.cpp
index d9a24a8..21f6f50 100644
--- a/test/brpc_builtin_service_unittest.cpp
+++ b/test/brpc_builtin_service_unittest.cpp
@@ -663,15 +663,15 @@ TEST_F(BuiltinServiceTest, pprof) {
 ClosureChecker done;
 brpc::Controller cntl;
 service.heap(, NULL, NULL, );
-const int rc = getenv("TCMALLOC_SAMPLE_PARAMETER") ? 0 : 
brpc::ENOMETHOD;
-EXPECT_EQ(rc, cntl.ErrorCode());
+const int rc = getenv("TCMALLOC_SAMPLE_PARAMETER") != nullptr ? 0 : 
brpc::ENOMETHOD;
+EXPECT_EQ(rc, cntl.ErrorCode()) << cntl.ErrorText();
 }
 {
 ClosureChecker done;
 brpc::Controller cntl;
 service.growth(, NULL, NULL, );
 // linked tcmalloc in UT
-EXPECT_EQ(0, cntl.ErrorCode());
+EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText();
 }
 {
 ClosureChecker done;


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/02: more accurate assertion

2020-11-30 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 61667b29b7d944eae8702c0ddf330c4975894c25
Author: jamesge 
AuthorDate: Mon Nov 30 21:32:26 2020 +0800

more accurate assertion
---
 test/baidu_thread_local_unittest.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/baidu_thread_local_unittest.cpp 
b/test/baidu_thread_local_unittest.cpp
index 7ffe0f5..01209b6 100644
--- a/test/baidu_thread_local_unittest.cpp
+++ b/test/baidu_thread_local_unittest.cpp
@@ -166,17 +166,17 @@ void fun2() {
 }
 
 void fun3(void* arg) {
-get_oss() << "fun3(" << arg << ")" << std::endl;
+get_oss() << "fun3(" << (uintptr_t)arg << ")" << std::endl;
 }
 
 void fun4(void* arg) {
-get_oss() << "fun4(" << arg << ")" << std::endl;
+get_oss() << "fun4(" << (uintptr_t)arg << ")" << std::endl;
 }
 
 static void check_result() {
   // Don't use gtest function since this function might be invoked when the 
main
   // thread quits, instances required by gtest functions are likely destroyed.
-  assert (get_oss().str() == "fun4(0)\nfun3(0x2)\nfun2\n");
+  assert(get_oss().str() == "fun4(0)\nfun3(2)\nfun2\n");
 }
 
 TEST_F(BaiduThreadLocalTest, call_order_and_cancel) {


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (20f2b4a -> 31eba30)

2020-11-29 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 20f2b4a  Support pass down request_id
 add 31eba30  change travis-ci.org to travis-ci.com

No new revisions were added by this update.

Summary of changes:
 README.md| 2 +-
 README_cn.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Support pass down request_id

2020-11-29 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 20f2b4a  Support pass down request_id
20f2b4a is described below

commit 20f2b4a887bb693382b47b7ff24a726d29eb224d
Author: jamesge 
AuthorDate: Sun Nov 29 16:07:25 2020 +0800

Support pass down request_id
---
 example/cascade_echo_c++/client.cpp| 10 +
 example/cascade_echo_c++/server.cpp| 10 -
 src/brpc/controller.cpp| 23 +---
 src/brpc/controller.h  | 39 +-
 src/brpc/policy/baidu_rpc_meta.proto   |  1 +
 src/brpc/policy/baidu_rpc_protocol.cpp |  6 ++
 src/brpc/policy/http_rpc_protocol.cpp  | 16 +++---
 src/butil/fast_rand.cpp| 15 +
 src/butil/fast_rand.h  |  7 +-
 test/brpc_controller_unittest.cpp  |  2 +-
 10 files changed, 101 insertions(+), 28 deletions(-)

diff --git a/example/cascade_echo_c++/client.cpp 
b/example/cascade_echo_c++/client.cpp
index 1bb7005..cb545b6 100644
--- a/example/cascade_echo_c++/client.cpp
+++ b/example/cascade_echo_c++/client.cpp
@@ -26,8 +26,9 @@
 #include 
 #include "echo.pb.h"
 #include 
+#include 
 
-DEFINE_int32(thread_num, 4, "Number of threads to send requests");
+DEFINE_int32(thread_num, 2, "Number of threads to send requests");
 DEFINE_bool(use_bthread, false, "Use bthread to send requests");
 DEFINE_string(attachment, "foo", "Carry this along with requests");
 DEFINE_string(connection_type, "", "Connection type. Available values: single, 
pooled, short");
@@ -38,7 +39,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the 
first RPC)");
 DEFINE_string(protocol, "baidu_std", "Protocol type. Defined in 
src/brpc/options.proto");
 DEFINE_int32(depth, 0, "number of loop calls");
 // Don't send too frequently in this example
-DEFINE_int32(sleep_ms, 100, "milliseconds to sleep after each RPC");
+DEFINE_int32(sleep_ms, 1000, "milliseconds to sleep after each RPC");
 DEFINE_int32(dummy_port, -1, "Launch dummy server at this port");
 
 bvar::LatencyRecorder g_latency_recorder("client");
@@ -50,7 +51,6 @@ void* sender(void* arg) {
 example::EchoService_Stub stub(chan);
 
 // Send a request and wait for the response every 1 second.
-int log_id = 0;
 while (!brpc::IsAskedToQuit()) {
 // We will receive response synchronously, safe to put variables
 // on stack.
@@ -63,7 +63,9 @@ void* sender(void* arg) {
 request.set_depth(FLAGS_depth);
 }
 
-cntl.set_log_id(log_id ++);  // set by user
+// Set request_id to be a random string
+cntl.set_request_id(butil::fast_rand_printable(9));
+
 // Set attachment which is wired to network directly instead of 
 // being serialized into protobuf messages.
 cntl.request_attachment().append(FLAGS_attachment);
diff --git a/example/cascade_echo_c++/server.cpp 
b/example/cascade_echo_c++/server.cpp
index b8f1c04..47f1dd9 100644
--- a/example/cascade_echo_c++/server.cpp
+++ b/example/cascade_echo_c++/server.cpp
@@ -52,27 +52,25 @@ public:
 static_cast(cntl_base);
 
 if (request->depth() > 0) {
-TRACEPRINTF("I'm about to call myself for another time, depth=%d",
-request->depth());
+CLOGI(cntl) << "I'm about to call myself for another time, depth=" 
<< request->depth();
 example::EchoService_Stub stub();
 example::EchoRequest request2;
 example::EchoResponse response2;
-brpc::Controller cntl2;
+brpc::Controller cntl2(cntl->inheritable());
 request2.set_message(request->message());
 request2.set_depth(request->depth() - 1);
 
-cntl2.set_log_id(cntl->log_id());
 cntl2.set_timeout_ms(FLAGS_timeout_ms);
 cntl2.set_max_retry(FLAGS_max_retry);
 stub.Echo(, , , NULL);
 if (cntl2.Failed()) {
-LOG(ERROR) << "Fail to send EchoRequest, " << 
cntl2.ErrorText();
+CLOGE() << "Fail to send EchoRequest, " << 
cntl2.ErrorText();
 cntl->SetFailed(cntl2.ErrorCode(), "%s", 
cntl2.ErrorText().c_str());
 return;
 }
 response->set_message(response2.message());
 } else {
-TRACEPRINTF("I'm the last call");
+CLOGI(cntl) << "I'm the last call";
 response->set_message(request->message());

[incubator-brpc] branch master updated: Use = as non-json sep; Rename LOG* macros to CLOG*

2020-11-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new d06e330  Use = as non-json sep; Rename LOG* macros to CLOG*
d06e330 is described below

commit d06e330533dacb44ecf0282dd7cc0b62307fda4f
Author: jamesge 
AuthorDate: Sun Nov 29 13:56:35 2020 +0800

Use = as non-json sep; Rename LOG* macros to CLOG*
---
 src/brpc/controller.cpp   |  2 +-
 src/brpc/controller.h | 15 ---
 test/brpc_controller_unittest.cpp |  6 +++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index e88e3e1..a3c77e0 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -1509,7 +1509,7 @@ KVMap& Controller::SessionKV() {
 
 #define BRPC_SESSION_END_MSG "Session ends."
 #define BRPC_REQ_ID "@rid"
-#define BRPC_KV_SEP ":"
+#define BRPC_KV_SEP "="
 
 void Controller::FlushSessionKV(std::ostream& os) {
 if (_session_kv == nullptr || _session_kv->Count() == 0) {
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index b1689cf..9118633 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -814,12 +814,13 @@ std::ostream& operator<<(std::ostream& os, const 
Controller::LogPrefixDummy& p);
 
 } // namespace brpc
 
-// Print logs appended with @rid which is got from "x-request-id"(set 
-// -request_id_header to change) in http header by default
-#define LOGD(cntl) LOG(DEBUG) << (cntl)->LogPrefix()
-#define LOGI(cntl) LOG(INFO) << (cntl)->LogPrefix()
-#define LOGW(cntl) LOG(WARNING) << (cntl)->LogPrefix()
-#define LOGE(cntl) LOG(ERROR) << (cntl)->LogPrefix()
-#define LOGF(cntl) LOG(FATAL) << (cntl)->LogPrefix()
+// Print contextual logs with @rid which is got from "x-request-id"(changable
+// by -request_id_header) in http header by default
+#define CLOGD(cntl) LOG(DEBUG) << (cntl)->LogPrefix()
+#define CLOGI(cntl) LOG(INFO) << (cntl)->LogPrefix()
+#define CLOGW(cntl) LOG(WARNING) << (cntl)->LogPrefix()
+#define CLOGE(cntl) LOG(ERROR) << (cntl)->LogPrefix()
+#define CLOGF(cntl) LOG(FATAL) << (cntl)->LogPrefix()
+#define CVLOG(v, cntl) VLOG(v) << (cntl)->LogPrefix()
 
 #endif  // BRPC_CONTROLLER_H
diff --git a/test/brpc_controller_unittest.cpp 
b/test/brpc_controller_unittest.cpp
index 9b999b9..0def06d 100644
--- a/test/brpc_controller_unittest.cpp
+++ b/test/brpc_controller_unittest.cpp
@@ -117,14 +117,14 @@ TEST_F(ControllerTest, SessionKV) {
 
 cntl.SessionKV().Set("Cisco", 33.33);
 
-LOGW() << "My WARNING Log";
+CLOGW() << "My WARNING Log";
 ASSERT_TRUE(endsWith(sink1, "] My WARNING Log")) << sink1;
 ASSERT_TRUE(startsWith(sink1, "W")) << sink1;
 sink1.clear();
 
 cntl.http_request().SetHeader("x-request-id", "abcdEFG-456");
-LOGE() << "My ERROR Log";
-ASSERT_TRUE(endsWith(sink1, "] @rid:abcdEFG-456 My ERROR Log")) << 
sink1;
+CLOGE() << "My ERROR Log";
+ASSERT_TRUE(endsWith(sink1, "] @rid=abcdEFG-456 My ERROR Log")) << 
sink1;
 ASSERT_TRUE(startsWith(sink1, "E")) << sink1;
 sink1.clear();
 


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Replace previous hacky impl. of appending postfix to ostream with a safer one and lose the -log_as_json support for glog

2020-11-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 5f7e048  Replace previous hacky impl. of appending postfix to ostream 
with a safer one and lose the -log_as_json support for glog
5f7e048 is described below

commit 5f7e0480bae0c2b2c212803072eb330e0eaf9108
Author: jamesge 
AuthorDate: Fri Nov 27 15:33:45 2020 +0800

Replace previous hacky impl. of appending postfix to ostream with a safer 
one and lose the -log_as_json support for glog
---
 src/brpc/controller.cpp   | 45 +++---
 src/brpc/controller.h | 28 --
 src/butil/logging.cc  | 79 ---
 test/brpc_controller_unittest.cpp | 26 ++---
 4 files changed, 82 insertions(+), 96 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index f343edb..e88e3e1 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -1507,7 +1507,7 @@ KVMap& Controller::SessionKV() {
 return *_session_kv.get();
 }
 
-#define BRPC_SESSION_END_MSG "Session ends"
+#define BRPC_SESSION_END_MSG "Session ends."
 #define BRPC_REQ_ID "@rid"
 #define BRPC_KV_SEP ":"
 
@@ -1522,62 +1522,43 @@ void Controller::FlushSessionKV(std::ostream& os) {
 }
 
 if (FLAGS_log_as_json) {
-os << "\"M\":\"" BRPC_SESSION_END_MSG "\"";
 if (pRID) {
-os << ",\"" BRPC_REQ_ID "\":\"" << *pRID << '"';
+os << "\"" BRPC_REQ_ID "\":\"" << *pRID << "\",";
 }
+os << "\"M\":\"" BRPC_SESSION_END_MSG "\"";
 for (auto it = _session_kv->Begin(); it != _session_kv->End(); ++it) {
 os << ",\"" << it->first << "\":\"" << it->second << '"';
 }
 } else {
-os << BRPC_SESSION_END_MSG;
 if (pRID) {
-os << " " BRPC_REQ_ID BRPC_KV_SEP << *pRID;
+os << BRPC_REQ_ID BRPC_KV_SEP << *pRID << " ";
 }
+os << BRPC_SESSION_END_MSG;
 for (auto it = _session_kv->Begin(); it != _session_kv->End(); ++it) {
 os << ' ' << it->first << BRPC_KV_SEP << it->second;
 }
 }
 }
 
-Controller::LogPostfixDummy::~LogPostfixDummy() {
-if (osptr != nullptr) {
-*osptr << postfix;
-}
-}
-
-std::ostream& operator<<(std::ostream& os, const Controller::LogPostfixDummy& 
p) {
-const_cast(p).osptr = 
-if (FLAGS_log_as_json) {
-os << "\"M\":\"";
-}
+std::ostream& operator<<(std::ostream& os, const Controller::LogPrefixDummy& 
p) {
+p.DoPrintLogPrefix(os);
 return os;
 }
-
-
-Controller::LogPostfixDummy Controller::LogPostfix() const {
-Controller::LogPostfixDummy result;
-std::string& p = result.postfix;
-if (FLAGS_log_as_json) {
-p.push_back('"');
-}
+void Controller::DoPrintLogPrefix(std::ostream& os) const {
 const std::string* pRID = nullptr;
 if (_http_request) {
 pRID = _http_request->GetHeader(FLAGS_request_id_header);
 if (pRID) {
 if (FLAGS_log_as_json) {
-p.append(",\"" BRPC_REQ_ID "\":\"");
-p.append(*pRID);
-p.push_back('"');
+os << BRPC_REQ_ID "\":\"" << *pRID << "\",";
 } else {
-p.reserve(5 + pRID->size());
-p.append(" " BRPC_REQ_ID BRPC_KV_SEP);
-p.append(*pRID);
+os << BRPC_REQ_ID BRPC_KV_SEP << *pRID << " ";
 }
-
 }
 }
-return result;
+if (FLAGS_log_as_json) {
+os << "\"M\":\"";
+}
 }
 
 } // namespace brpc
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index 8a75c54..b1689cf 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -491,13 +491,15 @@ public:
 void FlushSessionKV(std::ostream& os);
 
 // Contextual prefixes for LOGD/LOGI/LOGW/LOGE/LOGF macros
-struct LogPostfixDummy {
-LogPostfixDummy() : osptr(nullptr) {}
-~LogPostfixDummy();
-std::string postfix;
-std::ostream* osptr;
+class LogPrefixDummy {
+public:
+LogPrefixDummy(const Controller* cntl) : _cntl

[incubator-brpc] branch fix_crash_of_ut updated: add debugging code

2020-11-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch fix_crash_of_ut
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/fix_crash_of_ut by this push:
 new 3e38b26  add debugging code
3e38b26 is described below

commit 3e38b26d9cb6e3a7a58d4765546e918af50bd6d2
Author: jamesge 
AuthorDate: Fri Nov 27 13:13:17 2020 +0800

add debugging code
---
 src/brpc/controller.cpp   | 19 ++-
 src/brpc/controller.h |  1 +
 test/brpc_controller_unittest.cpp |  8 +---
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index f343edb..fa59919 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include "bthread/bthread.h"
+#include "butil/atomicops.h"
 #include "butil/build_config.h"// OS_MACOSX
 #include "butil/string_printf.h"
 #include "butil/logging.h"
@@ -1542,14 +1543,30 @@ void Controller::FlushSessionKV(std::ostream& os) {
 
 Controller::LogPostfixDummy::~LogPostfixDummy() {
 if (osptr != nullptr) {
+std::cout << "osptr=" << osptr << std::endl;
 *osptr << postfix;
 }
 }
+static void testfn(std::ios::event ev, std::ios_base& stream, int index) {
+switch (ev) {
+case std::ios_base::copyfmt_event:
+std::cout << "copyfmt_event"; break;
+case std::ios_base::imbue_event:
+std::cout << "imbue_event"; break;
+case std::ios_base::erase_event: 
+std::cout << "erase_event"; break;
+}
+std::cout << " ptr=" <<  << " index=" << index << std::endl;
+}
 
+butil::static_atomic _counter;
 std::ostream& operator<<(std::ostream& os, const Controller::LogPostfixDummy& 
p) {
+const auto index = _counter.fetch_add(1, butil::memory_order_relaxed);
+os.register_callback(testfn, index);
 const_cast(p).osptr = 
+os << "Index=" << index << ' ' ;
 if (FLAGS_log_as_json) {
-os << "\"M\":\"";
+os << "\"M\":\"" << index;
 }
 return os;
 }
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index 8a75c54..761b5fb 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -493,6 +493,7 @@ public:
 // Contextual prefixes for LOGD/LOGI/LOGW/LOGE/LOGF macros
 struct LogPostfixDummy {
 LogPostfixDummy() : osptr(nullptr) {}
+LogPostfixDummy(const LogPostfixDummy&) : osptr(nullptr) {}
 ~LogPostfixDummy();
 std::string postfix;
 std::ostream* osptr;
diff --git a/test/brpc_controller_unittest.cpp 
b/test/brpc_controller_unittest.cpp
index 011928c..606b0f7 100644
--- a/test/brpc_controller_unittest.cpp
+++ b/test/brpc_controller_unittest.cpp
@@ -95,7 +95,6 @@ TEST_F(ControllerTest, SessionKV) {
 FLAGS_log_as_json = false;
 logging::StringSink sink1;
 auto oldSink = logging::SetLogSink();
-//brpc::SetGlobalSessionLogFormatter(new MyFormatter);
 {
 brpc::Controller cntl;
 cntl.set_log_id(123); // not working now
@@ -104,18 +103,21 @@ TEST_F(ControllerTest, SessionKV) {
 cntl.SessionKV().Set("Cisco", 33.3);
 
 LOGW() << "My WARNING Log";
-ASSERT_TRUE(endsWith(sink1, "] My WARNING Log")) << sink1;
+//ASSERT_TRUE(endsWith(sink1, "] My WARNING Log")) << sink1;
 ASSERT_TRUE(startsWith(sink1, "W")) << sink1;
+std::cout << sink1 << std::endl;
 sink1.clear();
 
 cntl.http_request().SetHeader("x-request-id", "abcdEFG-456");
 LOGE() << "My ERROR Log";
-ASSERT_TRUE(endsWith(sink1, "] My ERROR Log @rid:abcdEFG-456")) << 
sink1;
+//ASSERT_TRUE(endsWith(sink1, "] My ERROR Log @rid:abcdEFG-456")) << 
sink1;
 ASSERT_TRUE(startsWith(sink1, "E")) << sink1;
+std::cout << sink1 << std::endl;
 sink1.clear();
 
 FLAGS_log_as_json = true;
 }
+std::cout << sink1 << std::endl;
 ASSERT_TRUE(endsWith(sink1, R"(,"M":"Session 
ends","@rid":"abcdEFG-456","Baidu":"22","Cisco":"33.30","Apple":"1"})")) << 
sink1;
 ASSERT_TRUE(startsWith(sink1, R"({"L":"I",)")) << sink1;
 


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch fix_crash_of_ut created (now c1dd203)

2020-11-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch fix_crash_of_ut
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


  at c1dd203  add a null check in ~LogPostfixDummy

No new revisions were added by this update.


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add a null check in ~LogPostfixDummy

2020-11-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new c1dd203  add a null check in ~LogPostfixDummy
c1dd203 is described below

commit c1dd203534dd9268edbc264e27b412ea718a790a
Author: jamesge 
AuthorDate: Fri Nov 27 00:22:14 2020 +0800

add a null check in ~LogPostfixDummy
---
 src/brpc/controller.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index 0ef6004..f343edb 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -1541,7 +1541,9 @@ void Controller::FlushSessionKV(std::ostream& os) {
 }
 
 Controller::LogPostfixDummy::~LogPostfixDummy() {
-*osptr << postfix;
+if (osptr != nullptr) {
+*osptr << postfix;
+}
 }
 
 std::ostream& operator<<(std::ostream& os, const Controller::LogPostfixDummy& 
p) {


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Make code compile for glog

2020-11-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new ce7c45f  Make code compile for glog
ce7c45f is described below

commit ce7c45f182d2ffa954665d6438ba2b877f5c4758
Author: jamesge 
AuthorDate: Thu Nov 26 19:34:04 2020 +0800

Make code compile for glog
---
 src/brpc/controller.cpp   | 22 +-
 src/brpc/controller.h |  6 +++---
 src/butil/logging.cc  |  6 +++---
 src/butil/logging.h   |  1 -
 test/brpc_controller_unittest.cpp | 17 ++---
 5 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index 92f717d..0ef6004 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -77,6 +77,8 @@ BAIDU_REGISTER_ERRNO(brpc::ECLOSE, "Close socket 
initiatively");
 BAIDU_REGISTER_ERRNO(brpc::EITP, "Bad Itp response");
 
 
+DECLARE_bool(log_as_json);
+
 namespace brpc {
 
 DEFINE_bool(graceful_quit_on_sigterm, false,
@@ -128,9 +130,19 @@ Controller::Controller() {
 ResetPods();
 }
 
+struct SessionKVFlusher {
+Controller* cntl;
+};
+static std::ostream& operator<<(std::ostream& os, const SessionKVFlusher& f) {
+f.cntl->FlushSessionKV(os);
+return os;
+}
+
 Controller::~Controller() {
 *g_ncontroller << -1;
-FlushSessionKV(LOG_STREAM(INFO));
+if (_session_kv != nullptr && _session_kv->Count() != 0) {
+LOG(INFO) << SessionKVFlusher{ this };
+}
 ResetNonPods();
 }
 
@@ -1509,7 +1521,7 @@ void Controller::FlushSessionKV(std::ostream& os) {
 pRID = _http_request->GetHeader(FLAGS_request_id_header);
 }
 
-if (::logging::FLAGS_log_as_json) {
+if (FLAGS_log_as_json) {
 os << "\"M\":\"" BRPC_SESSION_END_MSG "\"";
 if (pRID) {
 os << ",\"" BRPC_REQ_ID "\":\"" << *pRID << '"';
@@ -1534,7 +1546,7 @@ Controller::LogPostfixDummy::~LogPostfixDummy() {
 
 std::ostream& operator<<(std::ostream& os, const Controller::LogPostfixDummy& 
p) {
 const_cast(p).osptr = 
-if (::logging::FLAGS_log_as_json) {
+if (FLAGS_log_as_json) {
 os << "\"M\":\"";
 }
 return os;
@@ -1544,14 +1556,14 @@ std::ostream& operator<<(std::ostream& os, const 
Controller::LogPostfixDummy& p)
 Controller::LogPostfixDummy Controller::LogPostfix() const {
 Controller::LogPostfixDummy result;
 std::string& p = result.postfix;
-if (::logging::FLAGS_log_as_json) {
+if (FLAGS_log_as_json) {
 p.push_back('"');
 }
 const std::string* pRID = nullptr;
 if (_http_request) {
 pRID = _http_request->GetHeader(FLAGS_request_id_header);
 if (pRID) {
-if (::logging::FLAGS_log_as_json) {
+if (FLAGS_log_as_json) {
 p.append(",\"" BRPC_REQ_ID "\":\"");
 p.append(*pRID);
 p.push_back('"');
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index 89250a7..8a75c54 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -486,6 +486,9 @@ public:
 // Get the object to write key/value which will be flushed into
 // LOG(INFO) when this controller is deleted.
 KVMap& SessionKV();
+
+// Flush SessionKV() into `os'
+void FlushSessionKV(std::ostream& os);
 
 // Contextual prefixes for LOGD/LOGI/LOGW/LOGE/LOGF macros
 struct LogPostfixDummy {
@@ -674,9 +677,6 @@ private:
 std::string& protocol_param() { return _thrift_method_name; }
 const std::string& protocol_param() const { return _thrift_method_name; }
 
-// Flush this->SessionKV() into `os'
-void FlushSessionKV(std::ostream& os);
-
 private:
 // NOTE: align and group fields to make Controller as compact as possible.
 
diff --git a/src/butil/logging.cc b/src/butil/logging.cc
index 26e6259..c283ce1 100644
--- a/src/butil/logging.cc
+++ b/src/butil/logging.cc
@@ -19,6 +19,9 @@
 
 #include "butil/logging.h"
 
+#include 
+DEFINE_bool(log_as_json, false, "Print log as a valid JSON");
+
 #if !BRPC_WITH_GLOG
 
 #if defined(OS_WIN)
@@ -87,7 +90,6 @@ typedef pthread_mutex_t* MutexHandle;
 #include 
 #include 
 #include 
-#include 
 #include "butil/atomicops.h"
 #include "butil/thread_local.h"
 #include "butil/scoped_lock.h"// BAIDU_SCOPED_LOCK
@@ -139,8 +141,6 @@ DEFINE_bool(log_hostname, false, "Add host after pid in 
each log so"
 
 DEFINE_bool(log_year, false, "Log year in datetime part

[incubator-brpc] branch master updated: Add :: before namespace logging

2020-11-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 6d3a6e1  Add :: before namespace logging
6d3a6e1 is described below

commit 6d3a6e1e655479bb2b04944091a94d1a3afeb31b
Author: jamesge 
AuthorDate: Thu Nov 26 16:47:15 2020 +0800

Add :: before namespace logging
---
 src/brpc/controller.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index 5c061ee..92f717d 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -1509,7 +1509,7 @@ void Controller::FlushSessionKV(std::ostream& os) {
 pRID = _http_request->GetHeader(FLAGS_request_id_header);
 }
 
-if (logging::FLAGS_log_as_json) {
+if (::logging::FLAGS_log_as_json) {
 os << "\"M\":\"" BRPC_SESSION_END_MSG "\"";
 if (pRID) {
 os << ",\"" BRPC_REQ_ID "\":\"" << *pRID << '"';
@@ -1534,7 +1534,7 @@ Controller::LogPostfixDummy::~LogPostfixDummy() {
 
 std::ostream& operator<<(std::ostream& os, const Controller::LogPostfixDummy& 
p) {
 const_cast(p).osptr = 
-if (logging::FLAGS_log_as_json) {
+if (::logging::FLAGS_log_as_json) {
 os << "\"M\":\"";
 }
 return os;
@@ -1544,14 +1544,14 @@ std::ostream& operator<<(std::ostream& os, const 
Controller::LogPostfixDummy& p)
 Controller::LogPostfixDummy Controller::LogPostfix() const {
 Controller::LogPostfixDummy result;
 std::string& p = result.postfix;
-if (logging::FLAGS_log_as_json) {
+if (::logging::FLAGS_log_as_json) {
 p.push_back('"');
 }
 const std::string* pRID = nullptr;
 if (_http_request) {
 pRID = _http_request->GetHeader(FLAGS_request_id_header);
 if (pRID) {
-if (logging::FLAGS_log_as_json) {
+if (::logging::FLAGS_log_as_json) {
 p.append(",\"" BRPC_REQ_ID "\":\"");
 p.append(*pRID);
 p.push_back('"');


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 03/05: add Controller.SessionKV() to record and print session-level KV; Add LOGD/I/W/E/F to print contextual log; Add flag -log_as_json to print logs as valid JSON

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 86acfa893d8f7776a7085701cf9ae5721434e2b6
Author: jamesge 
AuthorDate: Thu Nov 26 14:11:20 2020 +0800

add Controller.SessionKV() to record and print session-level KV; Add 
LOGD/I/W/E/F to print contextual log; Add flag -log_as_json to print logs as 
valid JSON
---
 src/brpc/controller.cpp |  83 +-
 src/brpc/controller.h   |  27 +
 src/brpc/{session_log.h => kvmap.h} |  21 +++
 src/butil/logging.cc| 115 
 src/butil/logging.h |   1 +
 test/brpc_controller_unittest.cpp   |  55 +
 6 files changed, 278 insertions(+), 24 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index ace380f..5c061ee 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -79,7 +79,9 @@ BAIDU_REGISTER_ERRNO(brpc::EITP, "Bad Itp response");
 
 namespace brpc {
 
-DEFINE_bool(graceful_quit_on_sigterm, false, "Register SIGTERM handle func to 
quit graceful");
+DEFINE_bool(graceful_quit_on_sigterm, false,
+"Register SIGTERM handle func to quit graceful");
+DEFINE_string(request_id_header, "x-request-id", "The http header to mark a 
session");
 
 const IdlNames idl_single_req_single_res = { "req", "res" };
 const IdlNames idl_single_req_multi_res = { "req", "" };
@@ -128,6 +130,7 @@ Controller::Controller() {
 
 Controller::~Controller() {
 *g_ncontroller << -1;
+FlushSessionKV(LOG_STREAM(INFO));
 ResetNonPods();
 }
 
@@ -1485,4 +1488,82 @@ google::protobuf::Closure* DoNothing() {
 return butil::get_leaky_singleton();
 }
 
+KVMap& Controller::SessionKV() {
+if (_session_kv == nullptr) {
+_session_kv.reset(new KVMap);
+}
+return *_session_kv.get();
+}
+
+#define BRPC_SESSION_END_MSG "Session ends"
+#define BRPC_REQ_ID "@rid"
+#define BRPC_KV_SEP ":"
+
+void Controller::FlushSessionKV(std::ostream& os) {
+if (_session_kv == nullptr || _session_kv->Count() == 0) {
+return;
+}
+
+const std::string* pRID = nullptr;
+if (_http_request) {
+pRID = _http_request->GetHeader(FLAGS_request_id_header);
+}
+
+if (logging::FLAGS_log_as_json) {
+os << "\"M\":\"" BRPC_SESSION_END_MSG "\"";
+if (pRID) {
+os << ",\"" BRPC_REQ_ID "\":\"" << *pRID << '"';
+}
+for (auto it = _session_kv->Begin(); it != _session_kv->End(); ++it) {
+os << ",\"" << it->first << "\":\"" << it->second << '"';
+}
+} else {
+os << BRPC_SESSION_END_MSG;
+if (pRID) {
+os << " " BRPC_REQ_ID BRPC_KV_SEP << *pRID;
+}
+for (auto it = _session_kv->Begin(); it != _session_kv->End(); ++it) {
+os << ' ' << it->first << BRPC_KV_SEP << it->second;
+}
+}
+}
+
+Controller::LogPostfixDummy::~LogPostfixDummy() {
+*osptr << postfix;
+}
+
+std::ostream& operator<<(std::ostream& os, const Controller::LogPostfixDummy& 
p) {
+const_cast(p).osptr = 
+if (logging::FLAGS_log_as_json) {
+os << "\"M\":\"";
+}
+return os;
+}
+
+
+Controller::LogPostfixDummy Controller::LogPostfix() const {
+Controller::LogPostfixDummy result;
+std::string& p = result.postfix;
+if (logging::FLAGS_log_as_json) {
+p.push_back('"');
+}
+const std::string* pRID = nullptr;
+if (_http_request) {
+pRID = _http_request->GetHeader(FLAGS_request_id_header);
+if (pRID) {
+if (logging::FLAGS_log_as_json) {
+p.append(",\"" BRPC_REQ_ID "\":\"");
+p.append(*pRID);
+p.push_back('"');
+} else {
+p.reserve(5 + pRID->size());
+p.append(" " BRPC_REQ_ID BRPC_KV_SEP);
+p.append(*pRID);
+}
+
+}
+}
+return result;
+}
+
 } // namespace brpc
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index 19a352e..fc39e52 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -43,6 +43,7 @@
 #include "brpc/progressive_attachment.h"   // ProgressiveAttachment
 #include "brpc/progressive_reader.h"   // ProgressiveReader
 #include "brpc/grpc.h"
+#include "brpc/kvmap.h"
 
 // EA

[incubator-brpc] 04/05: polish comments on LOG*

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 6b83e0f5dc2a187a1f111ee426778dfe26516acd
Author: jamesge 
AuthorDate: Thu Nov 26 14:14:10 2020 +0800

polish comments on LOG*
---
 src/brpc/controller.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index fc39e52..89250a7 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -810,7 +810,8 @@ std::ostream& operator<<(std::ostream& os, const 
Controller::LogPostfixDummy& p)
 
 } // namespace brpc
 
-// Print contextual logs
+// Print logs appended with @rid which is got from "x-request-id"(set 
+// -request_id_header to change) in http header by default
 #define LOGD(cntl) LOG(DEBUG) << (cntl)->LogPostfix()
 #define LOGI(cntl) LOG(INFO) << (cntl)->LogPostfix()
 #define LOGW(cntl) LOG(WARNING) << (cntl)->LogPostfix()


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 05/05: Merge branch 'master' of https://github.com/brpc/brpc

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 00498f2333cd54ce943626566c4714f2e685219d
Merge: 6b83e0f 2aea691
Author: jamesge 
AuthorDate: Thu Nov 26 14:14:25 2020 +0800

Merge branch 'master' of https://github.com/brpc/brpc

 docs/cn/getting_started.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (2aea691 -> 00498f2)

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 2aea691  Update getting_started.md
 new e3782eb  Add SessionLog to remember session-level kv
 new 74d156c  fix some warnings
 new 86acfa8  add Controller.SessionKV() to record and print session-level 
KV; Add LOGD/I/W/E/F to print contextual log; Add flag -log_as_json to print 
logs as valid JSON
 new 6b83e0f  polish comments on LOG*
 new 00498f2  Merge branch 'master' of https://github.com/brpc/brpc

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/controller.cpp   |  83 ++-
 src/brpc/controller.h |  28 ++
 src/brpc/kvmap.h  |  75 +
 src/butil/logging.cc  | 115 ++
 src/butil/logging.h   |   1 +
 test/brpc_controller_unittest.cpp |  55 ++
 test/iobuf_unittest.cpp   |   4 +-
 test/rand_util_unittest.cc|   4 +-
 8 files changed, 350 insertions(+), 15 deletions(-)
 create mode 100644 src/brpc/kvmap.h


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 02/05: fix some warnings

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit 74d156c840f86adff0ca13bfee5c9484b0674f5b
Author: jamesge 
AuthorDate: Wed Nov 25 20:19:14 2020 +0800

fix some warnings
---
 test/iobuf_unittest.cpp| 4 ++--
 test/rand_util_unittest.cc | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/iobuf_unittest.cpp b/test/iobuf_unittest.cpp
index cec4019..7691d79 100644
--- a/test/iobuf_unittest.cpp
+++ b/test/iobuf_unittest.cpp
@@ -1660,7 +1660,7 @@ TEST_F(IOBufTest, append_user_data_and_share) {
 TEST_F(IOBufTest, share_tls_block) {
 butil::iobuf::remove_tls_block_chain();
 butil::IOBuf::Block* b = butil::iobuf::acquire_tls_block();
-ASSERT_EQ(0, butil::iobuf::block_size(b));
+ASSERT_EQ(0u, butil::iobuf::block_size(b));
 
 butil::IOBuf::Block* b2 = butil::iobuf::share_tls_block();
 butil::IOBuf buf;
@@ -1677,7 +1677,7 @@ TEST_F(IOBufTest, share_tls_block) {
 }
 // now tls block is b(full) -> b2(full) -> NULL
 butil::IOBuf::Block* head_block = butil::iobuf::share_tls_block();
-ASSERT_EQ(0, butil::iobuf::block_size(head_block));
+ASSERT_EQ(0u, butil::iobuf::block_size(head_block));
 ASSERT_NE(b, head_block);
 ASSERT_NE(b2, head_block);
 }
diff --git a/test/rand_util_unittest.cc b/test/rand_util_unittest.cc
index 8b77884..17891c3 100644
--- a/test/rand_util_unittest.cc
+++ b/test/rand_util_unittest.cc
@@ -138,8 +138,8 @@ TEST(RandUtilTest, RandGeneratorIsUniform) {
 // Don't quit too quickly for things to start converging, or we 
may have
 // a false positive.
 if (count > kMinAttempts &&
-kExpectedAverage - kAllowedVariance < cumulative_average &&
-cumulative_average < kExpectedAverage + kAllowedVariance) {
+double(kExpectedAverage - kAllowedVariance) < 
cumulative_average &&
+cumulative_average < double(kExpectedAverage + 
kAllowedVariance)) {
 break;
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/05: Add SessionLog to remember session-level kv

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit e3782eb8f2e649d1f6eaa00aa5f966a74d564d5d
Author: jamesge 
AuthorDate: Wed Nov 25 20:18:51 2020 +0800

Add SessionLog to remember session-level kv
---
 src/brpc/session_log.h | 80 ++
 1 file changed, 80 insertions(+)

diff --git a/src/brpc/session_log.h b/src/brpc/session_log.h
new file mode 100644
index 000..049232a
--- /dev/null
+++ b/src/brpc/session_log.h
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef BRPC_SESSION_LOG_H
+#define BRPC_SESSION_LOG_H
+
+#include "butil/containers/flat_map.h"
+
+namespace brpc {
+
+class SessionLog {
+public:
+class Formatter {
+public:
+virtual ~Formatter() {}
+virtual void Print(std::ostream&, const SessionLog&) = 0;
+};
+
+typedef butil::FlatMap Map;
+typedef Map::const_iterator Iterator;
+
+SessionLog() {}
+
+// Exchange internal fields with another SessionLog.
+void Swap(SessionLog ) { _entries.swap(rhs._entries); }
+
+// Reset internal fields as if they're just default-constructed.
+void Clear() { _entries.clear(); }
+
+// Get value of a key(case-sensitive)
+// Return pointer to the value, NULL on not found.
+const std::string* Get(const char* key) const { return _entries.seek(key); 
}
+const std::string* Get(const std::string& key) const { return 
_entries.seek(key); }
+
+// Set value of a key
+void Set(const std::string& key, const std::string& value) { GetOrAdd(key) 
= value; }
+void Set(const std::string& key, const char* value) { GetOrAdd(key) = 
value; }
+// Convert other types to string as well
+template 
+void Set(const std::string& key, const T& value) { GetOrAdd(key) = 
std::to_string(value); }
+
+// Remove a key
+void Remove(const char* key) { _entries.erase(key); }
+void Remove(const std::string& key) { _entries.erase(key); }
+
+// Get iterators to iterate key/value
+Iterator Begin() const { return _entries.begin(); }
+Iterator End() const { return _entries.end(); }
+
+// number of key/values
+size_t Count() const { return _entries.size(); }
+
+private:
+std::string& GetOrAdd(const std::string& key) {
+if (!_entries.initialized()) {
+_entries.init(29);
+}
+return _entries[key];
+}
+
+Map _entries;
+};
+
+} // namespace brpc
+
+#endif // BRPC_SESSION_LOG_H


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Update getting_started.md

2020-11-25 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 2aea691  Update getting_started.md
2aea691 is described below

commit 2aea69107891060eeb98ec7ce61f1a1a8f033ada
Author: jamesge 
AuthorDate: Wed Nov 25 19:07:36 2020 +0800

Update getting_started.md
---
 docs/cn/getting_started.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md
index 0f5a364..0b70895 100644
--- a/docs/cn/getting_started.md
+++ b/docs/cn/getting_started.md
@@ -265,10 +265,11 @@ If you need to enable cpu/heap profilers in examples:
 brew install gperftools
 ```
 
-If you need to run tests, install and compile googletest (which is not 
compiled yet):
+If you need to run tests, download and compile googletest (which is not 
compiled yet):
 ```shell
-git clone https://github.com/google/googletest && cd googletest/googletest && 
mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make && sudo 
mv libgtest* /usr/lib/ && cd -
+git clone https://github.com/google/googletest -b release-1.10.0 && cd 
googletest/googletest && mkdir bld && cd bld && cmake 
-DCMAKE_CXX_FLAGS="-std=c++11" .. && make
 ```
+After the compilation, copy include/ and lib/ into /usr/local/include and 
/usr/local/lib respectively to expose gtest to all apps
 
 ### Compile brpc with config_brpc.sh
 git clone brpc, cd into the repo and run


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (a78a34e -> a624f99)

2020-11-23 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from a78a34e  fix errors with clang++ 11 on MacOS Catalina
 add f965d4e  Compatibility improvement of protobuf json format and spring 
http spec
 new a624f99  Merge pull request #1292 from apache/http_improve

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/policy/http_rpc_protocol.cpp|   7 ++-
 src/brpc/policy/http_rpc_protocol.h  |   1 +
 src/json2pb/json_to_pb.cpp   | 105 ---
 src/json2pb/pb_to_json.cpp   |   2 +-
 test/brpc_http_rpc_protocol_unittest.cpp |  37 +++
 test/brpc_protobuf_json_unittest.cpp |  19 --
 6 files changed, 157 insertions(+), 14 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] 01/01: Merge pull request #1292 from apache/http_improve

2020-11-23 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git

commit a624f9951be922b5128ced6c0f9c4d43c390dbc1
Merge: a78a34e f965d4e
Author: jamesge 
AuthorDate: Tue Nov 24 00:07:48 2020 +0800

Merge pull request #1292 from apache/http_improve

Compatibility improvement of protobuf json format and spring http spec

 src/brpc/policy/http_rpc_protocol.cpp|   7 ++-
 src/brpc/policy/http_rpc_protocol.h  |   1 +
 src/json2pb/json_to_pb.cpp   | 105 ---
 src/json2pb/pb_to_json.cpp   |   2 +-
 test/brpc_http_rpc_protocol_unittest.cpp |  37 +++
 test/brpc_protobuf_json_unittest.cpp |  19 --
 6 files changed, 157 insertions(+), 14 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: fix errors with clang++ 11 on MacOS Catalina

2020-11-21 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new a78a34e  fix errors with clang++ 11 on MacOS Catalina
a78a34e is described below

commit a78a34eaf044b6510156dfa17316ee8fe4138b7f
Author: jamesge 
AuthorDate: Sat Nov 21 19:17:11 2020 +0800

fix errors with clang++ 11 on MacOS Catalina
---
 src/butil/mac/foundation_util.h|  8 
 src/butil/third_party/rapidjson/document.h | 10 +++---
 src/butil/time/time.h  |  9 +
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/butil/mac/foundation_util.h b/src/butil/mac/foundation_util.h
index 8e00438..12b8e66 100644
--- a/src/butil/mac/foundation_util.h
+++ b/src/butil/mac/foundation_util.h
@@ -37,17 +37,17 @@ class UIFont;
 #if __has_extension(cxx_strong_enums) && \
 (defined(OS_IOS) || (defined(MAC_OS_X_VERSION_10_8) && \
  MAC_OS_X_VERSION_MAX_ALLOWED >= 
MAC_OS_X_VERSION_10_8))
-#define CR_FORWARD_ENUM(_type, _name) enum _name : _type _name
+#define CR_FORWARD_ENUM(_type, _name) enum _name : _type
 #else
-#define CR_FORWARD_ENUM(_type, _name) _type _name
+#define CR_FORWARD_ENUM(_type, _name) typedef _type _name
 #endif
 
 // Adapted from NSPathUtilities.h and NSObjCRuntime.h.
 #if __LP64__ || NS_BUILD_32_LIKE_64
-typedef CR_FORWARD_ENUM(unsigned long, NSSearchPathDirectory);
+CR_FORWARD_ENUM(unsigned long, NSSearchPathDirectory);
 typedef unsigned long NSSearchPathDomainMask;
 #else
-typedef CR_FORWARD_ENUM(unsigned int, NSSearchPathDirectory);
+CR_FORWARD_ENUM(unsigned int, NSSearchPathDirectory);
 typedef unsigned int NSSearchPathDomainMask;
 #endif
 
diff --git a/src/butil/third_party/rapidjson/document.h 
b/src/butil/third_party/rapidjson/document.h
index f802110..a706586 100644
--- a/src/butil/third_party/rapidjson/document.h
+++ b/src/butil/third_party/rapidjson/document.h
@@ -315,6 +315,10 @@ struct GenericStringRef {
 GenericStringRef(const CharType* str, SizeType len)
 : s(str), length(len) { RAPIDJSON_ASSERT(s != NULL); }
 
+// Required by clang++ 11 on MacOS catalina
+GenericStringRef(const GenericStringRef& other)
+: s(other.s), length(other.length) { RAPIDJSON_ASSERT(s != NULL); }
+
 //! implicit conversion to plain CharType pointer
 operator const Ch *() const { return s; }
 
@@ -322,11 +326,11 @@ struct GenericStringRef {
 const SizeType length; //!< length of the string (excluding the trailing 
NULL terminator)
 
 private:
-//! Disallow copy-assignment
-GenericStringRef operator=(const GenericStringRef&);
+//! Disallow copy-ctor
+GenericStringRef operator=(const GenericStringRef&) = delete;
 //! Disallow construction from non-const array
 template
-GenericStringRef(CharType ()[N]) /* = delete */;
+GenericStringRef(CharType ()[N]) = delete;
 };
 
 //! Mark a character pointer as constant string
diff --git a/src/butil/time/time.h b/src/butil/time/time.h
index c33dfcc..cdc57b6 100644
--- a/src/butil/time/time.h
+++ b/src/butil/time/time.h
@@ -71,6 +71,9 @@ class BUTIL_EXPORT TimeDelta {
   TimeDelta() : delta_(0) {
   }
 
+  // Required by clang++ 11 on MacOS catalina
+  TimeDelta(const TimeDelta& other) : delta_(other.delta_) {}
+
   // Converts units of time to TimeDeltas.
   static TimeDelta FromDays(int days);
   static TimeDelta FromHours(int hours);
@@ -269,6 +272,9 @@ class BUTIL_EXPORT Time {
   Time() : us_(0) {
   }
 
+  // Required by clang++ 11 on MacOS catalina
+  Time(const Time& other) : us_(other.us_) {}
+
   // Returns true if the time object has not been initialized.
   bool is_null() const {
 return us_ == 0;
@@ -608,6 +614,9 @@ class BUTIL_EXPORT TimeTicks {
   TimeTicks() : ticks_(0) {
   }
 
+  // Required by clang++ 11 on MacOS catalina
+  TimeTicks(const TimeTicks& other) : ticks_(other.ticks_) {}
+
   // Platform-dependent tick count representing "right now."
   // The resolution of this clock is ~1-15ms.  Resolution varies depending
   // on hardware/operating system configuration.


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: coding style fix in brpc/trackme.cpp

2020-10-20 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 123e444  coding style fix in brpc/trackme.cpp
 new b1f7ea0  Merge pull request #1270 from gydong/master
123e444 is described below

commit 123e4440a5ae61113de566b650bf549557a36df7
Author: mougaidong 
AuthorDate: Tue Oct 20 11:35:14 2020 +0800

coding style fix in brpc/trackme.cpp
---
 src/brpc/trackme.cpp   | 44 ++--
 src/bthread/task_group.cpp | 33 -
 2 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/src/brpc/trackme.cpp b/src/brpc/trackme.cpp
index b0f56f3..85598a6 100644
--- a/src/brpc/trackme.cpp
+++ b/src/brpc/trackme.cpp
@@ -43,11 +43,11 @@ static const int32_t TRACKME_MIN_INTERVAL = 30;
 static const int32_t TRACKME_MAX_INTERVAL = 600;
 static int32_t s_trackme_interval = TRACKME_MIN_INTERVAL;
 // Protecting global vars on trackme
-static pthread_mutex_t g_trackme_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t s_trackme_mutex = PTHREAD_MUTEX_INITIALIZER;
 // For contacting with trackme_server.
-static Channel* g_trackme_chan = NULL;
+static Channel* s_trackme_chan = NULL;
 // Any server address in this process.
-static std::string* g_trackme_addr = NULL;
+static std::string* s_trackme_addr = NULL;
 
 // Information of bugs.
 // Notice that this structure may be a combination of all affected bugs.
@@ -65,10 +65,10 @@ struct BugInfo {
 // can avoid showing the same bug repeatly.
 static BugInfo* g_bug_info = NULL;
 // The timestamp(microseconds) that we sent TrackMeRequest.
-static int64_t g_trackme_last_time = 0;
+static int64_t s_trackme_last_time = 0;
 
 // version of RPC.
-// Since the code for getting BRPC_REVISION often fails, 
+// Since the code for getting BRPC_REVISION often fails,
 // BRPC_REVISION must be defined to string and be converted to number
 // within our code.
 // The code running before main() may see g_rpc_version=0, should be OK.
@@ -116,8 +116,8 @@ int ReadJPaasHostPort(int container_port) {
 
 // Called in server.cpp
 void SetTrackMeAddress(butil::EndPoint pt) {
-BAIDU_SCOPED_LOCK(g_trackme_mutex);
-if (g_trackme_addr == NULL) {
+BAIDU_SCOPED_LOCK(s_trackme_mutex);
+if (s_trackme_addr == NULL) {
 // JPAAS has NAT capabilities, read its log to figure out the open port
 // accessible from outside.
 const int jpaas_port = ReadJPaasHostPort(pt.port);
@@ -126,7 +126,7 @@ void SetTrackMeAddress(butil::EndPoint pt) {
  << " instead of jpaas_container_port=" << pt.port;
 pt.port = jpaas_port;
 }
-g_trackme_addr = new std::string(butil::endpoint2str(pt).c_str());
+s_trackme_addr = new std::string(butil::endpoint2str(pt).c_str());
 }
 }
 
@@ -139,7 +139,7 @@ static void HandleTrackMeResponse(Controller* cntl, 
TrackMeResponse* res) {
 cur_info.error_text = res->error_text();
 bool already_reported = false;
 {
-BAIDU_SCOPED_LOCK(g_trackme_mutex);
+BAIDU_SCOPED_LOCK(s_trackme_mutex);
 if (g_bug_info != NULL && *g_bug_info == cur_info) {
 // we've shown the bug.
 already_reported = true;
@@ -187,10 +187,10 @@ static void HandleTrackMeResponse(Controller* cntl, 
TrackMeResponse* res) {
 }
 
 static void TrackMeNow(std::unique_lock& mu) {
-if (g_trackme_addr == NULL) {
+if (s_trackme_addr == NULL) {
 return;
 }
-if (g_trackme_chan == NULL) {
+if (s_trackme_chan == NULL) {
 Channel* chan = new (std::nothrow) Channel;
 if (chan == NULL) {
 LOG(FATAL) << "Fail to new trackme channel";
@@ -204,17 +204,17 @@ static void TrackMeNow(std::unique_lock& 
mu) {
 delete chan;
 return;
 }
-g_trackme_chan = chan;
+s_trackme_chan = chan;
 }
 mu.unlock();
-TrackMeService_Stub stub(g_trackme_chan);
+TrackMeService_Stub stub(s_trackme_chan);
 TrackMeRequest req;
 req.set_rpc_version(g_rpc_version);
-req.set_server_addr(*g_trackme_addr);
+req.set_server_addr(*s_trackme_addr);
 TrackMeResponse* res = new TrackMeResponse;
 Controller* cntl = new Controller;
-cntl->set_request_code(policy::MurmurHash32(g_trackme_addr->data(), 
g_trackme_addr->size()));
-google::protobuf::Closure* done = 
+cntl->set_request_code(policy::MurmurHash32(s_trackme_addr->data(), 
s_trackme_addr->size()));
+google::protobuf::Closure* done =
 ::brpc::NewCallback(, cntl, res);
 stub.TrackMe(cntl, , res, done);
 }
@@ -226,15 +226,15 @@ void TrackMe() {
 return;
 }
 int64_t now = butil::gettimeofday_us();
-std::unique_lock 

[incubator-brpc] branch master updated: Fix build break for clang 10.0.1

2020-10-03 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 3a928dd  Fix build break for clang 10.0.1
 new a4e28d6  Merge pull request #1261 from thanksunix/clang-build
3a928dd is described below

commit 3a928ddbad1e2f2bc7106f8ca8eddec7bfd435d6
Author: shuyan.ycf 
AuthorDate: Wed Sep 30 11:44:30 2020 +0800

Fix build break for clang 10.0.1
---
 src/bvar/scoped_timer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bvar/scoped_timer.h b/src/bvar/scoped_timer.h
index 4f349f2..159c3ee 100644
--- a/src/bvar/scoped_timer.h
+++ b/src/bvar/scoped_timer.h
@@ -51,7 +51,7 @@ public:
 
 private:
 DISALLOW_COPY_AND_ASSIGN(ScopedTimer);
-const int64_t _start_time;
+int64_t _start_time;
 T* _bvar;
 };
 } // namespace bvar


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (71aa40c -> 6d9dcf7)

2020-09-18 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 71aa40c  Merge pull request #1139 from 
TousakaRin/use_443_as_default_port_for_https
 new 751649c  Update streaming_rpc.md
 new 57c1a30  Update streaming_rpc.md
 new 6d9dcf7  Merge pull request #1247 from cstarc/patch-1

The 2121 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/cn/streaming_rpc.md | 6 +++---
 docs/en/streaming_rpc.md | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: For https naming service, use 443 as default port

2020-09-10 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new fdb4e77  For https naming service, use 443 as default port
 new 71aa40c  Merge pull request #1139 from 
TousakaRin/use_443_as_default_port_for_https
fdb4e77 is described below

commit fdb4e77d6c9dc6bb3fece739acf57079c224052e
Author: helei 
AuthorDate: Thu Sep 10 18:43:23 2020 +0800

For https naming service, use 443 as default port
---
 src/brpc/global.cpp   | 7 +--
 src/brpc/policy/domain_naming_service.cpp | 8 +---
 src/brpc/policy/domain_naming_service.h   | 4 +++-
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp
index 3bd13ec..23b9bd2 100755
--- a/src/brpc/global.cpp
+++ b/src/brpc/global.cpp
@@ -115,7 +115,9 @@ const char* const DUMMY_SERVER_PORT_FILE = 
"dummy_server.port";
 
 struct GlobalExtensions {
 GlobalExtensions()
-: ch_mh_lb(CONS_HASH_LB_MURMUR3)
+: dns(80)
+, dns_with_ssl(443)
+, ch_mh_lb(CONS_HASH_LB_MURMUR3)
 , ch_md5_lb(CONS_HASH_LB_MD5)
 , ch_ketama_lb(CONS_HASH_LB_KETAMA)
 , constant_cl(0) {
@@ -127,6 +129,7 @@ struct GlobalExtensions {
 FileNamingService fns;
 ListNamingService lns;
 DomainNamingService dns;
+DomainNamingService dns_with_ssl;
 RemoteFileNamingService rfns;
 ConsulNamingService cns;
 DiscoveryNamingService dcns;
@@ -346,7 +349,7 @@ static void GlobalInitializeOrDieImpl() {
 NamingServiceExtension()->RegisterOrDie("file", _ext->fns);
 NamingServiceExtension()->RegisterOrDie("list", _ext->lns);
 NamingServiceExtension()->RegisterOrDie("http", _ext->dns);
-NamingServiceExtension()->RegisterOrDie("https", _ext->dns);
+NamingServiceExtension()->RegisterOrDie("https", _ext->dns_with_ssl);
 NamingServiceExtension()->RegisterOrDie("redis", _ext->dns);
 NamingServiceExtension()->RegisterOrDie("remotefile", _ext->rfns);
 NamingServiceExtension()->RegisterOrDie("consul", _ext->cns);
diff --git a/src/brpc/policy/domain_naming_service.cpp 
b/src/brpc/policy/domain_naming_service.cpp
index aea943c..6e1d975 100644
--- a/src/brpc/policy/domain_naming_service.cpp
+++ b/src/brpc/policy/domain_naming_service.cpp
@@ -28,7 +28,9 @@
 namespace brpc {
 namespace policy {
 
-DomainNamingService::DomainNamingService() : _aux_buf_len(0) {}
+DomainNamingService::DomainNamingService(int default_port)
+: _aux_buf_len(0)
+, _default_port(default_port) {}
 
 int DomainNamingService::GetServers(const char* dns_name,
 std::vector* servers) {
@@ -51,7 +53,7 @@ int DomainNamingService::GetServers(const char* dns_name,
 }
 
 buf[i] = '\0';
-int port = 80;  // default port of HTTP
+int port = _default_port;
 if (dns_name[i] == ':') {
 ++i;
 char* end = NULL;
@@ -142,7 +144,7 @@ void DomainNamingService::Describe(
 }
 
 NamingService* DomainNamingService::New() const {
-return new DomainNamingService;
+return new DomainNamingService(_default_port);
 }
 
 void DomainNamingService::Destroy() {
diff --git a/src/brpc/policy/domain_naming_service.h 
b/src/brpc/policy/domain_naming_service.h
index a20d2ae..f8874f6 100644
--- a/src/brpc/policy/domain_naming_service.h
+++ b/src/brpc/policy/domain_naming_service.h
@@ -28,7 +28,8 @@ namespace policy {
 
 class DomainNamingService : public PeriodicNamingService {
 public:
-DomainNamingService();
+DomainNamingService(int default_port);
+DomainNamingService() : DomainNamingService(80) {}
 
 private:
 int GetServers(const char *service_name,
@@ -43,6 +44,7 @@ private:
 private:
 std::unique_ptr _aux_buf;
 size_t _aux_buf_len;
+int _default_port;
 };
 
 }  // namespace policy


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (8801a84 -> 7bda11b)

2020-09-01 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from 8801a84  Merge pull request #1224 from tanzhongyi003/master
 new ca66d1f  add option to allow access methods from default url
 new d50f3fa  rename restful_mapped_only to allow_default_url
 new 4eea737  Accessing via default url
 new 7bda11b  Merge pull request #1214 from 
wasphin/feature/restful-mapped-only

The 2116 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/policy/http_rpc_protocol.cpp |  2 +-
 src/brpc/server.cpp   |  9 -
 src/brpc/server.h |  9 -
 test/brpc_server_unittest.cpp | 35 +++
 4 files changed, 52 insertions(+), 3 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: update .asf.yaml to change RPC as rpc

2020-08-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 1bb5e81  update .asf.yaml to change RPC as rpc
 new 8801a84  Merge pull request #1224 from tanzhongyi003/master
1bb5e81 is described below

commit 1bb5e81aa7cc1dee8fe79d85b7af77f303cb92dd
Author: tanzhongyi003 <1371827282...@163.com>
AuthorDate: Fri Aug 28 19:35:48 2020 +0800

update .asf.yaml to change RPC as rpc
---
 .asf.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.asf.yaml b/.asf.yaml
index 456d4e8..00ceb66 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -1,5 +1,5 @@
 github:
   description: Industrial-grade RPC framework used throughout Baidu, with 
1,000,000+ instances and thousands kinds of services. "brpc" means "better RPC".
   labels:
-- RPC
+- rpc
   homepage: https://brpc.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add .asf.yaml to set github about info

2020-08-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 414d712  add .asf.yaml to set github about info
 new 3a4256b  Merge pull request #1222 from tanzhongyi003/master
414d712 is described below

commit 414d712e4f592ee70099cf86bff42dd3dadaabf7
Author: tanzhongyi003 <1371827282...@163.com>
AuthorDate: Fri Aug 28 14:09:49 2020 +0800

add .asf.yaml to set github about info
---
 .asf.yaml | 5 +
 1 file changed, 5 insertions(+)

diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 000..456d4e8
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,5 @@
+github:
+  description: Industrial-grade RPC framework used throughout Baidu, with 
1,000,000+ instances and thousands kinds of services. "brpc" means "better RPC".
+  labels:
+- RPC
+  homepage: https://brpc.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: add .asf.yaml to set github about info

2020-08-28 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 414d712  add .asf.yaml to set github about info
 new 3a4256b  Merge pull request #1222 from tanzhongyi003/master
414d712 is described below

commit 414d712e4f592ee70099cf86bff42dd3dadaabf7
Author: tanzhongyi003 <1371827282...@163.com>
AuthorDate: Fri Aug 28 14:09:49 2020 +0800

add .asf.yaml to set github about info
---
 .asf.yaml | 5 +
 1 file changed, 5 insertions(+)

diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 000..456d4e8
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,5 @@
+github:
+  description: Industrial-grade RPC framework used throughout Baidu, with 
1,000,000+ instances and thousands kinds of services. "brpc" means "better RPC".
+  labels:
+- RPC
+  homepage: https://brpc.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: make logo.png even smaller

2020-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new b80ea89  make logo.png even smaller
b80ea89 is described below

commit b80ea8970d736e8bcb09917406ee749ee2dfb528
Author: jamesge 
AuthorDate: Thu Aug 27 11:17:46 2020 +0800

make logo.png even smaller
---
 docs/images/logo.png | Bin 74976 -> 34847 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/docs/images/logo.png b/docs/images/logo.png
index 0088af1..51e2fbd 100644
Binary files a/docs/images/logo.png and b/docs/images/logo.png differ


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: make logo.png smaller

2020-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 54a89a9  make logo.png smaller
54a89a9 is described below

commit 54a89a9a2212755a31e7f900aeffaae10619d8a0
Author: jamesge 
AuthorDate: Thu Aug 27 11:10:39 2020 +0800

make logo.png smaller
---
 docs/images/logo.png | Bin 122317 -> 74976 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/docs/images/logo.png b/docs/images/logo.png
index 75cd8fe..0088af1 100644
Binary files a/docs/images/logo.png and b/docs/images/logo.png differ


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: update logo and readme

2020-08-26 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 8a68acd  update logo and readme
8a68acd is described below

commit 8a68acd3d203a21e7dfc98477c36dffa4ecf5f3e
Author: jamesge 
AuthorDate: Thu Aug 27 11:04:41 2020 +0800

update logo and readme
---
 README.md|   2 +-
 README_cn.md |   2 +-
 docs/images/logo.png | Bin 5582 -> 122317 bytes
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 2870115..ce96fd4 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 
 # ![brpc](docs/images/logo.png)
 
-An industrial-grade RPC framework used throughout 
[Baidu](http://ir.baidu.com/phoenix.zhtml?c=188488=irol-irhome), with 
1,000,000+ instances(not counting clients) and thousands kinds of services, 
called "**baidu-rpc**" inside Baidu. Only C++ implementation is opensourced 
right now.
+An industrial-grade RPC framework used throughout 
[Baidu](http://ir.baidu.com/phoenix.zhtml?c=188488=irol-irhome), with 
1,000,000+ instances(not counting clients) and thousands kinds of services. 
"brpc" means "better RPC".
 
 You can use it to:
 * Build a server that can talk in multiple protocols (**on same port**), or 
access all sorts of services
diff --git a/README_cn.md b/README_cn.md
index ee62ff8..1bd1c96 100644
--- a/README_cn.md
+++ b/README_cn.md
@@ -4,7 +4,7 @@
 
 # ![brpc](docs/images/logo.png)
 
-百度内最常使用的工业级RPC框架, 有1,000,000+个实例(不包含client)和上千种多种服务, 在百度内叫做"**baidu-rpc**". 
目前只开源C++版本。
+百度内最常使用的工业级RPC框架, 有1,000,000+个实例(不包含client)和上千种多种服务。"brpc"的含义是"better RPC"。
 
 你可以使用它:
 
diff --git a/docs/images/logo.png b/docs/images/logo.png
index d4ff6ef..75cd8fe 100644
Binary files a/docs/images/logo.png and b/docs/images/logo.png differ


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: fix_ut_brpc_baidu_com

2020-07-29 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 1211ddc  fix_ut_brpc_baidu_com
 new 8e6bdfa  Merge pull request #1189 from zyearn/fix_ut_brpc_baidu_com
1211ddc is described below

commit 1211ddcc013bc0b4781ac2b7d22bc49c53b4e07f
Author: zhujiashun 
AuthorDate: Tue Jul 28 22:33:13 2020 +0800

fix_ut_brpc_baidu_com
---
 test/brpc_naming_service_filter_unittest.cpp |  2 +-
 test/brpc_naming_service_unittest.cpp| 54 +++-
 2 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/test/brpc_naming_service_filter_unittest.cpp 
b/test/brpc_naming_service_filter_unittest.cpp
index 117e5b7..387aeb5 100644
--- a/test/brpc_naming_service_filter_unittest.cpp
+++ b/test/brpc_naming_service_filter_unittest.cpp
@@ -45,7 +45,7 @@ TEST_F(NamingServiceFilterTest, sanity) {
 "10.128.0.1:1234 enable",
 "10.129.0.1:1234",
 "localhost:1234",
-"brpc.baidu.com:1234"
+"baidu.com:1234"
 };
 butil::TempFile tmp_file;
 {
diff --git a/test/brpc_naming_service_unittest.cpp 
b/test/brpc_naming_service_unittest.cpp
index 61c558b..2b2cbda 100644
--- a/test/brpc_naming_service_unittest.cpp
+++ b/test/brpc_naming_service_unittest.cpp
@@ -50,6 +50,19 @@ DECLARE_int32(discovery_renew_interval_s);
 } // brpc
 
 namespace {
+
+bool IsIPListEqual(const std::set& s1, const 
std::set& s2) {
+if (s1.size() != s2.size()) {
+return false;
+}
+for (auto it1 = s1.begin(), it2 = s2.begin(); it1 != s1.end(); ++it1, 
++it2) {
+if (*it1 != *it2) {
+return false;
+}
+}
+return true;
+}
+
 TEST(NamingServiceTest, sanity) {
 std::vector servers;
 
@@ -59,32 +72,39 @@ TEST(NamingServiceTest, sanity) {
 #endif
 
 brpc::policy::DomainNamingService dns;
-ASSERT_EQ(0, dns.GetServers("brpc.baidu.com:1234", ));
-ASSERT_EQ(1u, servers.size());
+ASSERT_EQ(0, dns.GetServers("baidu.com:1234", ));
+ASSERT_EQ(2u, servers.size());
 ASSERT_EQ(1234, servers[0].addr.port);
-const butil::ip_t expected_ip = servers[0].addr.ip;
+ASSERT_EQ(1234, servers[1].addr.port);
+const std::set expected_ips{servers[0].addr.ip, 
servers[1].addr.ip};
 
-ASSERT_EQ(0, dns.GetServers("brpc.baidu.com", ));
-ASSERT_EQ(1u, servers.size());
-ASSERT_EQ(expected_ip, servers[0].addr.ip);
+ASSERT_EQ(0, dns.GetServers("baidu.com", ));
+ASSERT_EQ(2u, servers.size());
+const std::set ip_list1{servers[0].addr.ip, 
servers[1].addr.ip};
+ASSERT_TRUE(IsIPListEqual(expected_ips, ip_list1));
 ASSERT_EQ(80, servers[0].addr.port);
+ASSERT_EQ(80, servers[1].addr.port);
 
-ASSERT_EQ(0, dns.GetServers("brpc.baidu.com:1234/useless1/useless2", 
));
-ASSERT_EQ(1u, servers.size());
-ASSERT_EQ(expected_ip, servers[0].addr.ip);
+ASSERT_EQ(0, dns.GetServers("baidu.com:1234/useless1/useless2", ));
+ASSERT_EQ(2u, servers.size());
+const std::set ip_list2{servers[0].addr.ip, 
servers[1].addr.ip};
+ASSERT_TRUE(IsIPListEqual(expected_ips, ip_list2));
 ASSERT_EQ(1234, servers[0].addr.port);
+ASSERT_EQ(1234, servers[1].addr.port);
 
-ASSERT_EQ(0, dns.GetServers("brpc.baidu.com/useless1/useless2", ));
-ASSERT_EQ(1u, servers.size());
-ASSERT_EQ(expected_ip, servers[0].addr.ip);
+ASSERT_EQ(0, dns.GetServers("baidu.com/useless1/useless2", ));
+ASSERT_EQ(2u, servers.size());
+const std::set ip_list3{servers[0].addr.ip, 
servers[1].addr.ip};
+ASSERT_TRUE(IsIPListEqual(expected_ips, ip_list3));
 ASSERT_EQ(80, servers[0].addr.port);
+ASSERT_EQ(80, servers[1].addr.port);
 
 const char *address_list[] =  {
 "10.127.0.1:1234",
 "10.128.0.1:1234",
 "10.129.0.1:1234",
 "localhost:1234",
-"brpc.baidu.com:1234"
+"baidu.com:1234"
 };
 butil::TempFile tmp_file;
 {
@@ -126,9 +146,9 @@ TEST(NamingServiceTest, invalid_port) {
 #endif
 
 brpc::policy::DomainNamingService dns;
-ASSERT_EQ(-1, dns.GetServers("brpc.baidu.com:", ));
-ASSERT_EQ(-1, dns.GetServers("brpc.baidu.com:123a", ));
-ASSERT_EQ(-1, dns.GetServers("brpc.baidu.com:9", ));
+ASSERT_EQ(-1, dns.GetServers("baidu.com:", ));
+ASSERT_EQ(-1, dns.GetServers("baidu.com:123a", ));
+ASSERT_EQ(-1, dns.GetServers("baidu.com:9", ));
 }
 
 TEST(NamingServiceTest, wrong_name) {
@@ -146,7 +166,7 @@ TEST(NamingServiceTest, wrong_name) {
 "10.128.0.1:",
 "10.128.0.1",
 "localhost:1234"

[incubator-brpc] branch master updated: Modify RedisTest.auth to adapt redis 6.0

2020-07-24 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 983b997  Modify RedisTest.auth to adapt redis 6.0
983b997 is described below

commit 983b997066dee33022bfba27d7e00f207c092b21
Author: jamesge 
AuthorDate: Fri Jul 24 22:31:38 2020 +0800

Modify RedisTest.auth to adapt redis 6.0
---
 test/brpc_redis_unittest.cpp | 51 +++-
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/test/brpc_redis_unittest.cpp b/test/brpc_redis_unittest.cpp
index 08576bf..1176676 100644
--- a/test/brpc_redis_unittest.cpp
+++ b/test/brpc_redis_unittest.cpp
@@ -356,18 +356,25 @@ TEST_F(RedisTest, by_components) {
 AssertResponseEqual(response2, response, 2);
 }
 
+static std::string GeneratePassword() {
+std::string result;
+result.reserve(12);
+for (size_t i = 0; i < result.capacity(); ++i) {
+result.push_back(butil::fast_rand_in('a', 'z'));
+}
+return result;
+}
+
 TEST_F(RedisTest, auth) {
 if (g_redis_pid < 0) {
 puts("Skipped due to absence of redis-server");
 return;
 }
 // generate a random password
-char PASSWORD[12];
-for (size_t i = 0; i < arraysize(PASSWORD) - 1; ++i) {
-PASSWORD[i] = butil::fast_rand_in('a', 'z');
-}
-PASSWORD[arraysize(PASSWORD)-1] = '\0';
-LOG(INFO) << "Generated password=" << PASSWORD;
+const std::string passwd1 = GeneratePassword();
+const std::string passwd2 = GeneratePassword();
+LOG(INFO) << "Generated passwd1=" << passwd1 << " passwd2=" << passwd2;
+
 // config auth
 {
 brpc::ChannelOptions options;
@@ -378,10 +385,10 @@ TEST_F(RedisTest, auth) {
 brpc::RedisResponse response;
 brpc::Controller cntl;
 
-request.AddCommand("set passwd %s", PASSWORD);
-request.AddCommand("config set requirepass %s", PASSWORD);
-request.AddCommand("auth %s", PASSWORD);
-request.AddCommand("get passwd");
+request.AddCommand("set mykey %s", passwd1.c_str());
+request.AddCommand("config set requirepass %s", passwd1.c_str());
+request.AddCommand("auth %s", passwd1.c_str());
+request.AddCommand("get mykey");
 
 channel.CallMethod(NULL, , , , NULL);
 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
@@ -393,7 +400,7 @@ TEST_F(RedisTest, auth) {
 ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(2).type());
 ASSERT_STREQ("OK", response.reply(2).c_str());
 ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(3).type());
-ASSERT_STREQ(PASSWORD, response.reply(3).c_str());
+ASSERT_STREQ(passwd1.c_str(), response.reply(3).c_str());
 }
 
 // Auth failed
@@ -406,54 +413,58 @@ TEST_F(RedisTest, auth) {
 brpc::RedisResponse response;
 brpc::Controller cntl;
 
-request.AddCommand("get passwd");
+request.AddCommand("get mykey");
 channel.CallMethod(NULL, , , , NULL);
 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
 ASSERT_EQ(1, response.reply_size());
 ASSERT_EQ(brpc::REDIS_REPLY_ERROR, response.reply(0).type());
 }
 
-// Auth with RedisAuthenticator && clear auth
+// Auth with RedisAuthenticator and change to passwd2 (setting to empty
+// pass does not work on redis 6.0.6)
 {
 brpc::ChannelOptions options;
 options.protocol = brpc::PROTOCOL_REDIS;
 brpc::Channel channel;
 brpc::policy::RedisAuthenticator* auth =
-  new brpc::policy::RedisAuthenticator(PASSWORD);
+  new brpc::policy::RedisAuthenticator(passwd1.c_str());
 options.auth = auth;
 ASSERT_EQ(0, channel.Init("0.0.0.0:" REDIS_SERVER_PORT, ));
 brpc::RedisRequest request;
 brpc::RedisResponse response;
 brpc::Controller cntl;
 
-request.AddCommand("get passwd");
-request.AddCommand("config set requirepass ''");
+request.AddCommand("get mykey");
+request.AddCommand("config set requirepass %s", passwd2.c_str());
 
 channel.CallMethod(NULL, , , , NULL);
 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
 ASSERT_EQ(2, response.reply_size());
 ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());
-ASSERT_STREQ(PASSWORD, response.reply(0).c_str());
+ASSERT_STREQ(passwd1.c_str(), response.reply(0).c_str());
 ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(1).type());
 ASSERT_STREQ("OK", response.re

[incubator-brpc] branch master updated: A few changes on RedisTest.auth to test against redis 6.0 on travis-ci

2020-07-24 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new c347f58  A few changes on RedisTest.auth to test against redis 6.0 on 
travis-ci
c347f58 is described below

commit c347f5896f255398f9fe6500aa2596e3df6b0a45
Author: jamesge 
AuthorDate: Fri Jul 24 20:19:14 2020 +0800

A few changes on RedisTest.auth to test against redis 6.0 on travis-ci
---
 test/brpc_redis_unittest.cpp | 47 +++-
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/test/brpc_redis_unittest.cpp b/test/brpc_redis_unittest.cpp
index 7e348f7..08576bf 100644
--- a/test/brpc_redis_unittest.cpp
+++ b/test/brpc_redis_unittest.cpp
@@ -361,6 +361,13 @@ TEST_F(RedisTest, auth) {
 puts("Skipped due to absence of redis-server");
 return;
 }
+// generate a random password
+char PASSWORD[12];
+for (size_t i = 0; i < arraysize(PASSWORD) - 1; ++i) {
+PASSWORD[i] = butil::fast_rand_in('a', 'z');
+}
+PASSWORD[arraysize(PASSWORD)-1] = '\0';
+LOG(INFO) << "Generated password=" << PASSWORD;
 // config auth
 {
 brpc::ChannelOptions options;
@@ -371,15 +378,10 @@ TEST_F(RedisTest, auth) {
 brpc::RedisResponse response;
 brpc::Controller cntl;
 
-butil::StringPiece comp1[] = { "set", "passwd", "my_redis" };
-butil::StringPiece comp2[] = { "config", "set", "requirepass", 
"my_redis" };
-butil::StringPiece comp3[] = { "auth", "my_redis" };
-butil::StringPiece comp4[] = { "get", "passwd" };
-
-request.AddCommandByComponents(comp1, arraysize(comp1));
-request.AddCommandByComponents(comp2, arraysize(comp2));
-request.AddCommandByComponents(comp3, arraysize(comp3));
-request.AddCommandByComponents(comp4, arraysize(comp4));
+request.AddCommand("set passwd %s", PASSWORD);
+request.AddCommand("config set requirepass %s", PASSWORD);
+request.AddCommand("auth %s", PASSWORD);
+request.AddCommand("get passwd");
 
 channel.CallMethod(NULL, , , , NULL);
 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
@@ -391,7 +393,7 @@ TEST_F(RedisTest, auth) {
 ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(2).type());
 ASSERT_STREQ("OK", response.reply(2).c_str());
 ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(3).type());
-ASSERT_STREQ("my_redis", response.reply(3).c_str());
+ASSERT_STREQ(PASSWORD, response.reply(3).c_str());
 }
 
 // Auth failed
@@ -404,10 +406,7 @@ TEST_F(RedisTest, auth) {
 brpc::RedisResponse response;
 brpc::Controller cntl;
 
-butil::StringPiece comp1[] = { "get", "passwd" };
-
-request.AddCommandByComponents(comp1, arraysize(comp1));
-
+request.AddCommand("get passwd");
 channel.CallMethod(NULL, , , , NULL);
 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
 ASSERT_EQ(1, response.reply_size());
@@ -420,24 +419,21 @@ TEST_F(RedisTest, auth) {
 options.protocol = brpc::PROTOCOL_REDIS;
 brpc::Channel channel;
 brpc::policy::RedisAuthenticator* auth =
-  new brpc::policy::RedisAuthenticator("my_redis");
+  new brpc::policy::RedisAuthenticator(PASSWORD);
 options.auth = auth;
 ASSERT_EQ(0, channel.Init("0.0.0.0:" REDIS_SERVER_PORT, ));
 brpc::RedisRequest request;
 brpc::RedisResponse response;
 brpc::Controller cntl;
 
-butil::StringPiece comp1[] = { "get", "passwd" };
-butil::StringPiece comp2[] = { "config", "set", "requirepass", "" };
-
-request.AddCommandByComponents(comp1, arraysize(comp1));
-request.AddCommandByComponents(comp2, arraysize(comp2));
+request.AddCommand("get passwd");
+request.AddCommand("config set requirepass ''");
 
 channel.CallMethod(NULL, , , , NULL);
 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
 ASSERT_EQ(2, response.reply_size());
 ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());
-ASSERT_STREQ("my_redis", response.reply(0).c_str());
+ASSERT_STREQ(PASSWORD, response.reply(0).c_str());
 ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(1).type());
 ASSERT_STREQ("OK", response.reply(1).c_str());
 }
@@ -452,15 +448,12 @@ TEST_F(RedisTest, auth) {
 brpc::RedisResponse response;
   

[incubator-brpc] branch master updated: remove a piece of optional code in TimerThread.run, which has access-after-return issue and may cause the heap popped wrongly

2020-07-24 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new ea87ee7  remove a piece of optional code in TimerThread.run, which has 
access-after-return issue and may cause the heap popped wrongly
ea87ee7 is described below

commit ea87ee715b04e30a4ee255953ac94cd0f6672b59
Author: jamesge 
AuthorDate: Fri Jul 24 16:25:51 2020 +0800

remove a piece of optional code in TimerThread.run, which has 
access-after-return issue and may cause the heap popped wrongly
---
 src/bthread/timer_thread.cpp | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/bthread/timer_thread.cpp b/src/bthread/timer_thread.cpp
index 8d85b63..88bdcf2 100644
--- a/src/bthread/timer_thread.cpp
+++ b/src/bthread/timer_thread.cpp
@@ -367,11 +367,6 @@ void TimerThread::run() {
 bool pull_again = false;
 while (!tasks.empty()) {
 Task* task1 = tasks[0];  // the about-to-run task
-if (task1->try_delete()) { // already unscheduled
-std::pop_heap(tasks.begin(), tasks.end(), task_greater);
-tasks.pop_back();
-continue;
-}
 if (butil::gettimeofday_us() < task1->run_time) {  // not ready 
yet.
 break;
 }


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Controller::CreateProgressiveAttachment returns intrusive_ptr instead of raw pointer which could be deleted and invalid before usage

2020-07-24 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 2071a22  Controller::CreateProgressiveAttachment returns intrusive_ptr 
instead of raw pointer which could be deleted and invalid before usage
2071a22 is described below

commit 2071a22c7f8ca4dfd47b1f0b607737082b66c865
Author: jamesge 
AuthorDate: Fri Jul 24 16:04:24 2020 +0800

Controller::CreateProgressiveAttachment returns intrusive_ptr instead of 
raw pointer which could be deleted and invalid before usage
---
 docs/cn/http_service.md  |  2 +-
 docs/en/http_service.md  |  2 +-
 example/http_c++/http_client.cpp |  2 +-
 example/http_c++/http_server.cpp | 18 +++---
 src/brpc/controller.cpp  |  9 -
 src/brpc/controller.h|  3 ++-
 test/brpc_http_rpc_protocol_unittest.cpp |  8 
 7 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/docs/cn/http_service.md b/docs/cn/http_service.md
index c8b6827..6aaa4b8 100644
--- a/docs/cn/http_service.md
+++ b/docs/cn/http_service.md
@@ -337,7 +337,7 @@ brpc server支持发送超大或无限长的body。方法如下:
   ```c++
   #include 
   ...
-  butil::intrusive_ptr 
pa(cntl->CreateProgressiveAttachment());
+  butil::intrusive_ptr pa = 
cntl->CreateProgressiveAttachment();
   ```
 
 2. 调用ProgressiveAttachment::Write()发送数据。
diff --git a/docs/en/http_service.md b/docs/en/http_service.md
index c0749ad..fc403bc 100644
--- a/docs/en/http_service.md
+++ b/docs/en/http_service.md
@@ -338,7 +338,7 @@ brpc server is capable of sending large or infinite sized 
body, in following ste
   ```c++
   #include 
   ...
-  butil::intrusive_ptr pa 
(cntl->CreateProgressiveAttachment());
+  butil::intrusive_ptr pa = 
cntl->CreateProgressiveAttachment();
   ```
 
 2. Call `ProgressiveAttachment::Write()` to send the data.
diff --git a/example/http_c++/http_client.cpp b/example/http_c++/http_client.cpp
index 6d5e0e9..d9984c8 100644
--- a/example/http_c++/http_client.cpp
+++ b/example/http_c++/http_client.cpp
@@ -28,7 +28,7 @@
 
 DEFINE_string(d, "", "POST this data to the http server");
 DEFINE_string(load_balancer, "", "The algorithm for load balancing");
-DEFINE_int32(timeout_ms, 1000, "RPC timeout in milliseconds");
+DEFINE_int32(timeout_ms, 2000, "RPC timeout in milliseconds");
 DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); 
 DEFINE_string(protocol, "http", "Client-side protocol");
 
diff --git a/example/http_c++/http_server.cpp b/example/http_c++/http_server.cpp
index c52800e..d20ee71 100644
--- a/example/http_c++/http_server.cpp
+++ b/example/http_c++/http_server.cpp
@@ -69,17 +69,20 @@ public:
 FileServiceImpl() {};
 virtual ~FileServiceImpl() {};
 
-static void* SendLargeFile(void* arg) {
-butil::intrusive_ptr pa(
-(brpc::ProgressiveAttachment*)arg);
-if (pa == NULL) {
+struct Args {
+butil::intrusive_ptr pa;
+};
+
+static void* SendLargeFile(void* raw_args) {
+std::unique_ptr args(static_cast(raw_args));
+if (args->pa == NULL) {
 LOG(ERROR) << "ProgressiveAttachment is NULL";
 return NULL;
 }
 for (int i = 0; i < 100; ++i) {
 char buf[16];
 int len = snprintf(buf, sizeof(buf), "part_%d ", i);
-pa->Write(buf, len);
+args->pa->Write(buf, len);
 
 // sleep a while to send another part.
 bthread_usleep(1);
@@ -97,9 +100,10 @@ public:
 const std::string& filename = cntl->http_request().unresolved_path();
 if (filename == "largefile") {
 // Send the "largefile" with ProgressiveAttachment.
+std::unique_ptr args(new Args);
+args->pa = cntl->CreateProgressiveAttachment();
 bthread_t th;
-bthread_start_background(, NULL, SendLargeFile, 
-cntl->CreateProgressiveAttachment());
+bthread_start_background(, NULL, SendLargeFile, args.release());
 } else {
 cntl->response_attachment().append("Getting file: ");
 cntl->response_attachment().append(filename);
diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index 8455508..ace380f 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -1345,7 +1345,7 @@ void Controller::set_stream_creator(StreamCreator* sc) {
 _stream_creator = sc;
 }
 
-ProgressiveAttachment*
+butil::intrusive_ptr
 Controller::CreateProgressiveAttachment(StopStyle stop_style) {
 if (has_progressive_writer()) {
 LOG(ERROR) <<

[incubator-brpc] branch master updated: fix a typo: COMPLELE -> COMPLETE

2020-07-21 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new f67446d  fix a typo: COMPLELE -> COMPLETE
 new 11da9c8  Merge pull request #1116 from wasphin/feature/fix-typo
f67446d is described below

commit f67446d7e123e6f96ad55476309671951be762b5
Author: Xiaofeng Wang 
AuthorDate: Tue May 19 08:13:30 2020 +0800

fix a typo: COMPLELE -> COMPLETE
---
 src/brpc/details/http_message.cpp | 6 +++---
 src/brpc/details/http_message.h   | 6 +++---
 src/brpc/policy/http_rpc_protocol.cpp | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/brpc/details/http_message.cpp 
b/src/brpc/details/http_message.cpp
index 96bb326..d9c590c 100644
--- a/src/brpc/details/http_message.cpp
+++ b/src/brpc/details/http_message.cpp
@@ -134,7 +134,7 @@ int HttpMessage::on_header_value(http_parser *parser,
 
 int HttpMessage::on_headers_complete(http_parser *parser) {
 HttpMessage *http_message = (HttpMessage *)parser->data;
-http_message->_stage = HTTP_ON_HEADERS_COMPLELE;
+http_message->_stage = HTTP_ON_HEADERS_COMPLETE;
 // Move content-type into the member field.
 const std::string* content_type = 
http_message->header().GetHeader("content-type");
 if (content_type) {
@@ -295,12 +295,12 @@ int HttpMessage::OnMessageComplete() {
 _cur_value = NULL;
 if (!_read_body_progressively) {
 // Normal read.
-_stage = HTTP_ON_MESSAGE_COMPLELE;
+_stage = HTTP_ON_MESSAGE_COMPLETE;
 return 0;
 }
 // Progressive read.
 std::unique_lock mu(_body_mutex);
-_stage = HTTP_ON_MESSAGE_COMPLELE;
+_stage = HTTP_ON_MESSAGE_COMPLETE;
 if (_body_reader != NULL) {
 // Solve the case: SetBodyReader quit at ntry=MAX_TRY with non-empty
 // _body and the remaining _body is just the last part.
diff --git a/src/brpc/details/http_message.h b/src/brpc/details/http_message.h
index 548f61f..e23b201 100644
--- a/src/brpc/details/http_message.h
+++ b/src/brpc/details/http_message.h
@@ -37,9 +37,9 @@ enum HttpParserStage {
 HTTP_ON_STATUS,
 HTTP_ON_HEADER_FIELD, 
 HTTP_ON_HEADER_VALUE,
-HTTP_ON_HEADERS_COMPLELE,
+HTTP_ON_HEADERS_COMPLETE,
 HTTP_ON_BODY,
-HTTP_ON_MESSAGE_COMPLELE
+HTTP_ON_MESSAGE_COMPLETE
 };
 
 class HttpMessage {
@@ -61,7 +61,7 @@ public:
 // Returns bytes parsed, -1 on failure.
 ssize_t ParseFromIOBuf(const butil::IOBuf );
 
-bool Completed() const { return _stage == HTTP_ON_MESSAGE_COMPLELE; }
+bool Completed() const { return _stage == HTTP_ON_MESSAGE_COMPLETE; }
 HttpParserStage stage() const { return _stage; }
 
 HttpHeader () { return _header; }
diff --git a/src/brpc/policy/http_rpc_protocol.cpp 
b/src/brpc/policy/http_rpc_protocol.cpp
index 734eb0f..e955286 100644
--- a/src/brpc/policy/http_rpc_protocol.cpp
+++ b/src/brpc/policy/http_rpc_protocol.cpp
@@ -1099,7 +1099,7 @@ ParseResult ParseHttpMessage(butil::IOBuf *source, Socket 
*socket,
 }
 return result;
 } else if (socket->is_read_progressive() &&
-   http_imsg->stage() >= HTTP_ON_HEADERS_COMPLELE) {
+   http_imsg->stage() >= HTTP_ON_HEADERS_COMPLETE) {
 // header part of a progressively-read http message is complete,
 // go on to ProcessHttpXXX w/o waiting for full body.
 http_imsg->AddOneRefForStage2(); // released when body is fully 
read


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (e9f6a58 -> 4941431)

2020-07-21 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from e9f6a58  Merge pull request #1172 from mapleFU/may-error
 new a64407c  fix h2_req check failed when retry after ELIMIT error
 new 935a12a  refine comment
 new 4f92e06  refine code
 new 4941431  Merge pull request #1161 from 
heyuyi0906/fix_h2_req_check_failed

The 2091 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/brpc/channel.cpp | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: [Remove] remove BasicStringPiece in comments

2020-07-21 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new 2f0e18f  [Remove] remove BasicStringPiece in comments
 new e9f6a58  Merge pull request #1172 from mapleFU/may-error
2f0e18f is described below

commit 2f0e18f38cff56c66bed70dbfca0d29d81505365
Author: mwish 
AuthorDate: Thu Jul 16 17:45:48 2020 +0800

[Remove] remove BasicStringPiece in comments

Signed-off-by: mwish 
---
 src/butil/strings/string_piece.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/butil/strings/string_piece.h b/src/butil/strings/string_piece.h
index 479e998..e67758c 100644
--- a/src/butil/strings/string_piece.h
+++ b/src/butil/strings/string_piece.h
@@ -155,7 +155,7 @@ BUTIL_EXPORT StringPiece16 substr(const StringPiece16& self,
 
 // Defines the types, methods, operators, and data members common to both
 // StringPiece and StringPiece16. Do not refer to this class directly, but
-// rather to BasicStringPiece, StringPiece, or StringPiece16.
+// rather to StringPiece, or StringPiece16.
 //
 // This is templatized by string class type rather than character type, so
 // BasicStringPiece or BasicStringPiece.


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated (b7b7982 -> 5d0512d)

2020-07-21 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git.


from b7b7982  Merge pull request #1163 from yetingsky/fix-comment
 new 1344fa2  fix_share_tls_block
 new 65dfdd8  fix_share_tls_block: add ut
 new 5d0512d  Merge pull request #1156 from zyearn/fix_share_tls_block

The 2085 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/butil/iobuf.cpp | 12 
 test/iobuf_unittest.cpp | 26 ++
 2 files changed, 34 insertions(+), 4 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: fix comment

2020-07-14 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new b9c5aa1  fix comment
 new b7b7982  Merge pull request #1163 from yetingsky/fix-comment
b9c5aa1 is described below

commit b9c5aa126f66e312bfc76f503bf83fbee3549879
Author: yeting 
AuthorDate: Wed Jul 15 01:34:23 2020 +0800

fix comment
---
 src/butil/object_pool.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/butil/object_pool.h b/src/butil/object_pool.h
index 210e8ec..2267b29 100644
--- a/src/butil/object_pool.h
+++ b/src/butil/object_pool.h
@@ -48,7 +48,7 @@ template  struct ObjectPoolBlockMaxItem {
 
 // Free objects of each thread are grouped into a chunk before they are merged
 // to the global list. Memory size of objects in one free chunk will not 
exceed:
-//   min(ObjectPoolFreeChunkMaxItem::value(),
+//   min(ObjectPoolFreeChunkMaxItem::value() * sizeof(T),
 //   ObjectPoolBlockMaxSize::value,
 //   ObjectPoolBlockMaxItem::value * sizeof(T))
 template  struct ObjectPoolFreeChunkMaxItem {


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[incubator-brpc] branch master updated: Update nshead_service.md

2020-07-03 Thread jamesge
This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new c52e0b0  Update nshead_service.md
 new 846f799  Merge pull request #1151 from pklim101/master
c52e0b0 is described below

commit c52e0b07f05adc7cda6d8b7134553f946e379413
Author: thinksasa 
AuthorDate: Fri Jul 3 12:59:13 2020 +0800

Update nshead_service.md
---
 docs/cn/nshead_service.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/cn/nshead_service.md b/docs/cn/nshead_service.md
index 3bf873d..db18bed 100644
--- a/docs/cn/nshead_service.md
+++ b/docs/cn/nshead_service.md
@@ -134,7 +134,7 @@ struct NsheadMessage {
 butil::IOBuf body;
 };
  
-// 实现这个类并复制给ServerOptions.nshead_service来让brpc处理nshead请求。
+// 实现这个类并赋值给ServerOptions.nshead_service来让brpc处理nshead请求。
 class NsheadService : public Describable {
 public:
 NsheadService();


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



  1   2   3   >