This is an automated email from the ASF dual-hosted git repository.

guangmingchen 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 f12bc52a socket: fix potential double close (#2663)
f12bc52a is described below

commit f12bc52a55770ac2bcd5ed658d406581dd6f579b
Author: Jay <busy...@users.noreply.github.com>
AuthorDate: Mon Jun 24 16:55:13 2024 +0800

    socket: fix potential double close (#2663)
    
    `_fd` should be reset if `ResetFileDescriptor` is going to return -1,
    otherwise the fd will be closed in callers like `CheckConnectedAndKeepWrite`
    or `Server::StartInernal` and socket lifecycle methods like `BeforeRecycled`
    or `WaitAndReset`.
---
 src/brpc/socket.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp
index ac1c37ae..12230d7f 100644
--- a/src/brpc/socket.cpp
+++ b/src/brpc/socket.cpp
@@ -594,6 +594,7 @@ int Socket::ResetFileDescriptor(int fd) {
     // Make the fd non-blocking.
     if (butil::make_non_blocking(fd) != 0) {
         PLOG(ERROR) << "Fail to set fd=" << fd << " to non-blocking";
+        _fd.store(-1, butil::memory_order_release);
         return -1;
     }
     // turn off nagling.


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

Reply via email to