• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Pipewireパッケージ(ちょっと変更)


Commit MetaInfo

Revisão0ecc7ca5f52c05a5e1e77e25163d5b8fdd7041dc (tree)
Hora2023-11-16 01:11:19
AutorJonas Holmberg <jonashg@axis...>
CommiterJonas Holmberg

Mensagem de Log

module-rt: Remove RLIMIT_RTTIME while trying rt policy

Trying rt scheduling policy while RLIMIT_RTTIME is set could result in
SIGXCPU if the limit is exceeded. Set an infinite limit temporarily
while checking if rt policy is allowed.

Mudança Sumário

Diff

--- a/src/modules/module-rt.c
+++ b/src/modules/module-rt.c
@@ -549,6 +549,8 @@ static bool check_realtime_privileges(struct impl *impl)
549549 int err, old_policy, new_policy, min, max;
550550 struct sched_param old_sched_params;
551551 struct sched_param new_sched_params;
552+ struct rlimit old_rlim;
553+ struct rlimit no_rlim = { -1, -1 };
552554 int try = 0;
553555
554556 if (!impl->rlimits_enabled)
@@ -596,11 +598,21 @@ static bool check_realtime_privileges(struct impl *impl)
596598 if ((old_policy & PW_SCHED_RESET_ON_FORK) != 0)
597599 new_policy |= PW_SCHED_RESET_ON_FORK;
598600
601+ /* Disable RLIMIT_RTTIME while trying new_policy. */
602+ if ((err = getrlimit(RLIMIT_RTTIME, &old_rlim)) < 0)
603+ pw_log_debug("getrlimit() failed: %s", spa_strerror(err));
604+ if ((err = setrlimit(RLIMIT_RTTIME, &no_rlim)) < 0)
605+ pw_log_debug("setrlimit() failed: %s", spa_strerror(err));
606+
599607 if (pthread_setschedparam(pthread_self(), new_policy, &new_sched_params) == 0) {
600608 impl->rt_prio = new_sched_params.sched_priority;
601609 pthread_setschedparam(pthread_self(), old_policy, &old_sched_params);
610+ if ((err = setrlimit(RLIMIT_RTTIME, &old_rlim)) < 0)
611+ pw_log_debug("setrlimit() failed: %s", spa_strerror(err));
602612 return true;
603613 }
614+ if ((err = setrlimit(RLIMIT_RTTIME, &old_rlim)) < 0)
615+ pw_log_debug("setrlimit() failed: %s", spa_strerror(err));
604616 }
605617 pw_log_info("Can't set rt prio to %d: %m (try increasing rlimits)", (int)priority);
606618 return false;
@@ -648,18 +660,18 @@ static int set_nice(struct impl *impl, int nice_level, bool warn)
648660 return res;
649661 }
650662
651-static int set_rlimit(struct impl *impl)
663+static int set_rlimit(struct rlimit *rlim)
652664 {
653665 int res = 0;
654666
655- if (setrlimit(RLIMIT_RTTIME, &impl->rl) < 0)
667+ if (setrlimit(RLIMIT_RTTIME, rlim) < 0)
656668 res = -errno;
657669
658670 if (res < 0)
659671 pw_log_debug("setrlimit() failed: %s", spa_strerror(res));
660672 else
661673 pw_log_debug("rt.time.soft:%"PRIi64" rt.time.hard:%"PRIi64,
662- (int64_t)impl->rl.rlim_cur, (int64_t)impl->rl.rlim_max);
674+ (int64_t)rlim->rlim_cur, (int64_t)rlim->rlim_max);
663675
664676 return res;
665677 }
@@ -1023,7 +1035,7 @@ static int do_rtkit_setup(struct spa_loop *loop, bool async, uint32_t seq,
10231035 impl->rl.rlim_cur = SPA_MIN(impl->rl.rlim_cur, impl->rttime_max);
10241036 impl->rl.rlim_max = SPA_MIN(impl->rl.rlim_max, impl->rttime_max);
10251037
1026- set_rlimit(impl);
1038+ set_rlimit(&impl->rl);
10271039
10281040 return 0;
10291041 }
@@ -1144,7 +1156,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
11441156 use_rtkit = can_use_rtkit;
11451157 }
11461158 if (!use_rtkit)
1147- set_rlimit(impl);
1159+ set_rlimit(&impl->rl);
11481160
11491161 if (impl->uclamp_max > 1024) {
11501162 pw_log_warn("uclamp.max out of bounds. Got %d, clamping to 1024.", impl->uclamp_max);