mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Fixups to nice handling. Users can't normally lower niceness.
This commit is contained in:
parent
02a7bdc6c4
commit
9b20563ef5
|
|
@ -47,4 +47,7 @@ extern void zpaq_compress(uchar *c_buf, i64 *c_len, uchar *s_buf, i64 s_len, int
|
|||
FILE *msgout, bool progress, long thread);
|
||||
extern void zpaq_decompress(uchar *s_buf, i64 *d_len, uchar *c_buf, i64 c_len,
|
||||
FILE *msgout, bool progress, long thread);
|
||||
|
||||
static int current_priority;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
22
main.c
22
main.c
|
|
@ -440,8 +440,8 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 'N':
|
||||
control->nice_val = atoi(optarg);
|
||||
if (control->nice_val < -20 || control->nice_val > 19)
|
||||
failure("Invalid nice value (must be -20..19)\n");
|
||||
if (control->nice_val < PRIO_MIN || control->nice_val > PRIO_MAX)
|
||||
failure("Invalid nice value (must be %d...%d)\n", PRIO_MIN, PRIO_MAX);
|
||||
break;
|
||||
case 'o':
|
||||
if (control->outdir)
|
||||
|
|
@ -565,12 +565,20 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Set the main nice value to half that of the backend threads since
|
||||
* the rzip stage is usually the rate limiting step */
|
||||
if (control->nice_val > 0 && !NO_COMPRESS) {
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val / 2) == -1))
|
||||
print_err("Warning, unable to set nice value\n");
|
||||
current_priority = getpriority(PRIO_PROCESS, 0);
|
||||
if (!NO_COMPRESS) {
|
||||
/* If niceness can't be set. just reset process priority */
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val/2) == -1)) {
|
||||
print_err("Warning, unable to set nice value %d...Resetting to %d\n",
|
||||
control->nice_val, current_priority);
|
||||
setpriority(PRIO_PROCESS, 0, (control->nice_val=current_priority));
|
||||
}
|
||||
} else {
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1))
|
||||
print_err("Warning, unable to set nice value\n");
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1)) {
|
||||
print_err("Warning, unable to set nice value %d...Resetting to %d\n",
|
||||
control->nice_val, current_priority);
|
||||
setpriority(PRIO_PROCESS, 0, (control->nice_val=current_priority));
|
||||
}
|
||||
}
|
||||
|
||||
/* One extra iteration for the case of no parameters means we will default to stdin/out */
|
||||
|
|
|
|||
13
stream.c
13
stream.c
|
|
@ -1276,9 +1276,10 @@ static void *compthread(void *data)
|
|||
cti = &cthread[i];
|
||||
ctis = cti->sinfo;
|
||||
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1))
|
||||
print_err("Warning, unable to set nice value on thread\n");
|
||||
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1)) {
|
||||
print_err("Warning, unable to set thread nice value %d...Resetting to %d\n", control->nice_val, current_priority);
|
||||
setpriority(PRIO_PROCESS, 0, (control->nice_val=current_priority));
|
||||
}
|
||||
cti->c_type = CTYPE_NONE;
|
||||
cti->c_len = cti->s_len;
|
||||
|
||||
|
|
@ -1512,8 +1513,10 @@ static void *ucompthread(void *data)
|
|||
dealloc(data);
|
||||
uci = &ucthread[i];
|
||||
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1))
|
||||
print_err("Warning, unable to set nice value on thread\n");
|
||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1)) {
|
||||
print_err("Warning, unable to set thread nice value %d...Resetting to %d\n", control->nice_val, current_priority);
|
||||
setpriority(PRIO_PROCESS, 0, (control->nice_val=current_priority));
|
||||
}
|
||||
|
||||
retry:
|
||||
if (uci->c_type != CTYPE_NONE) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue