diff options
author | Philipp Tölke <toelke@in.tum.de> | 2010-07-20 19:53:50 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2010-07-20 19:53:50 +0000 |
commit | 620eed92bd84969ce0f1f25490473158974daa1f (patch) | |
tree | bd2bc9728a684b893f942d6b0f676c6eaa135288 /src/vpn | |
parent | 622360c41aa24d27c07a2118d4fcb80d4d8fa25c (diff) | |
download | gnunet-620eed92bd84969ce0f1f25490473158974daa1f.tar.gz gnunet-620eed92bd84969ce0f1f25490473158974daa1f.zip |
make it possible to restart the helper
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index c8b1c895f..e3ae2a16e 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -55,6 +55,32 @@ static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | static void helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx); | ||
59 | |||
60 | static void start_helper_and_schedule(struct vpn_cls* mycls) { | ||
61 | mycls->helper_in = GNUNET_DISK_pipe(1); | ||
62 | mycls->helper_out = GNUNET_DISK_pipe(1); | ||
63 | |||
64 | mycls->helper_pid = GNUNET_OS_start_process(mycls->helper_in, mycls->helper_out, "gnunet-vpn-helper", "gnunet-vpn-helper", NULL); | ||
65 | |||
66 | mycls->fh_from_helper = GNUNET_DISK_pipe_handle (mycls->helper_out, GNUNET_DISK_PIPE_END_READ); | ||
67 | |||
68 | GNUNET_SCHEDULER_add_read_file (mycls->sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls->fh_from_helper, &helper_read, mycls); | ||
69 | } | ||
70 | |||
71 | |||
72 | static void restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { | ||
73 | struct vpn_cls* mycls = (struct vpn_cls*) cls; | ||
74 | |||
75 | // Kill the helper | ||
76 | PLIBC_KILL(mycls->helper_pid, SIGTERM); | ||
77 | GNUNET_OS_process_wait(mycls->helper_pid); | ||
78 | |||
79 | // Restart the helper | ||
80 | start_helper_and_schedule(mycls); | ||
81 | |||
82 | } | ||
83 | |||
58 | static void helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) { | 84 | static void helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) { |
59 | struct vpn_cls* mycls = (struct vpn_cls*) cls; | 85 | struct vpn_cls* mycls = (struct vpn_cls*) cls; |
60 | struct suid_packet_header hdr = { .size = 0 }; | 86 | struct suid_packet_header hdr = { .size = 0 }; |
@@ -135,14 +161,7 @@ run (void *cls, | |||
135 | 161 | ||
136 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); | 162 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); |
137 | 163 | ||
138 | mycls->helper_in = GNUNET_DISK_pipe(1); | 164 | start_helper_and_schedule(mycls); |
139 | mycls->helper_out = GNUNET_DISK_pipe(1); | ||
140 | |||
141 | mycls->helper_pid = GNUNET_OS_start_process(mycls->helper_in, mycls->helper_out, "gnunet-vpn-helper", "gnunet-vpn-helper", NULL); | ||
142 | |||
143 | mycls->fh_from_helper = GNUNET_DISK_pipe_handle (mycls->helper_out, GNUNET_DISK_PIPE_END_READ); | ||
144 | |||
145 | GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls->fh_from_helper, &helper_read, mycls); | ||
146 | } | 165 | } |
147 | 166 | ||
148 | 167 | ||