aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_os_lib.h12
-rw-r--r--src/util/Makefile.am6
-rw-r--r--src/util/os_priority.c106
-rw-r--r--src/util/test_os_priority.c68
4 files changed, 0 insertions, 192 deletions
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index 3496937a6..c92860dd8 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -304,18 +304,6 @@ GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc);
304 304
305 305
306/** 306/**
307 * Set process priority
308 *
309 * @param proc pointer to process structure
310 * @param prio priority value
311 * @return GNUNET_OK on success, GNUNET_SYSERR on error
312 */
313int
314GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
315 enum GNUNET_SCHEDULER_Priority prio);
316
317
318/**
319 * Start a process. 307 * Start a process.
320 * 308 *
321 * @param pipe_control should a pipe be used to send signals to the child? 309 * @param pipe_control should a pipe be used to send signals to the child?
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 275c98847..7bcac3d29 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -236,7 +236,6 @@ check_PROGRAMS = \
236 test_mq \ 236 test_mq \
237 test_mq_client \ 237 test_mq_client \
238 test_os_network \ 238 test_os_network \
239 test_os_priority \
240 test_peer \ 239 test_peer \
241 test_plugin \ 240 test_plugin \
242 test_program \ 241 test_program \
@@ -436,11 +435,6 @@ test_os_network_SOURCES = \
436test_os_network_LDADD = \ 435test_os_network_LDADD = \
437 $(top_builddir)/src/util/libgnunetutil.la 436 $(top_builddir)/src/util/libgnunetutil.la
438 437
439test_os_priority_SOURCES = \
440 test_os_priority.c
441test_os_priority_LDADD = \
442 $(top_builddir)/src/util/libgnunetutil.la
443
444test_peer_SOURCES = \ 438test_peer_SOURCES = \
445 test_peer.c 439 test_peer.c
446test_peer_LDADD = \ 440test_peer_LDADD = \
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index b967445f3..5946f2b3d 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -343,112 +343,6 @@ child_wait_thread (void *arg)
343#endif 343#endif
344 344
345 345
346/**
347 * Set process priority
348 *
349 * @param proc pointer to process structure
350 * @param prio priority value
351 * @return GNUNET_OK on success, GNUNET_SYSERR on error
352 */
353int
354GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
355 enum GNUNET_SCHEDULER_Priority prio)
356{
357 int rprio;
358
359 GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT);
360 if (GNUNET_SCHEDULER_PRIORITY_KEEP == prio)
361 return GNUNET_OK;
362
363 /* convert to MINGW/Unix values */
364 switch (prio)
365 {
366 case GNUNET_SCHEDULER_PRIORITY_UI:
367 case GNUNET_SCHEDULER_PRIORITY_URGENT:
368#ifdef MINGW
369 rprio = HIGH_PRIORITY_CLASS;
370#else
371 rprio = 0;
372#endif
373 break;
374
375 case GNUNET_SCHEDULER_PRIORITY_HIGH:
376#ifdef MINGW
377 rprio = ABOVE_NORMAL_PRIORITY_CLASS;
378#else
379 rprio = 5;
380#endif
381 break;
382
383 case GNUNET_SCHEDULER_PRIORITY_DEFAULT:
384#ifdef MINGW
385 rprio = NORMAL_PRIORITY_CLASS;
386#else
387 rprio = 7;
388#endif
389 break;
390
391 case GNUNET_SCHEDULER_PRIORITY_BACKGROUND:
392#ifdef MINGW
393 rprio = BELOW_NORMAL_PRIORITY_CLASS;
394#else
395 rprio = 10;
396#endif
397 break;
398
399 case GNUNET_SCHEDULER_PRIORITY_IDLE:
400#ifdef MINGW
401 rprio = IDLE_PRIORITY_CLASS;
402#else
403 rprio = 19;
404#endif
405 break;
406 default:
407 GNUNET_assert (0);
408 return GNUNET_SYSERR;
409 }
410
411 /* Set process priority */
412#ifdef MINGW
413 {
414 HANDLE h = proc->handle;
415
416 GNUNET_assert (h != NULL);
417 SetPriorityClass (h, rprio);
418 }
419#elif LINUX
420 pid_t pid;
421
422 pid = proc->pid;
423 if ((0 == pid) || (pid == getpid ()))
424 {
425 int have = nice (0);
426 int delta = rprio - have;
427
428 errno = 0;
429 if ((delta != 0) && (rprio == nice (delta)) && (errno != 0))
430 {
431 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "nice");
432 return GNUNET_SYSERR;
433 }
434 }
435 else
436 {
437 if (0 != setpriority (PRIO_PROCESS, pid, rprio))
438 {
439 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
440 "setpriority");
441 return GNUNET_SYSERR;
442 }
443 }
444#else
445 LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
446 "Priority management not availabe for this platform\n");
447#endif
448 return GNUNET_OK;
449}
450
451
452#if MINGW 346#if MINGW
453static char * 347static char *
454CreateCustomEnvTable (char **vars) 348CreateCustomEnvTable (char **vars)
diff --git a/src/util/test_os_priority.c b/src/util/test_os_priority.c
deleted file mode 100644
index bb740db5f..000000000
--- a/src/util/test_os_priority.c
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2003, 2004, 2005, 2006, 2009 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file util/test_os_priority.c
22 * @brief testcase for util/os_priority.c
23 */
24#include "platform.h"
25#include "gnunet_common.h"
26#include "gnunet_os_lib.h"
27
28
29static int
30testprio ()
31{
32 if (GNUNET_OK !=
33 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
34 GNUNET_SCHEDULER_PRIORITY_DEFAULT))
35 return 1;
36 if (GNUNET_OK !=
37 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
38 GNUNET_SCHEDULER_PRIORITY_UI))
39 return 1;
40 if (GNUNET_OK !=
41 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
42 GNUNET_SCHEDULER_PRIORITY_IDLE))
43 return 1;
44 if (GNUNET_OK !=
45 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
46 GNUNET_SCHEDULER_PRIORITY_BACKGROUND))
47 return 1;
48 if (GNUNET_OK !=
49 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
50 GNUNET_SCHEDULER_PRIORITY_HIGH))
51 return 1;
52 if (GNUNET_OK !=
53 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
54 GNUNET_SCHEDULER_PRIORITY_HIGH))
55 return 1;
56 return 0;
57}
58
59int
60main (int argc, char *argv[])
61{
62 int errCnt = 0;
63
64 GNUNET_log_setup ("test_os_priority", "WARNING", NULL);
65 if (0 != testprio ())
66 errCnt++;
67 return errCnt;
68}