This is an automated email from the ASF dual-hosted git repository.
chenBright 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 af515cc1 Fix guard SO_BINDTODEVICE (#3320)
af515cc1 is described below
commit af515cc17301e4fa84f94b36b438df4858e10be5
Author: Daeho Ro <[email protected]>
AuthorDate: Fri Jun 5 12:41:49 2026 +0900
Fix guard SO_BINDTODEVICE (#3320)
---
src/brpc/socket.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp
index aa349ec8..00227b41 100644
--- a/src/brpc/socket.cpp
+++ b/src/brpc/socket.cpp
@@ -1272,12 +1272,18 @@ int Socket::Connect(const timespec* abstime,
// We need to do async connect (to manage the timeout by ourselves).
CHECK_EQ(0, butil::make_non_blocking(sockfd));
if (!_device_name.empty()) {
+#ifdef SO_BINDTODEVICE
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
_device_name.c_str(), _device_name.size()) < 0) {
PLOG(ERROR) << "Fail to set SO_BINDTODEVICE of fd=" << sockfd
<< " to device_name=" << _device_name;
return -1;
}
+#else
+ LOG(ERROR) << "SO_BINDTODEVICE (device_name=" << _device_name
+ << ") is not supported on this platform";
+ return -1;
+#endif
}
if (local_side().ip != butil::IP_ANY) {
struct sockaddr_storage cli_addr;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]