Copilot commented on code in PR #3544:
URL: https://github.com/apache/brpc/pull/3544#discussion_r4011636262


##########
src/brpc/socket.cpp:
##########
@@ -742,6 +742,7 @@ int Socket::OnCreated(const SocketOptions& options) {
     _tos = 0;
     _remote_side = options.remote_side;
     _local_side = options.local_side;
+    _bind_local_side = butil::EndPoint(options.local_side.ip, 0);

Review Comment:
   `SocketOptions::local_side` is a public input, and before this change the 
initial `Connect()` passed its configured port through because `_local_side` 
was initialized from `options.local_side`. Constructing the persistent endpoint 
as `(options.local_side.ip, 0)` now silently drops any nonzero source port even 
on the first connection, not just an ephemeral port after revival. Preserve the 
configured port (the channel `client_host` path already supplies port 0), or 
make the port-0-only restriction an explicit compatible API contract across all 
connection types.
   
   This issue also appears on line 745 of the same file.



##########
src/brpc/socket.cpp:
##########
@@ -2796,7 +2799,10 @@ int Socket::GetPooledSocket(SocketUniquePtr* 
pooled_socket) {
     if (socket_pool == nullptr) {
         SocketOptions opt;
         opt.remote_side = remote_side();
-        opt.local_side = butil::EndPoint(local_side().ip, 0);
+        // Propagate the configured client binding (source IP + device) to
+        // pooled sub-sockets so that they keep the same binding policy.
+        opt.local_side = butil::EndPoint(_bind_local_side.ip, 0);

Review Comment:
   This reconstructs `_bind_local_side` from `.ip` again, so an extended 
IPv6/UDS endpoint preserved by `OnCreated()` would be converted back into a 
bogus IPv4 endpoint when the pooled socket is created. Copy `_bind_local_side` 
directly; it is already normalized to port 0 for ordinary IPv4 bindings.
   
   This issue also appears on line 2910 of the same file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to