aboutsummaryrefslogtreecommitdiff
path: root/src/setup/gnunet-setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup/gnunet-setup.c')
-rw-r--r--src/setup/gnunet-setup.c68
1 files changed, 59 insertions, 9 deletions
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c
index 506a861f..f93cb853 100644
--- a/src/setup/gnunet-setup.c
+++ b/src/setup/gnunet-setup.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -53,7 +53,12 @@ static int gret;
53/** 53/**
54 * Resolver process handle. 54 * Resolver process handle.
55 */ 55 */
56struct GNUNET_OS_Process *resolver; 56static struct GNUNET_OS_Process *resolver;
57
58/**
59 * Namestore process handle.
60 */
61static struct GNUNET_OS_Process *namestore;
57 62
58 63
59/** 64/**
@@ -278,6 +283,25 @@ load_options ()
278 283
279 284
280/** 285/**
286 * Write final configuration to disk.
287 *
288 * @return GNUNET_OK on success
289 */
290static int
291write_configuration ()
292{
293 struct GNUNET_CONFIGURATION_Handle *cfgDefault;
294 int ret;
295
296 cfgDefault = GNUNET_CONFIGURATION_create ();
297 (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */
298 ret = GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, cfgName);
299 GNUNET_CONFIGURATION_destroy (cfgDefault);
300 return ret;
301}
302
303
304/**
281 * Actual main method that sets up the configuration window. 305 * Actual main method that sets up the configuration window.
282 * 306 *
283 * @param cls the main loop handle 307 * @param cls the main loop handle
@@ -286,8 +310,6 @@ load_options ()
286static void 310static void
287cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 311cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
288{ 312{
289 struct GNUNET_CONFIGURATION_Handle *cfgDefault;
290
291 if (NULL == ml) 313 if (NULL == ml)
292 { 314 {
293 GNUNET_break (0); 315 GNUNET_break (0);
@@ -295,12 +317,8 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
295 } 317 }
296 GNUNET_GTK_main_loop_quit (ml); 318 GNUNET_GTK_main_loop_quit (ml);
297 ml = NULL; 319 ml = NULL;
298 cfgDefault = GNUNET_CONFIGURATION_create (); 320 if (GNUNET_OK != write_configuration ())
299 (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */
300 if (GNUNET_OK != GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, cfgName))
301 gret = 1; 321 gret = 1;
302 GNUNET_CONFIGURATION_destroy (cfgDefault);
303 GNUNET_CONFIGURATION_destroy (cfg);
304 cfg = NULL; 322 cfg = NULL;
305 if (NULL != resolver) 323 if (NULL != resolver)
306 { 324 {
@@ -308,6 +326,38 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
308 GNUNET_OS_process_destroy (resolver); 326 GNUNET_OS_process_destroy (resolver);
309 resolver = NULL; 327 resolver = NULL;
310 } 328 }
329 if (NULL != namestore)
330 {
331 GNUNET_break (0 == GNUNET_OS_process_kill (namestore, SIGTERM));
332 GNUNET_OS_process_destroy (namestore);
333 namestore = NULL;
334 }
335}
336
337
338/**
339 * Write configuration to dis, (re)start the namestore process and
340 * reload the namestore models.
341 *
342 *
343 * @param cls closure (unused)
344 * @param tc scheduler context (unused)
345 */
346void
347GNUNET_SETUP_restart_namestore (void *cls,
348 const struct GNUNET_SCHEDULER_TaskContext *tc)
349{
350 if (GNUNET_OK != write_configuration ())
351 return; /* no point in re-starting namestore ... */
352 if (NULL != namestore)
353 {
354 GNUNET_break (0 == GNUNET_OS_process_kill (namestore, SIGTERM));
355 GNUNET_OS_process_destroy (namestore);
356 namestore = NULL;
357 }
358 /* FIXME: start namestore */
359 /* FIXME: refresh namestore model! */
360 GNUNET_break (0); // not implemented...
311} 361}
312 362
313 363