Skip to content

Commit 7560574

Browse files
authored
Close channel for Xcode (#4)
When the channel for `XCBBuildService` is closed, basically current service will be stall. By closing the channel for Xcode to let service shutdown properly, and so Xcode can restart it when it's needed again. Signed-off-by: Yoshimasa Niwa <niw@niw.at>
1 parent df8b46a commit 7560574

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Sources/XCBBuildServiceProxyKit/Hybrid/HybridXCBBuildService.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ public final class HybridXCBBuildService<RequestHandler: HybridXCBBuildServiceRe
2121
.channelInitializer { channel in
2222
xcbBuildServiceFuture.flatMap { xcbBuildService in
2323
let framingHandler = RPCPacketCodec(label: "HybridXCBBuildService(\(name))")
24-
24+
25+
// When the channel for XCBBuildService is closed, such as the process is terminated,
26+
// close the channel for Xcode as well, which allows to terminate proxy process.
27+
// Xcode then relaunch it when it's needed.
28+
_ = xcbBuildService.channel.closeFuture.flatMap {
29+
channel.close()
30+
}
31+
2532
return channel.pipeline.addHandlers([
2633
// Bytes -> RPCPacket from Xcode
2734
ByteToMessageHandler(framingHandler),

0 commit comments

Comments
 (0)