aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-unindex.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-03-11 12:47:52 +0000
committerChristian Grothoff <christian@grothoff.org>2010-03-11 12:47:52 +0000
commita5b3f0b503c7afec7bbdf67fa3ae2e31c6cfd837 (patch)
tree7baa74c32de98004d3cef97400ef64dc82fbb9a7 /src/fs/gnunet-unindex.c
parent9c923d1ef6752f40535124439fed299ee4150795 (diff)
downloadgnunet-a5b3f0b503c7afec7bbdf67fa3ae2e31c6cfd837.tar.gz
gnunet-a5b3f0b503c7afec7bbdf67fa3ae2e31c6cfd837.zip
fixing shutdown
Diffstat (limited to 'src/fs/gnunet-unindex.c')
-rw-r--r--src/fs/gnunet-unindex.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index bc87e59f9..e934bf521 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -38,6 +38,31 @@ static struct GNUNET_FS_Handle *ctx;
38 38
39static struct GNUNET_FS_UnindexContext *uc; 39static struct GNUNET_FS_UnindexContext *uc;
40 40
41static struct GNUNET_SCHEDULER_Handle *sched;
42
43
44static void
45cleanup_task (void *cls,
46 const struct GNUNET_SCHEDULER_TaskContext *tc)
47{
48 GNUNET_FS_stop (ctx);
49 ctx = NULL;
50}
51
52
53static void
54shutdown_task (void *cls,
55 const struct GNUNET_SCHEDULER_TaskContext *tc)
56{
57 struct GNUNET_FS_UnindexContext *u;
58
59 if (uc != NULL)
60 {
61 u = uc;
62 uc = NULL;
63 GNUNET_FS_unindex_stop (u);
64 }
65}
41 66
42/** 67/**
43 * Called by FS client to give information about the progress of an 68 * Called by FS client to give information about the progress of an
@@ -78,15 +103,18 @@ progress_cb (void *cls,
78 fprintf (stderr, 103 fprintf (stderr,
79 _("Error unindexing: %s.\n"), 104 _("Error unindexing: %s.\n"),
80 info->value.unindex.specifics.error.message); 105 info->value.unindex.specifics.error.message);
81 GNUNET_FS_unindex_stop (uc); 106 GNUNET_SCHEDULER_shutdown (sched);
82 break; 107 break;
83 case GNUNET_FS_STATUS_UNINDEX_COMPLETED: 108 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
84 fprintf (stdout, 109 fprintf (stdout,
85 _("Unindexing done.\n")); 110 _("Unindexing done.\n"));
86 GNUNET_FS_unindex_stop (uc); 111 GNUNET_SCHEDULER_shutdown (sched);
87 break; 112 break;
88 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 113 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
89 GNUNET_FS_stop (ctx); 114 GNUNET_SCHEDULER_add_continuation (sched,
115 &cleanup_task,
116 NULL,
117 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
90 break; 118 break;
91 default: 119 default:
92 fprintf (stderr, 120 fprintf (stderr,
@@ -102,14 +130,14 @@ progress_cb (void *cls,
102 * Main function that will be run by the scheduler. 130 * Main function that will be run by the scheduler.
103 * 131 *
104 * @param cls closure 132 * @param cls closure
105 * @param sched the scheduler to use 133 * @param s the scheduler to use
106 * @param args remaining command-line arguments 134 * @param args remaining command-line arguments
107 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 135 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
108 * @param c configuration 136 * @param c configuration
109 */ 137 */
110static void 138static void
111run (void *cls, 139run (void *cls,
112 struct GNUNET_SCHEDULER_Handle *sched, 140 struct GNUNET_SCHEDULER_Handle *s,
113 char *const *args, 141 char *const *args,
114 const char *cfgfile, 142 const char *cfgfile,
115 const struct GNUNET_CONFIGURATION_Handle *c) 143 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -122,6 +150,7 @@ run (void *cls,
122 ret = -1; 150 ret = -1;
123 return; 151 return;
124 } 152 }
153 sched = s;
125 cfg = c; 154 cfg = c;
126 ctx = GNUNET_FS_start (sched, 155 ctx = GNUNET_FS_start (sched,
127 cfg, 156 cfg,
@@ -146,7 +175,12 @@ run (void *cls,
146 fprintf (stderr, 175 fprintf (stderr,
147 _("Could not start unindex operation.\n")); 176 _("Could not start unindex operation.\n"));
148 GNUNET_FS_stop (ctx); 177 GNUNET_FS_stop (ctx);
178 return;
149 } 179 }
180 GNUNET_SCHEDULER_add_delayed (sched,
181 GNUNET_TIME_UNIT_FOREVER_REL,
182 &shutdown_task,
183 NULL);
150} 184}
151 185
152 186