[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -fix gnunet-fs shutdown
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -fix gnunet-fs shutdown |
Date: |
Sat, 22 Oct 2022 16:59:46 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 16e780465 -fix gnunet-fs shutdown
16e780465 is described below
commit 16e78046530c204f2d349a13752fd8f8c30f7482
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Oct 22 16:59:41 2022 +0200
-fix gnunet-fs shutdown
---
contrib/sphinx | 2 +-
src/fs/gnunet-fs.c | 90 +++++++++++++++++++++++++++++------------
src/include/gnunet_fs_service.h | 3 +-
3 files changed, 67 insertions(+), 28 deletions(-)
diff --git a/contrib/sphinx b/contrib/sphinx
index c0e1c1d1c..4e5c8c6d4 160000
--- a/contrib/sphinx
+++ b/contrib/sphinx
@@ -1 +1 @@
-Subproject commit c0e1c1d1cc7531130ba9de8e74520fd21c3aa574
+Subproject commit 4e5c8c6d4a0befd55fba632b8b1bed482ea2bac7
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 70a0034a0..f9d63e101 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -35,6 +35,11 @@ static int ret;
*/
static struct GNUNET_FS_Handle *fs;
+/**
+ * Handle for the index listing operation.
+ */
+static struct GNUNET_FS_GetIndexedContext *gic;
+
/**
* Option -i given?
*/
@@ -54,25 +59,52 @@ static unsigned int verbose;
* @param file_id hash of the contents of the indexed file
* @return GNUNET_OK to continue iteration
*/
-static int
+static enum GNUNET_GenericReturnValue
print_indexed (void *cls,
const char *filename,
const struct GNUNET_HashCode *file_id)
{
if (NULL == filename)
{
- GNUNET_FS_stop (fs);
- fs = NULL;
+ gic = NULL;
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_OK;
}
if (verbose)
- fprintf (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
+ fprintf (stdout,
+ "%s: %s\n",
+ GNUNET_h2s (file_id),
+ filename);
else
- fprintf (stdout, "%s\n", filename);
+ fprintf (stdout,
+ "%s\n",
+ filename);
return GNUNET_OK;
}
+/**
+ * Function run on shutdown.
+ *
+ * @param cls NULL
+ */
+static void
+do_shutdown (void *cls)
+{
+ (void) cls;
+ if (NULL != gic)
+ {
+ GNUNET_FS_get_indexed_files_cancel (gic);
+ gic = NULL;
+ }
+ if (NULL != fs)
+ {
+ GNUNET_FS_stop (fs);
+ fs = NULL;
+ }
+}
+
+
/**
* Main function that will be run by the scheduler.
*
@@ -87,26 +119,29 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- if (list_indexed_files)
+ if (! list_indexed_files)
+ return;
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ NULL);
+ fs = GNUNET_FS_start (cfg,
+ "gnunet-fs",
+ NULL,
+ NULL,
+ GNUNET_FS_FLAGS_NONE,
+ GNUNET_FS_OPTIONS_END);
+ if (NULL == fs)
+ {
+ ret = 1;
+ return;
+ }
+ gic = GNUNET_FS_get_indexed_files (fs,
+ &print_indexed,
+ NULL);
+ if (NULL == gic)
{
- fs = GNUNET_FS_start (cfg,
- "gnunet-fs",
- NULL,
- NULL,
- GNUNET_FS_FLAGS_NONE,
- GNUNET_FS_OPTIONS_END);
- if (NULL == fs)
- {
- ret = 1;
- return;
- }
- if (NULL == GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL))
- {
- ret = 2;
- GNUNET_FS_stop (fs);
- fs = NULL;
- return;
- }
+ ret = 2;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
}
}
@@ -119,7 +154,8 @@ run (void *cls,
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('i',
@@ -132,7 +168,9 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_END
};
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
return 2;
ret = (GNUNET_OK ==
GNUNET_PROGRAM_run (argc,
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 8ae826380..d9f2ee563 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -1732,7 +1732,8 @@ GNUNET_FS_file_information_get_id (struct
GNUNET_FS_FileInformation *s);
* @return "filename" field of the structure (can be NULL)
*/
const char *
-GNUNET_FS_file_information_get_filename (const struct
GNUNET_FS_FileInformation *s);
+GNUNET_FS_file_information_get_filename (const struct
+ GNUNET_FS_FileInformation *s);
/**
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -fix gnunet-fs shutdown,
gnunet <=