diff options
Diffstat (limited to 'src/util/os_priority.c')
-rw-r--r-- | src/util/os_priority.c | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index bccde8d46..d27642a58 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -60,19 +60,20 @@ parent_control_handler (void *cls, | |||
60 | int sig; | 60 | int sig; |
61 | 61 | ||
62 | #if DEBUG_OS | 62 | #if DEBUG_OS |
63 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 63 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", |
64 | "`%s' invoked because of %d\n", __FUNCTION__, tc->reason); | 64 | __FUNCTION__, tc->reason); |
65 | #endif | 65 | #endif |
66 | if (tc->reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN | | 66 | if (tc-> |
67 | GNUNET_SCHEDULER_REASON_TIMEOUT | | 67 | reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN | |
68 | GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 68 | GNUNET_SCHEDULER_REASON_TIMEOUT | |
69 | GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | ||
69 | { | 70 | { |
70 | GNUNET_DISK_npipe_close (control_pipe); | 71 | GNUNET_DISK_npipe_close (control_pipe); |
71 | } | 72 | } |
72 | else | 73 | else |
73 | { | 74 | { |
74 | if (GNUNET_DISK_file_read (control_pipe, | 75 | if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) != |
75 | &sig, sizeof (sig)) != sizeof (sig)) | 76 | sizeof (sig)) |
76 | { | 77 | { |
77 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read"); | 78 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read"); |
78 | GNUNET_DISK_npipe_close (control_pipe); | 79 | GNUNET_DISK_npipe_close (control_pipe); |
@@ -80,12 +81,12 @@ parent_control_handler (void *cls, | |||
80 | else | 81 | else |
81 | { | 82 | { |
82 | #if DEBUG_OS | 83 | #if DEBUG_OS |
83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 84 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", |
84 | "Got control code %d from parent\n", sig); | 85 | sig); |
85 | #endif | 86 | #endif |
86 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 87 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
87 | control_pipe, | 88 | control_pipe, &parent_control_handler, |
88 | &parent_control_handler, control_pipe); | 89 | control_pipe); |
89 | raise (sig); | 90 | raise (sig); |
90 | } | 91 | } |
91 | } | 92 | } |
@@ -111,10 +112,10 @@ GNUNET_OS_install_parent_control_handler (void *cls, | |||
111 | GNUNET_OS_CONTROL_PIPE, env_buf); | 112 | GNUNET_OS_CONTROL_PIPE, env_buf); |
112 | return; | 113 | return; |
113 | } | 114 | } |
114 | control_pipe = GNUNET_DISK_npipe_open (env_buf, | 115 | control_pipe = |
115 | GNUNET_DISK_OPEN_READ, | 116 | GNUNET_DISK_npipe_open (env_buf, GNUNET_DISK_OPEN_READ, |
116 | GNUNET_DISK_PERM_USER_READ | | 117 | GNUNET_DISK_PERM_USER_READ | |
117 | GNUNET_DISK_PERM_USER_WRITE); | 118 | GNUNET_DISK_PERM_USER_WRITE); |
118 | if (control_pipe == NULL) | 119 | if (control_pipe == NULL) |
119 | { | 120 | { |
120 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "open", env_buf); | 121 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "open", env_buf); |
@@ -125,8 +126,7 @@ GNUNET_OS_install_parent_control_handler (void *cls, | |||
125 | "Adding parent control handler pipe `%s' to the scheduler\n", | 126 | "Adding parent control handler pipe `%s' to the scheduler\n", |
126 | env_buf); | 127 | env_buf); |
127 | #endif | 128 | #endif |
128 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 129 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe, |
129 | control_pipe, | ||
130 | &parent_control_handler, control_pipe); | 130 | &parent_control_handler, control_pipe); |
131 | } | 131 | } |
132 | 132 | ||
@@ -219,13 +219,14 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
219 | */ | 219 | */ |
220 | while (1) | 220 | while (1) |
221 | { | 221 | { |
222 | ret = GNUNET_NETWORK_socket_select (rfds, NULL, efds, | 222 | ret = |
223 | GNUNET_TIME_relative_multiply | 223 | GNUNET_NETWORK_socket_select (rfds, NULL, efds, |
224 | (GNUNET_TIME_relative_get_unit (), | 224 | GNUNET_TIME_relative_multiply |
225 | 5000)); | 225 | (GNUNET_TIME_relative_get_unit (), |
226 | 226 | 5000)); | |
227 | if (ret < 1 || GNUNET_NETWORK_fdset_handle_isset (efds, | 227 | |
228 | proc->control_pipe)) | 228 | if (ret < 1 || |
229 | GNUNET_NETWORK_fdset_handle_isset (efds, proc->control_pipe)) | ||
229 | { | 230 | { |
230 | /* Just to be sure */ | 231 | /* Just to be sure */ |
231 | PLIBC_KILL (proc->pid, sig); | 232 | PLIBC_KILL (proc->pid, sig); |
@@ -234,8 +235,8 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
234 | } | 235 | } |
235 | else | 236 | else |
236 | { | 237 | { |
237 | if (GNUNET_DISK_file_read (proc->control_pipe, &ret, | 238 | if (GNUNET_DISK_file_read (proc->control_pipe, &ret, sizeof (ret)) != |
238 | sizeof (ret)) != GNUNET_OK) | 239 | GNUNET_OK) |
239 | res = PLIBC_KILL (proc->pid, sig); | 240 | res = PLIBC_KILL (proc->pid, sig); |
240 | 241 | ||
241 | /* Child signaled shutdown is in progress */ | 242 | /* Child signaled shutdown is in progress */ |
@@ -394,8 +395,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, | |||
394 | errno = 0; | 395 | errno = 0; |
395 | if ((delta != 0) && (rprio == nice (delta)) && (errno != 0)) | 396 | if ((delta != 0) && (rprio == nice (delta)) && (errno != 0)) |
396 | { | 397 | { |
397 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 398 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
398 | GNUNET_ERROR_TYPE_BULK, "nice"); | 399 | "nice"); |
399 | return GNUNET_SYSERR; | 400 | return GNUNET_SYSERR; |
400 | } | 401 | } |
401 | } | 402 | } |
@@ -403,8 +404,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, | |||
403 | { | 404 | { |
404 | if (0 != setpriority (PRIO_PROCESS, pid, rprio)) | 405 | if (0 != setpriority (PRIO_PROCESS, pid, rprio)) |
405 | { | 406 | { |
406 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | | 407 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
407 | GNUNET_ERROR_TYPE_BULK, "setpriority"); | 408 | "setpriority"); |
408 | return GNUNET_SYSERR; | 409 | return GNUNET_SYSERR; |
409 | } | 410 | } |
410 | } | 411 | } |
@@ -552,10 +553,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
552 | int fd_stdin_write; | 553 | int fd_stdin_write; |
553 | 554 | ||
554 | #if ENABLE_WINDOWS_WORKAROUNDS | 555 | #if ENABLE_WINDOWS_WORKAROUNDS |
555 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 556 | control_pipe = |
556 | GNUNET_DISK_OPEN_WRITE, | 557 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
557 | GNUNET_DISK_PERM_USER_READ | | 558 | GNUNET_DISK_PERM_USER_READ | |
558 | GNUNET_DISK_PERM_USER_WRITE); | 559 | GNUNET_DISK_PERM_USER_WRITE); |
559 | if (control_pipe == NULL) | 560 | if (control_pipe == NULL) |
560 | return NULL; | 561 | return NULL; |
561 | #endif | 562 | #endif |
@@ -776,10 +777,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
776 | start.hStdOutput = stdout_handle; | 777 | start.hStdOutput = stdout_handle; |
777 | } | 778 | } |
778 | 779 | ||
779 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 780 | control_pipe = |
780 | GNUNET_DISK_OPEN_WRITE, | 781 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
781 | GNUNET_DISK_PERM_USER_READ | | 782 | GNUNET_DISK_PERM_USER_READ | |
782 | GNUNET_DISK_PERM_USER_WRITE); | 783 | GNUNET_DISK_PERM_USER_WRITE); |
783 | if (control_pipe == NULL) | 784 | if (control_pipe == NULL) |
784 | { | 785 | { |
785 | GNUNET_free (cmd); | 786 | GNUNET_free (cmd); |
@@ -865,8 +866,8 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, | |||
865 | * @return process ID of the new process, -1 on error | 866 | * @return process ID of the new process, -1 on error |
866 | */ | 867 | */ |
867 | struct GNUNET_OS_Process * | 868 | struct GNUNET_OS_Process * |
868 | GNUNET_OS_start_process_v (const int *lsocks, | 869 | GNUNET_OS_start_process_v (const int *lsocks, const char *filename, |
869 | const char *filename, char *const argv[]) | 870 | char *const argv[]) |
870 | { | 871 | { |
871 | #if ENABLE_WINDOWS_WORKAROUNDS | 872 | #if ENABLE_WINDOWS_WORKAROUNDS |
872 | struct GNUNET_DISK_FileHandle *control_pipe = NULL; | 873 | struct GNUNET_DISK_FileHandle *control_pipe = NULL; |
@@ -887,10 +888,10 @@ GNUNET_OS_start_process_v (const int *lsocks, | |||
887 | unsigned int ls; | 888 | unsigned int ls; |
888 | 889 | ||
889 | #if ENABLE_WINDOWS_WORKAROUNDS | 890 | #if ENABLE_WINDOWS_WORKAROUNDS |
890 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 891 | control_pipe = |
891 | GNUNET_DISK_OPEN_WRITE, | 892 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
892 | GNUNET_DISK_PERM_USER_READ | | 893 | GNUNET_DISK_PERM_USER_READ | |
893 | GNUNET_DISK_PERM_USER_WRITE); | 894 | GNUNET_DISK_PERM_USER_WRITE); |
894 | if (control_pipe == NULL) | 895 | if (control_pipe == NULL) |
895 | return NULL; | 896 | return NULL; |
896 | #endif | 897 | #endif |
@@ -1121,10 +1122,10 @@ GNUNET_OS_start_process_v (const int *lsocks, | |||
1121 | memset (&start, 0, sizeof (start)); | 1122 | memset (&start, 0, sizeof (start)); |
1122 | start.cb = sizeof (start); | 1123 | start.cb = sizeof (start); |
1123 | 1124 | ||
1124 | control_pipe = GNUNET_DISK_npipe_create (&childpipename, | 1125 | control_pipe = |
1125 | GNUNET_DISK_OPEN_WRITE, | 1126 | GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, |
1126 | GNUNET_DISK_PERM_USER_READ | | 1127 | GNUNET_DISK_PERM_USER_READ | |
1127 | GNUNET_DISK_PERM_USER_WRITE); | 1128 | GNUNET_DISK_PERM_USER_WRITE); |
1128 | if (control_pipe == NULL) | 1129 | if (control_pipe == NULL) |
1129 | { | 1130 | { |
1130 | GNUNET_free (cmd); | 1131 | GNUNET_free (cmd); |
@@ -1414,9 +1415,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1414 | proc (cmd->proc_cls, NULL); | 1415 | proc (cmd->proc_cls, NULL); |
1415 | return; | 1416 | return; |
1416 | } | 1417 | } |
1417 | ret = GNUNET_DISK_file_read (cmd->r, | 1418 | ret = |
1418 | &cmd->buf[cmd->off], | 1419 | GNUNET_DISK_file_read (cmd->r, &cmd->buf[cmd->off], |
1419 | sizeof (cmd->buf) - cmd->off); | 1420 | sizeof (cmd->buf) - cmd->off); |
1420 | if (ret <= 0) | 1421 | if (ret <= 0) |
1421 | { | 1422 | { |
1422 | if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) | 1423 | if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) |
@@ -1457,10 +1458,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1457 | * @return NULL on error | 1458 | * @return NULL on error |
1458 | */ | 1459 | */ |
1459 | struct GNUNET_OS_CommandHandle * | 1460 | struct GNUNET_OS_CommandHandle * |
1460 | GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, | 1461 | GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls, |
1461 | void *proc_cls, | 1462 | struct GNUNET_TIME_Relative timeout, const char *binary, |
1462 | struct GNUNET_TIME_Relative timeout, | 1463 | ...) |
1463 | const char *binary, ...) | ||
1464 | { | 1464 | { |
1465 | struct GNUNET_OS_CommandHandle *cmd; | 1465 | struct GNUNET_OS_CommandHandle *cmd; |
1466 | struct GNUNET_OS_Process *eip; | 1466 | struct GNUNET_OS_Process *eip; |