projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git+ssh://gnunet.org/gnunet
[oweals/gnunet.git]
/
src
/
fs
/
gnunet-publish.c
diff --git
a/src/fs/gnunet-publish.c
b/src/fs/gnunet-publish.c
index 7844acd96a03e7650a9604f6ed6eae45a7531208..a563d7b7a76d9e1c9baebde7ce73f9d5335aa732 100644
(file)
--- a/
src/fs/gnunet-publish.c
+++ b/
src/fs/gnunet-publish.c
@@
-1,6
+1,6
@@
/*
This file is part of GNUnet.
/*
This file is part of GNUnet.
- Copyright (C) 2001-2013
Christian Grothoff (and other contributing authors)
+ Copyright (C) 2001-2013
GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@
-14,8
+14,8
@@
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 5
9 Temple Place - Suite 330
,
- Boston, MA 0211
1-1307
, USA.
+ Free Software Foundation, Inc., 5
1 Franklin Street, Fifth Floor
,
+ Boston, MA 0211
0-1301
, USA.
*/
/**
* @file fs/gnunet-publish.c
*/
/**
* @file fs/gnunet-publish.c
@@
-30,9
+30,9
@@
#include "gnunet_identity_service.h"
/**
#include "gnunet_identity_service.h"
/**
- * Global return value from
'main'
.
+ * Global return value from
#main()
.
*/
*/
-static int ret
= 1
;
+static int ret;
/**
* Command line option 'verbose' set
/**
* Command line option 'verbose' set
@@
-124,11
+124,6
@@
static int extract_only;
*/
static int do_disable_creation_time;
*/
static int do_disable_creation_time;
-/**
- * Task run on CTRL-C to kill everything nicely.
- */
-static struct GNUNET_SCHEDULER_Task * kill_task;
-
/**
* Handle to the directory scanner (for recursive insertions).
*/
/**
* Handle to the directory scanner (for recursive insertions).
*/
@@
-151,15
+146,17
@@
static struct GNUNET_IDENTITY_Handle *identity;
* FS state.
*
* @param cls NULL
* FS state.
*
* @param cls NULL
- * @param tc scheduler context
*/
static void
*/
static void
-do_stop_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_stop_task (void *cls)
{
struct GNUNET_FS_PublishContext *p;
{
struct GNUNET_FS_PublishContext *p;
- kill_task = NULL;
+ if (NULL != ds)
+ {
+ GNUNET_FS_directory_scan_abort (ds);
+ ds = NULL;
+ }
if (NULL != identity)
{
GNUNET_IDENTITY_disconnect (identity);
if (NULL != identity)
{
GNUNET_IDENTITY_disconnect (identity);
@@
-171,37
+168,21
@@
do_stop_task (void *cls,
pc = NULL;
GNUNET_FS_publish_stop (p);
}
pc = NULL;
GNUNET_FS_publish_stop (p);
}
+ if (NULL != ctx)
+ {
+ GNUNET_FS_stop (ctx);
+ ctx = NULL;
+ }
if (NULL != meta)
{
GNUNET_CONTAINER_meta_data_destroy (meta);
meta = NULL;
}
if (NULL != meta)
{
GNUNET_CONTAINER_meta_data_destroy (meta);
meta = NULL;
}
-}
-
-
-/**
- * Stop the directory scanner (we had an error).
- *
- * @param cls closure
- * @param tc scheduler context
- */
-static void
-stop_scanner_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- kill_task = NULL;
- if (NULL != ds)
- {
- GNUNET_FS_directory_scan_abort (ds);
- ds = NULL;
- }
- if (NULL != identity)
+ if (NULL != uri)
{
{
- GNUNET_
IDENTITY_disconnect (identity
);
-
identity
= NULL;
+ GNUNET_
FS_uri_destroy (uri
);
+
uri
= NULL;
}
}
- GNUNET_FS_stop (ctx);
- ctx = NULL;
- ret = 1;
}
}
@@
-254,14
+235,11
@@
progress_cb (void *cls,
}
break;
case GNUNET_FS_STATUS_PUBLISH_ERROR:
}
break;
case GNUNET_FS_STATUS_PUBLISH_ERROR:
- FPRINTF (stderr, _("Error publishing: %s.\n"),
+ FPRINTF (stderr,
+ _("Error publishing: %s.\n"),
info->value.publish.specifics.error.message);
info->value.publish.specifics.error.message);
- if (kill_task != NULL)
- {
- GNUNET_SCHEDULER_cancel (kill_task);
- kill_task = NULL;
- }
- kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
+ ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
FPRINTF (stdout,
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
FPRINTF (stdout,
@@
-284,11
+262,9
@@
progress_cb (void *cls,
}
if (NULL == info->value.publish.pctx)
{
}
if (NULL == info->value.publish.pctx)
{
- if (NULL != kill_task)
- GNUNET_SCHEDULER_cancel (kill_task);
- kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
+ ret = 0;
+ GNUNET_SCHEDULER_shutdown ();
}
}
- ret = 0;
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
GNUNET_break (NULL == pc);
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
GNUNET_break (NULL == pc);
@@
-312,6
+288,8
@@
progress_cb (void *cls,
_("Cleanup after abort failed.\n"));
GNUNET_FS_unindex_stop (info->value.unindex.uc);
return NULL;
_("Cleanup after abort failed.\n"));
GNUNET_FS_unindex_stop (info->value.unindex.uc);
return NULL;
+ case GNUNET_FS_STATUS_UNINDEX_STOPPED:
+ return NULL;
default:
FPRINTF (stderr,
_("Unexpected status: %d\n"),
default:
FPRINTF (stderr,
_("Unexpected status: %d\n"),
@@
-349,9
+327,15
@@
meta_printer (void *cls,
if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type)
return 0;
#if HAVE_LIBEXTRACTOR
if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type)
return 0;
#if HAVE_LIBEXTRACTOR
- FPRINTF (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
+ FPRINTF (stdout,
+ "\t%s - %s\n",
+ EXTRACTOR_metatype_to_string (type),
+ data);
#else
#else
- FPRINTF (stdout, "\t%d - %s\n", type, data);
+ FPRINTF (stdout,
+ "\t%d - %s\n",
+ type,
+ data);
#endif
return 0;
}
#endif
return 0;
}
@@
-442,17
+426,26
@@
publish_inspector (void *cls,
fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
fs = GNUNET_STRINGS_byte_size_fancy (length);
fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
fs = GNUNET_STRINGS_byte_size_fancy (length);
- FPRINTF (stdout, _("Meta data for file `%s' (%s)\n"), fn, fs);
+ FPRINTF (stdout,
+ _("Meta data for file `%s' (%s)\n"),
+ fn,
+ fs);
GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL);
GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL);
- FPRINTF (stdout, _("Keywords for file `%s' (%s)\n"), fn, fs);
+ FPRINTF (stdout,
+ _("Keywords for file `%s' (%s)\n"),
+ fn,
+ fs);
GNUNET_free (fn);
GNUNET_free (fs);
if (NULL != *uri)
GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL);
GNUNET_free (fn);
GNUNET_free (fs);
if (NULL != *uri)
GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL);
- FPRINTF (stdout, "%s", "\n");
+ FPRINTF (stdout,
+ "%s",
+ "\n");
}
if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
}
if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
- GNUNET_FS_file_information_inspect (fi, &publish_inspector, fi);
+ GNUNET_FS_file_information_inspect (fi,
+ &publish_inspector, fi);
return GNUNET_OK;
}
return GNUNET_OK;
}
@@
-473,13
+466,12
@@
uri_sks_continuation (void *cls,
{
if (NULL != emsg)
{
{
if (NULL != emsg)
{
- FPRINTF (stderr, "%s\n", emsg);
+ FPRINTF (stderr,
+ "%s\n",
+ emsg);
ret = 1;
}
ret = 1;
}
- GNUNET_FS_uri_destroy (uri);
- uri = NULL;
- GNUNET_FS_stop (ctx);
- ctx = NULL;
+ GNUNET_SCHEDULER_shutdown ();
}
}
@@
-501,21
+493,26
@@
uri_ksk_continuation (void *cls,
if (NULL != emsg)
{
if (NULL != emsg)
{
- FPRINTF (stderr, "%s\n", emsg);
+ FPRINTF (stderr,
+ "%s\n",
+ emsg);
ret = 1;
}
if (NULL != namespace)
{
priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
ret = 1;
}
if (NULL != namespace)
{
priv = GNUNET_IDENTITY_ego_get_private_key (namespace);
- GNUNET_FS_publish_sks (ctx, priv, this_id, next_id, meta, uri, &bo,
+ GNUNET_FS_publish_sks (ctx,
+ priv,
+ this_id,
+ next_id,
+ meta,
+ uri,
+ &bo,
GNUNET_FS_PUBLISH_OPTION_NONE,
&uri_sks_continuation, NULL);
return;
}
GNUNET_FS_PUBLISH_OPTION_NONE,
&uri_sks_continuation, NULL);
return;
}
- GNUNET_FS_uri_destroy (uri);
- uri = NULL;
- GNUNET_FS_stop (ctx);
- ctx = NULL;
+ GNUNET_SCHEDULER_shutdown ();
}
}
@@
-590,8
+587,8
@@
directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
FPRINTF (stderr,
"%s",
_("Could not publish\n"));
FPRINTF (stderr,
"%s",
_("Could not publish\n"));
- GNUNET_SCHEDULER_shutdown ();
ret = 1;
ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_FS_file_information_inspect (fi, &publish_inspector, NULL);
return;
}
GNUNET_FS_file_information_inspect (fi, &publish_inspector, NULL);
@@
-615,8
+612,8
@@
directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result)
FPRINTF (stderr,
"%s",
_("Could not start publishing.\n"));
FPRINTF (stderr,
"%s",
_("Could not start publishing.\n"));
- GNUNET_SCHEDULER_shutdown ();
ret = 1;
ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
return;
}
}
return;
}
}
@@
-687,12
+684,8
@@
directory_scan_cb (void *cls,
FPRINTF (stdout,
"%s",
_("Internal error scanning directory.\n"));
FPRINTF (stdout,
"%s",
_("Internal error scanning directory.\n"));
- if (kill_task != NULL)
- {
- GNUNET_SCHEDULER_cancel (kill_task);
- kill_task = NULL;
- }
- kill_task = GNUNET_SCHEDULER_add_now (&stop_scanner_task, NULL);
+ ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
break;
default:
GNUNET_assert (0);
break;
default:
GNUNET_assert (0);
@@
-720,6
+713,7
@@
identity_continuation (const char *args0)
FPRINTF (stderr,
_("Selected pseudonym `%s' unknown\n"),
pseudonym);
FPRINTF (stderr,
_("Selected pseudonym `%s' unknown\n"),
pseudonym);
+ ret = 1;
GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_SCHEDULER_shutdown ();
return;
}
@@
-732,8
+726,8
@@
identity_continuation (const char *args0)
_("Failed to parse URI: %s\n"),
emsg);
GNUNET_free (emsg);
_("Failed to parse URI: %s\n"),
emsg);
GNUNET_free (emsg);
- GNUNET_SCHEDULER_shutdown ();
ret = 1;
ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_FS_publish_ksk (ctx, topKeywords,
return;
}
GNUNET_FS_publish_ksk (ctx, topKeywords,
@@
-878,10
+872,8
@@
run (void *cls,
ret = 1;
return;
}
ret = 1;
return;
}
- kill_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &do_stop_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
+ NULL);
if (NULL != pseudonym)
identity = GNUNET_IDENTITY_connect (cfg,
&identity_cb,
if (NULL != pseudonym)
identity = GNUNET_IDENTITY_connect (cfg,
&identity_cb,