Skip to content

Commit b16235c

Browse files
committed
[clang/cc1depscan_main] Make sure to call ::listen() as part of the ScanServer::start() function
For the `-execute` daemon mode, `::listen()` is needed to fully prepare the socket before executing the command; otherwise it's possible the command may start before the `ScanServer::listen()` function and fail to connect to the socket. (cherry picked from commit 900d6b1)
1 parent 27c1daf commit b16235c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

clang/tools/driver/cc1depscan_main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,15 @@ void ScanServer::start(bool Exclusive) {
848848

849849
if (cc1depscand::bindToSocket(BasePath, ListenSocket))
850850
reportError(StringRef() + "cannot bind to socket" + ": " + strerror(errno));
851+
852+
unsigned MaxBacklog =
853+
llvm::hardware_concurrency().compute_thread_count() * 16;
854+
if (::listen(ListenSocket, MaxBacklog))
855+
reportError("cannot listen to socket");
851856
}
852857

853858
int ScanServer::listen() {
854859
llvm::ThreadPool Pool;
855-
if (::listen(ListenSocket, /*MaxBacklog=*/Pool.getThreadCount() * 16))
856-
reportError("cannot listen to socket");
857860

858861
DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions());
859862
CASOptions CASOpts;

0 commit comments

Comments
 (0)