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
* 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
falcond (1.0.9-101pika1) pika; urgency=low
* Config parsing fixes

View File

@ -13,7 +13,7 @@ pub const PowerProfiles = struct {
original_profile: ?[]const u8,
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);
errdefer allocator.destroy(self);
@ -37,11 +37,7 @@ pub const PowerProfiles = struct {
.has_performance = false,
};
const profiles = self.getAvailableProfiles(allocator) catch |err| {
std.log.err("Failed to get power profiles: {}, power profiles will be disabled", .{err});
allocator.destroy(self);
return null;
};
const profiles = try self.getAvailableProfiles(allocator);
defer {
for (profiles) |profile| {
allocator.free(profile);

View File

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

View File

@ -14,10 +14,10 @@ pub const ProfileManager = struct {
proton_profile: ?*const Profile,
active_profile: ?*const Profile = null,
queued_profiles: std.ArrayList(*const Profile),
power_profiles: ?*PowerProfiles,
power_profiles: *PowerProfiles,
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 .{
.allocator = allocator,
.profiles = std.ArrayList(Profile).init(allocator),
@ -47,9 +47,9 @@ pub const ProfileManager = struct {
std.log.info("Activating profile: {s}", .{profile.name});
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});
self.power_profiles.?.enablePerformanceMode();
self.power_profiles.enablePerformanceMode();
}
const effective_mode = if (self.config.vcache_mode != .none)
@ -80,9 +80,9 @@ pub const ProfileManager = struct {
if (active == profile) {
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});
self.power_profiles.?.disablePerformanceMode();
self.power_profiles.disablePerformanceMode();
}
vcache_setting.applyVCacheMode(.none);
@ -102,9 +102,9 @@ pub const ProfileManager = struct {
if (active == profile) {
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});
self.power_profiles.?.disablePerformanceMode();
self.power_profiles.disablePerformanceMode();
}
vcache_setting.applyVCacheMode(.none);

View File

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