diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-06 19:59:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-06 19:59:59 +0000 |
commit | 7db4f64461a77f19bb39f1b84d26f96e6acf40ab (patch) | |
tree | 7d2adef1cebe18d80806bba3d534e9a1e4a44ac6 /src/fs/gnunet-service-fs_indexing.c | |
parent | 0ece77aca2114b6e5ec153477fccb43ceb807c77 (diff) | |
download | gnunet-7db4f64461a77f19bb39f1b84d26f96e6acf40ab.tar.gz gnunet-7db4f64461a77f19bb39f1b84d26f96e6acf40ab.zip |
allow file hashing cancellation -- and make use of it
Diffstat (limited to 'src/fs/gnunet-service-fs_indexing.c')
-rw-r--r-- | src/fs/gnunet-service-fs_indexing.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index a5ac0dda3..f8593ffd4 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c | |||
@@ -22,6 +22,11 @@ | |||
22 | * @file fs/gnunet-service-fs_indexing.c | 22 | * @file fs/gnunet-service-fs_indexing.c |
23 | * @brief program that provides indexing functions of the file-sharing service | 23 | * @brief program that provides indexing functions of the file-sharing service |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
27 | * - consider doing GNUNET_CRYPTO_hash_file_cancel on active indexing | ||
28 | * jobs during shutdown (currently, shutdown will only happen after | ||
29 | * all of those are done, not sure if this is good or bad) | ||
25 | */ | 30 | */ |
26 | #include "platform.h" | 31 | #include "platform.h" |
27 | #include <float.h> | 32 | #include <float.h> |
@@ -60,6 +65,11 @@ struct IndexInfo | |||
60 | * NULL if we've done this already. | 65 | * NULL if we've done this already. |
61 | */ | 66 | */ |
62 | struct GNUNET_SERVER_TransmitContext *tc; | 67 | struct GNUNET_SERVER_TransmitContext *tc; |
68 | |||
69 | /** | ||
70 | * Context for hashing of the file. | ||
71 | */ | ||
72 | struct GNUNET_CRYPTO_FileHashContext *fhc; | ||
63 | 73 | ||
64 | /** | 74 | /** |
65 | * Hash of the contents of the file. | 75 | * Hash of the contents of the file. |
@@ -282,7 +292,8 @@ hash_for_index_val (void *cls, | |||
282 | res) | 292 | res) |
283 | { | 293 | { |
284 | struct IndexInfo *ii = cls; | 294 | struct IndexInfo *ii = cls; |
285 | 295 | ||
296 | ii->fhc = NULL; | ||
286 | if ( (res == NULL) || | 297 | if ( (res == NULL) || |
287 | (0 != memcmp (res, | 298 | (0 != memcmp (res, |
288 | &ii->file_id, | 299 | &ii->file_id, |
@@ -375,12 +386,14 @@ GNUNET_FS_handle_index_start (void *cls, | |||
375 | (unsigned int) mydev); | 386 | (unsigned int) mydev); |
376 | #endif | 387 | #endif |
377 | /* slow validation, need to hash full file (again) */ | 388 | /* slow validation, need to hash full file (again) */ |
378 | GNUNET_CRYPTO_hash_file (sched, | 389 | ii->fhc = GNUNET_CRYPTO_hash_file (sched, |
379 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 390 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
380 | fn, | 391 | fn, |
381 | HASHING_BLOCKSIZE, | 392 | HASHING_BLOCKSIZE, |
382 | &hash_for_index_val, | 393 | &hash_for_index_val, |
383 | ii); | 394 | ii); |
395 | if (ii->fhc == NULL) | ||
396 | hash_for_index_val (ii, NULL); | ||
384 | GNUNET_free (fn); | 397 | GNUNET_free (fn); |
385 | } | 398 | } |
386 | 399 | ||