Improve oom-killer
This commit is contained in:
@@ -253,6 +253,11 @@ extension RootHelperService: RootHelperProtocol {
|
|||||||
reply(result, nil)
|
reply(result, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func promoteOOMDraft(reply: @escaping (NSError?) -> Void) {
|
||||||
|
LibboxPromoteOOMDraftAt(WorkingDirectoryManager.extensionWorkingDirectoryPath)
|
||||||
|
reply(nil)
|
||||||
|
}
|
||||||
|
|
||||||
func triggerGoCrash(reply: @escaping (NSError?) -> Void) {
|
func triggerGoCrash(reply: @escaping (NSError?) -> Void) {
|
||||||
reply(nil)
|
reply(nil)
|
||||||
LibboxTriggerGoPanic()
|
LibboxTriggerGoPanic()
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ public class ExtensionProfile: ObservableObject {
|
|||||||
self.connection = connection
|
self.connection = connection
|
||||||
self.status = connection.status
|
self.status = connection.status
|
||||||
self.connectedDate = connection.connectedDate
|
self.connectedDate = connection.connectedDate
|
||||||
|
if connection.status == .disconnected {
|
||||||
|
Self.schedulePromoteOOMDraft()
|
||||||
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
if connection.status == .connected || connection.status == .disconnected {
|
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)
|
#if os(iOS)
|
||||||
@available(iOS 16.0, *)
|
@available(iOS 16.0, *)
|
||||||
private static func signalFileProviderChanges() {
|
private static func signalFileProviderChanges() {
|
||||||
@@ -291,7 +314,11 @@ public class ExtensionProfile: ObservableObject {
|
|||||||
if managers.isEmpty {
|
if managers.isEmpty {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return ExtensionProfile(managers[0])
|
let profile = ExtensionProfile(managers[0])
|
||||||
|
if profile.status == .disconnected {
|
||||||
|
schedulePromoteOOMDraft()
|
||||||
|
}
|
||||||
|
return profile
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func install() async throws {
|
public static func install() async throws {
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
if let setupError {
|
if let setupError {
|
||||||
throw ExtensionStartupError("(packet-tunnel) error: setup service: \(setupError.localizedDescription)")
|
throw ExtensionStartupError("(packet-tunnel) error: setup service: \(setupError.localizedDescription)")
|
||||||
}
|
}
|
||||||
|
LibboxPromoteOOMDraft()
|
||||||
|
|
||||||
var error: NSError?
|
var error: NSError?
|
||||||
commandServer = LibboxNewCommandServer(platformInterface, platformInterface, &error)
|
commandServer = LibboxNewCommandServer(platformInterface, platformInterface, &error)
|
||||||
|
|||||||
@@ -193,6 +193,7 @@
|
|||||||
func registerMyInterface(name: String, reply: @escaping (NSError?) -> Void)
|
func registerMyInterface(name: String, reply: @escaping (NSError?) -> Void)
|
||||||
func collectAllCrashArtifacts(reply: @escaping (CrashArtifactsResult?, NSError?) -> Void)
|
func collectAllCrashArtifacts(reply: @escaping (CrashArtifactsResult?, NSError?) -> Void)
|
||||||
func collectOOMReportArtifacts(reply: @escaping (OOMReportArtifactsResult?, NSError?) -> Void)
|
func collectOOMReportArtifacts(reply: @escaping (OOMReportArtifactsResult?, NSError?) -> Void)
|
||||||
|
func promoteOOMDraft(reply: @escaping (NSError?) -> Void)
|
||||||
func triggerGoCrash(reply: @escaping (NSError?) -> Void)
|
func triggerGoCrash(reply: @escaping (NSError?) -> Void)
|
||||||
func triggerNativeCrash(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 {
|
public func triggerGoCrash() throws {
|
||||||
try performXPCCallVoid("triggerGoCrash") { proxy, reply in
|
try performXPCCallVoid("triggerGoCrash") { proxy, reply in
|
||||||
proxy.triggerGoCrash(reply: reply)
|
proxy.triggerGoCrash(reply: reply)
|
||||||
|
|||||||
Reference in New Issue
Block a user