Skip to content

Commit 0115426

Browse files
committed
[Macros] Ensure plugin process is alive before sending a message
1 parent d07e8ce commit 0115426

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/ASTGen/Sources/ASTGen/PluginHost.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ struct CompilerPlugin {
138138
}
139139

140140
func sendMessageAndWaitWithoutLock(_ message: HostToPluginMessage) throws -> PluginToHostMessage {
141+
guard !Plugin_spawnIfNeeded(opaqueHandle) else {
142+
throw PluginError.stalePlugin
143+
}
141144
try sendMessage(message)
142145
return try waitForNextMessage()
143146
}
144147

145148
func sendMessageAndWait(_ message: HostToPluginMessage) throws -> PluginToHostMessage {
146149
try self.withLock {
147-
guard !Plugin_spawnIfNeeded(opaqueHandle) else {
148-
throw PluginError.stalePlugin
149-
}
150150
return try sendMessageAndWaitWithoutLock(message);
151151
}
152152
}

0 commit comments

Comments
 (0)