diff options
-rw-r--r-- | doc/man/gnunet-search.1 | 4 | ||||
-rw-r--r-- | src/fs/gnunet-search.c | 26 |
2 files changed, 25 insertions, 5 deletions
diff --git a/doc/man/gnunet-search.1 b/doc/man/gnunet-search.1 index 526097733..8f9789400 100644 --- a/doc/man/gnunet-search.1 +++ b/doc/man/gnunet-search.1 | |||
@@ -42,6 +42,10 @@ Writes a GNUnet directory containing all of the search results to FILENAME. | |||
42 | Only search locally, do not forward requests to other peers. | 42 | Only search locally, do not forward requests to other peers. |
43 | 43 | ||
44 | .TP | 44 | .TP |
45 | \fB\-t \fIVALUE\fR, \fB\-\-timeout=\fIVALUE\fR | ||
46 | Automatically timeout search after VALUE ms. Otherwise the search runs until gnunet\-search is aborted with CTRL\-C. | ||
47 | |||
48 | .TP | ||
45 | \fB\-v\fR, \fB\-\-version\fR | 49 | \fB\-v\fR, \fB\-\-version\fR |
46 | print the version number | 50 | print the version number |
47 | 51 | ||
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index cc3ef7c87..f2414322d 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -42,6 +42,8 @@ static struct GNUNET_FS_DirectoryBuilder *db; | |||
42 | 42 | ||
43 | static unsigned int anonymity = 1; | 43 | static unsigned int anonymity = 1; |
44 | 44 | ||
45 | static unsigned long long timeout; | ||
46 | |||
45 | static int verbose; | 47 | static int verbose; |
46 | 48 | ||
47 | static int local_only; | 49 | static int local_only; |
@@ -231,6 +233,7 @@ run (void *cls, | |||
231 | struct GNUNET_FS_Uri *uri; | 233 | struct GNUNET_FS_Uri *uri; |
232 | unsigned int argc; | 234 | unsigned int argc; |
233 | enum GNUNET_FS_SearchOptions options; | 235 | enum GNUNET_FS_SearchOptions options; |
236 | struct GNUNET_TIME_Relative delay; | ||
234 | 237 | ||
235 | argc = 0; | 238 | argc = 0; |
236 | while (NULL != args[argc]) | 239 | while (NULL != args[argc]) |
@@ -242,7 +245,6 @@ run (void *cls, | |||
242 | fprintf (stderr, | 245 | fprintf (stderr, |
243 | _("Could not create keyword URI from arguments.\n")); | 246 | _("Could not create keyword URI from arguments.\n")); |
244 | ret = 1; | 247 | ret = 1; |
245 | GNUNET_FS_uri_destroy (uri); | ||
246 | return; | 248 | return; |
247 | } | 249 | } |
248 | cfg = c; | 250 | cfg = c; |
@@ -280,9 +282,19 @@ run (void *cls, | |||
280 | ret = 1; | 282 | ret = 1; |
281 | return; | 283 | return; |
282 | } | 284 | } |
283 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 285 | if (timeout != 0) |
284 | &shutdown_task, | 286 | { |
285 | NULL); | 287 | delay.rel_value = timeout; |
288 | GNUNET_SCHEDULER_add_delayed (delay, | ||
289 | &shutdown_task, | ||
290 | NULL); | ||
291 | } | ||
292 | else | ||
293 | { | ||
294 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
295 | &shutdown_task, | ||
296 | NULL); | ||
297 | } | ||
286 | } | 298 | } |
287 | 299 | ||
288 | 300 | ||
@@ -307,11 +319,15 @@ main (int argc, char *const *argv) | |||
307 | gettext_noop | 319 | gettext_noop |
308 | ("write search results to file starting with PREFIX"), | 320 | ("write search results to file starting with PREFIX"), |
309 | 1, &GNUNET_GETOPT_set_string, &output_filename}, | 321 | 1, &GNUNET_GETOPT_set_string, &output_filename}, |
322 | {'t', "timeout", "VALUE", | ||
323 | gettext_noop | ||
324 | ("automatically terminate search after VALUE ms"), | ||
325 | 1, &GNUNET_GETOPT_set_ulong, &timeout}, | ||
310 | {'V', "verbose", NULL, | 326 | {'V', "verbose", NULL, |
311 | gettext_noop ("be verbose (print progress information)"), | 327 | gettext_noop ("be verbose (print progress information)"), |
312 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 328 | 0, &GNUNET_GETOPT_set_one, &verbose}, |
313 | GNUNET_GETOPT_OPTION_END | 329 | GNUNET_GETOPT_OPTION_END |
314 | }; | 330 | }; |
315 | return (GNUNET_OK == | 331 | return (GNUNET_OK == |
316 | GNUNET_PROGRAM_run (argc, | 332 | GNUNET_PROGRAM_run (argc, |
317 | argv, | 333 | argv, |