diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-01-25 10:33:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-01-25 10:33:36 +0000 |
commit | 8846e58f99cd0774ea00dbbecf0053d62403214d (patch) | |
tree | a5ab18f7cbd748b2d0c905e78394db4b17cca55f /src | |
parent | b8d9f64cdf009b7bde0b43309eee076fb952a6df (diff) | |
download | gnunet-8846e58f99cd0774ea00dbbecf0053d62403214d.tar.gz gnunet-8846e58f99cd0774ea00dbbecf0053d62403214d.zip |
undo
Diffstat (limited to 'src')
-rw-r--r-- | src/util/os_priority.c | 29 |
1 files changed, 25 insertions, 4 deletions
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, | |||
320 | SetPriorityClass (h, rprio); | 320 | SetPriorityClass (h, rprio); |
321 | } | 321 | } |
322 | #elif LINUX | 322 | #elif LINUX |
323 | if (0 != setpriority (PRIO_PROCESS, proc->pid, rprio)) | 323 | pid_t pid; |
324 | |||
325 | pid = proc->pid; | ||
326 | if ( (0 == pid) || | ||
327 | (pid == getpid () ) ) | ||
324 | { | 328 | { |
325 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 329 | int have = nice (0); |
326 | GNUNET_ERROR_TYPE_BULK, "setpriority"); | 330 | int delta = rprio - have; |
327 | return GNUNET_SYSERR; | 331 | errno = 0; |
332 | if ( (delta != 0) && | ||
333 | (rprio == nice (delta)) && | ||
334 | (errno != 0) ) | ||
335 | { | ||
336 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | ||
337 | GNUNET_ERROR_TYPE_BULK, "nice"); | ||
338 | return GNUNET_SYSERR; | ||
339 | } | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | if (0 != setpriority (PRIO_PROCESS, pid, rprio)) | ||
344 | { | ||
345 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | ||
346 | GNUNET_ERROR_TYPE_BULK, "setpriority"); | ||
347 | return GNUNET_SYSERR; | ||
348 | } | ||
328 | } | 349 | } |
329 | #else | 350 | #else |
330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |