Compare commits

..

No commits in common. "main" and "v1.0.9" have entirely different histories.
main ... v1.0.9

6 changed files with 22 additions and 40 deletions

View File

@ -1 +1 @@
1 3

View File

@ -1,10 +1,4 @@
falcond (1.1.0-101pika1) pika; urgency=low falcond (1.0.9-101pika1) pika; urgency=low
* Fix memory leak on error, fix power ppd being required for falcond to launch.
-- ferreo <ferreo@pika-os.com> Sun, 12 Jan 2025 13:48:00 +0300
falcond (1.0.9-101pika2) pika; urgency=low
* Config parsing fixes * Config parsing fixes

View File

@ -13,7 +13,7 @@ pub const PowerProfiles = struct {
original_profile: ?[]const u8, original_profile: ?[]const u8,
has_performance: bool, has_performance: bool,
pub fn init(allocator: std.mem.Allocator, config: Config) !?*PowerProfiles { pub fn init(allocator: std.mem.Allocator, config: Config) !*PowerProfiles {
var self = try allocator.create(PowerProfiles); var self = try allocator.create(PowerProfiles);
errdefer allocator.destroy(self); errdefer allocator.destroy(self);
@ -37,11 +37,7 @@ pub const PowerProfiles = struct {
.has_performance = false, .has_performance = false,
}; };
const profiles = self.getAvailableProfiles(allocator) catch |err| { const profiles = try self.getAvailableProfiles(allocator);
std.log.err("Failed to get power profiles: {}, power profiles will be disabled", .{err});
allocator.destroy(self);
return null;
};
defer { defer {
for (profiles) |profile| { for (profiles) |profile| {
allocator.free(profile); allocator.free(profile);

View File

@ -15,7 +15,7 @@ pub const Daemon = struct {
profile_manager: ProfileManager, profile_manager: ProfileManager,
oneshot: bool, oneshot: bool,
known_pids: ?std.AutoHashMap(u32, *const Profile), known_pids: ?std.AutoHashMap(u32, *const Profile),
power_profiles: ?*PowerProfiles, power_profiles: *PowerProfiles,
performance_mode: bool, performance_mode: bool,
last_profiles_check: i128, last_profiles_check: i128,
last_config_check: i128, last_config_check: i128,
@ -30,17 +30,13 @@ pub const Daemon = struct {
const system_conf_path_owned = try allocator.dupe(u8, system_conf_path); const system_conf_path_owned = try allocator.dupe(u8, system_conf_path);
errdefer allocator.free(system_conf_path_owned); errdefer allocator.free(system_conf_path_owned);
var config = try Config.load(allocator, config_path, system_conf_path); const config = try Config.load(allocator, config_path, system_conf_path);
errdefer config.deinit();
const power_profiles = try PowerProfiles.init(allocator, config); const power_profiles = try PowerProfiles.init(allocator, config);
var performance_mode = false; errdefer power_profiles.deinit();
if (power_profiles) |pp| { const performance_mode = power_profiles.isPerformanceAvailable();
performance_mode = pp.isPerformanceAvailable(); if (performance_mode) {
if (performance_mode) { std.log.info("Performance profile available - power profile management enabled", .{});
std.log.info("Performance profile available - power profile management enabled", .{});
}
} }
var profile_manager = ProfileManager.init(allocator, power_profiles, config); var profile_manager = ProfileManager.init(allocator, power_profiles, config);
@ -70,9 +66,7 @@ pub const Daemon = struct {
pub fn deinit(self: *Self) void { pub fn deinit(self: *Self) void {
scx_scheds.deinit(); scx_scheds.deinit();
self.profile_manager.deinit(); self.profile_manager.deinit();
if (self.power_profiles) |pp| { self.power_profiles.deinit();
pp.*.deinit();
}
if (self.known_pids) |*map| { if (self.known_pids) |*map| {
map.deinit(); map.deinit();
} }
@ -92,9 +86,7 @@ pub const Daemon = struct {
} }
self.profile_manager.deinit(); self.profile_manager.deinit();
if (self.power_profiles) |pp| { self.power_profiles.deinit();
pp.*.deinit();
}
self.config.deinit(); self.config.deinit();
const config = try Config.load(self.allocator, self.config_path, self.system_conf_path); const config = try Config.load(self.allocator, self.config_path, self.system_conf_path);
@ -104,7 +96,7 @@ pub const Daemon = struct {
self.config = config; self.config = config;
self.power_profiles = power_profiles; self.power_profiles = power_profiles;
self.performance_mode = if (power_profiles) |pp| pp.isPerformanceAvailable() else false; self.performance_mode = self.power_profiles.isPerformanceAvailable();
self.profile_manager = profile_manager; self.profile_manager = profile_manager;
} }

View File

@ -14,10 +14,10 @@ pub const ProfileManager = struct {
proton_profile: ?*const Profile, proton_profile: ?*const Profile,
active_profile: ?*const Profile = null, active_profile: ?*const Profile = null,
queued_profiles: std.ArrayList(*const Profile), queued_profiles: std.ArrayList(*const Profile),
power_profiles: ?*PowerProfiles, power_profiles: *PowerProfiles,
config: Config, config: Config,
pub fn init(allocator: std.mem.Allocator, power_profiles: ?*PowerProfiles, config: Config) ProfileManager { pub fn init(allocator: std.mem.Allocator, power_profiles: *PowerProfiles, config: Config) ProfileManager {
return .{ return .{
.allocator = allocator, .allocator = allocator,
.profiles = std.ArrayList(Profile).init(allocator), .profiles = std.ArrayList(Profile).init(allocator),
@ -47,9 +47,9 @@ pub const ProfileManager = struct {
std.log.info("Activating profile: {s}", .{profile.name}); std.log.info("Activating profile: {s}", .{profile.name});
self.active_profile = profile; self.active_profile = profile;
if (profile.performance_mode and self.power_profiles != null and self.power_profiles.?.isPerformanceAvailable()) { if (profile.performance_mode and self.power_profiles.isPerformanceAvailable()) {
std.log.info("Enabling performance mode for profile: {s}", .{profile.name}); std.log.info("Enabling performance mode for profile: {s}", .{profile.name});
self.power_profiles.?.enablePerformanceMode(); self.power_profiles.enablePerformanceMode();
} }
const effective_mode = if (self.config.vcache_mode != .none) const effective_mode = if (self.config.vcache_mode != .none)
@ -80,9 +80,9 @@ pub const ProfileManager = struct {
if (active == profile) { if (active == profile) {
std.log.info("Deactivating profile: {s}", .{profile.name}); std.log.info("Deactivating profile: {s}", .{profile.name});
if (profile.performance_mode and self.power_profiles != null and self.power_profiles.?.isPerformanceAvailable()) { if (profile.performance_mode and self.power_profiles.isPerformanceAvailable()) {
std.log.info("Disabling performance mode for profile: {s}", .{profile.name}); std.log.info("Disabling performance mode for profile: {s}", .{profile.name});
self.power_profiles.?.disablePerformanceMode(); self.power_profiles.disablePerformanceMode();
} }
vcache_setting.applyVCacheMode(.none); vcache_setting.applyVCacheMode(.none);
@ -102,9 +102,9 @@ pub const ProfileManager = struct {
if (active == profile) { if (active == profile) {
std.log.info("Unloading profile: {s}", .{profile.name}); std.log.info("Unloading profile: {s}", .{profile.name});
if (profile.performance_mode and self.power_profiles != null and self.power_profiles.?.isPerformanceAvailable()) { if (profile.performance_mode and self.power_profiles.isPerformanceAvailable()) {
std.log.info("Disabling performance mode for profile: {s}", .{profile.name}); std.log.info("Disabling performance mode for profile: {s}", .{profile.name});
self.power_profiles.?.disablePerformanceMode(); self.power_profiles.disablePerformanceMode();
} }
vcache_setting.applyVCacheMode(.none); vcache_setting.applyVCacheMode(.none);

View File

@ -2,7 +2,7 @@
set -e set -e
VERSION="1.1.0" VERSION="1.0.9"
source ./pika-build-config.sh source ./pika-build-config.sh