aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_hash.c')
-rw-r--r--src/util/crypto_hash.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index ab6fc28cf..9e5af4ab5 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -83,11 +83,6 @@ struct GNUNET_CRYPTO_FileHashContext
83 struct GNUNET_DISK_FileHandle *fh; 83 struct GNUNET_DISK_FileHandle *fh;
84 84
85 /** 85 /**
86 * Our scheduler.
87 */
88 struct GNUNET_SCHEDULER_Handle *sched;
89
90 /**
91 * Cummulated hash. 86 * Cummulated hash.
92 */ 87 */
93 gcry_md_hd_t md; 88 gcry_md_hd_t md;
@@ -166,8 +161,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
166 return; 161 return;
167 } 162 }
168 fhc->task 163 fhc->task
169 = GNUNET_SCHEDULER_add_after (tc->sched, 164 = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK,
170 GNUNET_SCHEDULER_NO_TASK,
171 &file_hash_task, fhc); 165 &file_hash_task, fhc);
172} 166}
173 167
@@ -175,7 +169,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
175/** 169/**
176 * Compute the hash of an entire file. 170 * Compute the hash of an entire file.
177 * 171 *
178 * @param sched scheduler to use
179 * @param priority scheduling priority to use 172 * @param priority scheduling priority to use
180 * @param filename name of file to hash 173 * @param filename name of file to hash
181 * @param blocksize number of bytes to process in one task 174 * @param blocksize number of bytes to process in one task
@@ -184,8 +177,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
184 * @return NULL on (immediate) errror 177 * @return NULL on (immediate) errror
185 */ 178 */
186struct GNUNET_CRYPTO_FileHashContext * 179struct GNUNET_CRYPTO_FileHashContext *
187GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, 180GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
188 enum GNUNET_SCHEDULER_Priority priority,
189 const char *filename, 181 const char *filename,
190 size_t blocksize, 182 size_t blocksize,
191 GNUNET_CRYPTO_HashCompletedCallback callback, 183 GNUNET_CRYPTO_HashCompletedCallback callback,
@@ -197,7 +189,6 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
197 fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize); 189 fhc = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize);
198 fhc->callback = callback; 190 fhc->callback = callback;
199 fhc->callback_cls = callback_cls; 191 fhc->callback_cls = callback_cls;
200 fhc->sched = sched;
201 fhc->buffer = (unsigned char *) &fhc[1]; 192 fhc->buffer = (unsigned char *) &fhc[1];
202 fhc->filename = GNUNET_strdup (filename); 193 fhc->filename = GNUNET_strdup (filename);
203 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) 194 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0))
@@ -223,7 +214,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
223 return NULL; 214 return NULL;
224 } 215 }
225 fhc->task 216 fhc->task
226 = GNUNET_SCHEDULER_add_with_priority (sched, priority, 217 = GNUNET_SCHEDULER_add_with_priority (priority,
227 &file_hash_task, fhc); 218 &file_hash_task, fhc);
228 return fhc; 219 return fhc;
229} 220}
@@ -237,8 +228,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
237void 228void
238GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc) 229GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc)
239{ 230{
240 GNUNET_SCHEDULER_cancel (fhc->sched, 231 GNUNET_SCHEDULER_cancel (fhc->task);
241 fhc->task);
242 GNUNET_free (fhc->filename); 232 GNUNET_free (fhc->filename);
243 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); 233 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh));
244 GNUNET_free (fhc); 234 GNUNET_free (fhc);