[clang] [llvm] [clang][MBD] set up module build daemon infrastructure (PR #67562)

Michael Spencer via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 13:11:06 PDT 2024


================
@@ -71,6 +101,18 @@ ListeningSocket::ListeningSocket(ListeningSocket &&LS)
 Expected<ListeningSocket> ListeningSocket::createUnix(StringRef SocketPath,
                                                       int MaxBacklog) {
 
+  // Identify instances where the target socket address already exist but hasn't
+  // been binded to by another program. If there is already a file (of any type)
+  // at the specified path, ::bind() will fail with an error
+  if (llvm::sys::fs::exists(SocketPath)) {
+    Expected<int> MaybeFD = getSocketFD(SocketPath);
+    if (!MaybeFD) {
+      return llvm::make_error<StringError>(
+          std::make_error_code(std::errc::file_exists),
+          "Cannot create and bind to socket file");
+    }
----------------
Bigcheese wrote:

Need to call `::close` on the FD.

https://github.com/llvm/llvm-project/pull/67562


More information about the cfe-commits mailing list