From: Christian Grothoff Date: Tue, 25 Jan 2011 10:33:36 +0000 (+0000) Subject: undo X-Git-Tag: initial-import-from-subversion-38251~19258 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8846e58f99cd0774ea00dbbecf0053d62403214d;p=oweals%2Fgnunet.git undo --- diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 3993f572c..e9ca9deea 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -320,11 +320,32 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, SetPriorityClass (h, rprio); } #elif LINUX - if (0 != setpriority (PRIO_PROCESS, proc->pid, rprio)) + pid_t pid; + + pid = proc->pid; + if ( (0 == pid) || + (pid == getpid () ) ) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, "setpriority"); - return GNUNET_SYSERR; + int have = nice (0); + int delta = rprio - have; + errno = 0; + if ( (delta != 0) && + (rprio == nice (delta)) && + (errno != 0) ) + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | + GNUNET_ERROR_TYPE_BULK, "nice"); + return GNUNET_SYSERR; + } + } + else + { + if (0 != setpriority (PRIO_PROCESS, pid, rprio)) + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | + GNUNET_ERROR_TYPE_BULK, "setpriority"); + return GNUNET_SYSERR; + } } #else GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,