Skip to content

Commit e4dc04d

Browse files
committed
[Macros] Reap plugin process as soon as it ends
1 parent fc52e27 commit e4dc04d

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

include/swift/AST/PluginRegistry.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ class LoadedExecutablePlugin : public CompilerPlugin {
147147
const llvm::sys::ProcessInfo process;
148148
const int input;
149149
const int output;
150-
bool isStale = false;
151150

152151
PluginProcess(llvm::sys::ProcessInfo process, int input, int output)
153152
: process(process), input(input), output(output) {}
@@ -168,7 +167,7 @@ class LoadedExecutablePlugin : public CompilerPlugin {
168167

169168
/// Mark the current process "stale" (not usable anymore for some reason,
170169
/// probably crashed).
171-
void setStale() { Process->isStale = true; }
170+
void setStale() { Process.reset(); }
172171

173172
public:
174173
LoadedExecutablePlugin(llvm::StringRef ExecutablePath,
@@ -185,7 +184,7 @@ class LoadedExecutablePlugin : public CompilerPlugin {
185184
}
186185

187186
/// Indicates that the current process is usable.
188-
bool isAlive() const { return Process != nullptr && !Process->isStale; }
187+
bool isAlive() const { return Process != nullptr; }
189188

190189
// Launch the plugin if it's not already running, or it's stale. Return an
191190
// error if it's fails to execute it.

lib/AST/PluginRegistry.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,10 @@ PluginRegistry::loadExecutablePlugin(StringRef path, bool disableSandbox) {
223223

224224
llvm::Error LoadedExecutablePlugin::spawnIfNeeded() {
225225
if (Process) {
226-
// See if the loaded one is still usable.
227-
if (!Process->isStale)
228-
return llvm::Error::success();
229-
230226
// NOTE: We don't check the mtime here because 'stat(2)' call is too heavy.
231227
// PluginRegistry::loadExecutablePlugin() checks it and replace this object
232228
// itself if the plugin is updated.
233-
234-
// The plugin is stale. Discard the previously opened process.
235-
Process.reset();
229+
return llvm::Error::success();
236230
}
237231

238232
// Create command line arguments.

0 commit comments

Comments
 (0)