Improve oom-killer
This commit is contained in:
@@ -62,6 +62,9 @@ public class ExtensionProfile: ObservableObject {
|
||||
self.connection = connection
|
||||
self.status = connection.status
|
||||
self.connectedDate = connection.connectedDate
|
||||
if connection.status == .disconnected {
|
||||
Self.schedulePromoteOOMDraft()
|
||||
}
|
||||
#if os(iOS)
|
||||
if #available(iOS 16.0, *) {
|
||||
if connection.status == .connected || connection.status == .disconnected {
|
||||
@@ -73,6 +76,26 @@ public class ExtensionProfile: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
private static func schedulePromoteOOMDraft() {
|
||||
Task.detached {
|
||||
try? await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)
|
||||
#if os(macOS)
|
||||
if Variant.useSystemExtension {
|
||||
guard HelperServiceManager.rootHelperStatus == .enabled else {
|
||||
return
|
||||
}
|
||||
do {
|
||||
try RootHelperClient.shared.promoteOOMDraft()
|
||||
} catch {
|
||||
logger.warning("promote OOM draft: \(error.localizedDescription)")
|
||||
}
|
||||
return
|
||||
}
|
||||
#endif
|
||||
LibboxPromoteOOMDraft()
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
@available(iOS 16.0, *)
|
||||
private static func signalFileProviderChanges() {
|
||||
@@ -291,7 +314,11 @@ public class ExtensionProfile: ObservableObject {
|
||||
if managers.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return ExtensionProfile(managers[0])
|
||||
let profile = ExtensionProfile(managers[0])
|
||||
if profile.status == .disconnected {
|
||||
schedulePromoteOOMDraft()
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
public static func install() async throws {
|
||||
|
||||
@@ -176,6 +176,7 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
||||
if let setupError {
|
||||
throw ExtensionStartupError("(packet-tunnel) error: setup service: \(setupError.localizedDescription)")
|
||||
}
|
||||
LibboxPromoteOOMDraft()
|
||||
|
||||
var error: NSError?
|
||||
commandServer = LibboxNewCommandServer(platformInterface, platformInterface, &error)
|
||||
|
||||
@@ -193,6 +193,7 @@
|
||||
func registerMyInterface(name: String, reply: @escaping (NSError?) -> Void)
|
||||
func collectAllCrashArtifacts(reply: @escaping (CrashArtifactsResult?, NSError?) -> Void)
|
||||
func collectOOMReportArtifacts(reply: @escaping (OOMReportArtifactsResult?, NSError?) -> Void)
|
||||
func promoteOOMDraft(reply: @escaping (NSError?) -> Void)
|
||||
func triggerGoCrash(reply: @escaping (NSError?) -> Void)
|
||||
func triggerNativeCrash(reply: @escaping (NSError?) -> Void)
|
||||
}
|
||||
@@ -441,6 +442,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
public func promoteOOMDraft() throws {
|
||||
try performXPCCallVoid("promoteOOMDraft") { proxy, reply in
|
||||
proxy.promoteOOMDraft(reply: reply)
|
||||
}
|
||||
}
|
||||
|
||||
public func triggerGoCrash() throws {
|
||||
try performXPCCallVoid("triggerGoCrash") { proxy, reply in
|
||||
proxy.triggerGoCrash(reply: reply)
|
||||
|
||||
Reference in New Issue
Block a user