Remove support for REALTIME_PRIORITY_CLASS in proc_nice() on Windows.

The reasoning for this is because that it requires special permissions and can in the end be dangerous, discovered by Anatol.
This commit is contained in:
Kalle Sommer Nielsen 2016-11-19 00:32:07 +01:00
parent 271ed78a31
commit ddf95667c4
2 changed files with 4 additions and 8 deletions

View file

@ -75,8 +75,7 @@ $p = [
'Below normal' => [6, 5],
'Normal' => [8, 0],
'Above normal' => [10, -5],
'High priority' => [13, -10],
'Real time' => [24, -16]
'High priority' => [13, -10]
];
foreach ($p as $test => $data) {
@ -93,4 +92,3 @@ Testing 'Below normal' (5): Passed
Testing 'Normal' (0): Passed
Testing 'Above normal' (-5): Passed
Testing 'High priority' (-10): Passed
Testing 'Real time' (-16): Passed

View file

@ -30,8 +30,6 @@
* +-----------------------+-----------------------------+
* | Expression | Priority type |
* +-----------------------+-----------------------------+
* | priority < -14 | REALTIME_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
* | priority < -9 | HIGH_PRIORITY_CLASS |
* +-----------------------+-----------------------------+
* | priority < -4 | ABOVE_NORMAL_PRIORITY_CLASS |
@ -48,15 +46,15 @@
*
* This is applied to the main process, not per thread, although this could
* be implemented using SetThreadPriority() at one point.
*
* Note, it is intended that some priority classes are left out.
*/
PHPAPI int nice(zend_long p)
{
DWORD dwFlag = NORMAL_PRIORITY_CLASS;
if (p < -14) {
dwFlag = REALTIME_PRIORITY_CLASS;
} else if (p < -9) {
if (p < -9) {
dwFlag = HIGH_PRIORITY_CLASS;
} else if (p < -4) {
dwFlag = ABOVE_NORMAL_PRIORITY_CLASS;