You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ja...@apache.org on 2022/11/14 06:19:03 UTC

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

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 <ge...@bytedance.com>
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-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org