diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs.c | 11 | ||||
-rw-r--r-- | src/fs/fs_publish.c | 350 | ||||
-rw-r--r-- | src/fs/test_fs_publish_persistence.c | 12 |
3 files changed, 219 insertions, 154 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c index fdaa12205..046c4dbb0 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c | |||
@@ -1477,10 +1477,13 @@ deserialize_publish_file (void *cls, | |||
1477 | 1477 | ||
1478 | /* re-start publishing (if needed)... */ | 1478 | /* re-start publishing (if needed)... */ |
1479 | if (pc->all_done != GNUNET_YES) | 1479 | if (pc->all_done != GNUNET_YES) |
1480 | pc->upload_task | 1480 | { |
1481 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 1481 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); |
1482 | &GNUNET_FS_publish_main_, | 1482 | pc->upload_task |
1483 | pc); | 1483 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
1484 | &GNUNET_FS_publish_main_, | ||
1485 | pc); | ||
1486 | } | ||
1484 | if (GNUNET_OK != | 1487 | if (GNUNET_OK != |
1485 | GNUNET_BIO_read_close (rh, &emsg)) | 1488 | GNUNET_BIO_read_close (rh, &emsg)) |
1486 | { | 1489 | { |
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 26d21bb0e..777450ec2 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -45,7 +45,7 @@ struct PutContCtx | |||
45 | /** | 45 | /** |
46 | * Current publishing context. | 46 | * Current publishing context. |
47 | */ | 47 | */ |
48 | struct GNUNET_FS_PublishContext *sc; | 48 | struct GNUNET_FS_PublishContext *pc; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Specific file with the block. | 51 | * Specific file with the block. |
@@ -69,18 +69,18 @@ struct PutContCtx | |||
69 | * a publish event and call the callback. | 69 | * a publish event and call the callback. |
70 | * | 70 | * |
71 | * @param pi structure to fill in | 71 | * @param pi structure to fill in |
72 | * @param sc overall publishing context | 72 | * @param pc overall publishing context |
73 | * @param p file information for the file being published | 73 | * @param p file information for the file being published |
74 | * @param offset where in the file are we so far | 74 | * @param offset where in the file are we so far |
75 | * @return value returned from callback | 75 | * @return value returned from callback |
76 | */ | 76 | */ |
77 | void * | 77 | void * |
78 | GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | 78 | GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, |
79 | struct GNUNET_FS_PublishContext *sc, | 79 | struct GNUNET_FS_PublishContext *pc, |
80 | const struct GNUNET_FS_FileInformation *p, | 80 | const struct GNUNET_FS_FileInformation *p, |
81 | uint64_t offset) | 81 | uint64_t offset) |
82 | { | 82 | { |
83 | pi->value.publish.pc = sc; | 83 | pi->value.publish.pc = pc; |
84 | pi->value.publish.fi = p; | 84 | pi->value.publish.fi = p; |
85 | pi->value.publish.cctx | 85 | pi->value.publish.cctx |
86 | = p->client_info; | 86 | = p->client_info; |
@@ -96,7 +96,7 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
96 | pi->value.publish.completed = offset; | 96 | pi->value.publish.completed = offset; |
97 | pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time); | 97 | pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time); |
98 | pi->value.publish.anonymity = p->bo.anonymity_level; | 98 | pi->value.publish.anonymity = p->bo.anonymity_level; |
99 | return sc->h->upcb (sc->h->upcb_cls, | 99 | return pc->h->upcb (pc->h->upcb_cls, |
100 | pi); | 100 | pi); |
101 | } | 101 | } |
102 | 102 | ||
@@ -113,6 +113,10 @@ publish_cleanup (void *cls, | |||
113 | { | 113 | { |
114 | struct GNUNET_FS_PublishContext *pc = cls; | 114 | struct GNUNET_FS_PublishContext *pc = cls; |
115 | 115 | ||
116 | #if DEBUG_PUBLISH | ||
117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
118 | "Cleaning up publish context (done!)\n"); | ||
119 | #endif | ||
116 | if (pc->fhc != NULL) | 120 | if (pc->fhc != NULL) |
117 | { | 121 | { |
118 | GNUNET_CRYPTO_hash_file_cancel (pc->fhc); | 122 | GNUNET_CRYPTO_hash_file_cancel (pc->fhc); |
@@ -120,7 +124,10 @@ publish_cleanup (void *cls, | |||
120 | } | 124 | } |
121 | GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); | 125 | GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); |
122 | if (pc->namespace != NULL) | 126 | if (pc->namespace != NULL) |
123 | GNUNET_FS_namespace_delete (pc->namespace, GNUNET_NO); | 127 | { |
128 | GNUNET_FS_namespace_delete (pc->namespace, GNUNET_NO); | ||
129 | pc->namespace = NULL; | ||
130 | } | ||
124 | GNUNET_free_non_null (pc->nid); | 131 | GNUNET_free_non_null (pc->nid); |
125 | GNUNET_free_non_null (pc->nuid); | 132 | GNUNET_free_non_null (pc->nuid); |
126 | GNUNET_free_non_null (pc->serialization); | 133 | GNUNET_free_non_null (pc->serialization); |
@@ -130,7 +137,11 @@ publish_cleanup (void *cls, | |||
130 | pc->dsh = NULL; | 137 | pc->dsh = NULL; |
131 | } | 138 | } |
132 | if (pc->client != NULL) | 139 | if (pc->client != NULL) |
133 | GNUNET_CLIENT_disconnect (pc->client, GNUNET_NO); | 140 | { |
141 | GNUNET_CLIENT_disconnect (pc->client, GNUNET_NO); | ||
142 | pc->client = NULL; | ||
143 | } | ||
144 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); | ||
134 | GNUNET_free (pc); | 145 | GNUNET_free (pc); |
135 | } | 146 | } |
136 | 147 | ||
@@ -151,17 +162,18 @@ ds_put_cont (void *cls, | |||
151 | struct PutContCtx *pcc = cls; | 162 | struct PutContCtx *pcc = cls; |
152 | struct GNUNET_FS_ProgressInfo pi; | 163 | struct GNUNET_FS_ProgressInfo pi; |
153 | 164 | ||
154 | if (GNUNET_SYSERR == pcc->sc->in_network_wait) | 165 | pcc->pc->qre = NULL; |
166 | if (GNUNET_SYSERR == pcc->pc->in_network_wait) | ||
155 | { | 167 | { |
156 | /* we were aborted in the meantime, finish shutdown! */ | 168 | /* we were aborted in the meantime, finish shutdown! */ |
157 | GNUNET_SCHEDULER_add_continuation (&publish_cleanup, | 169 | GNUNET_SCHEDULER_add_continuation (&publish_cleanup, |
158 | pcc->sc, | 170 | pcc->pc, |
159 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 171 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
160 | GNUNET_free (pcc); | 172 | GNUNET_free (pcc); |
161 | return; | 173 | return; |
162 | } | 174 | } |
163 | GNUNET_assert (GNUNET_YES == pcc->sc->in_network_wait); | 175 | GNUNET_assert (GNUNET_YES == pcc->pc->in_network_wait); |
164 | pcc->sc->in_network_wait = GNUNET_NO; | 176 | pcc->pc->in_network_wait = GNUNET_NO; |
165 | if (GNUNET_SYSERR == success) | 177 | if (GNUNET_SYSERR == success) |
166 | { | 178 | { |
167 | GNUNET_asprintf (&pcc->p->emsg, | 179 | GNUNET_asprintf (&pcc->p->emsg, |
@@ -170,22 +182,25 @@ ds_put_cont (void *cls, | |||
170 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | 182 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
171 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 183 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
172 | pi.value.publish.specifics.error.message = pcc->p->emsg; | 184 | pi.value.publish.specifics.error.message = pcc->p->emsg; |
173 | pcc->p->client_info = GNUNET_FS_publish_make_status_ (&pi, pcc->sc, pcc->p, 0); | 185 | pcc->p->client_info = GNUNET_FS_publish_make_status_ (&pi, pcc->pc, pcc->p, 0); |
174 | if ( (pcc->p->is_directory == GNUNET_NO) && | 186 | if ( (pcc->p->is_directory == GNUNET_NO) && |
175 | (pcc->p->filename != NULL) && | 187 | (pcc->p->filename != NULL) && |
176 | (pcc->p->data.file.do_index == GNUNET_YES) ) | 188 | (pcc->p->data.file.do_index == GNUNET_YES) ) |
177 | { | 189 | { |
178 | /* run unindex to clean up */ | 190 | /* run unindex to clean up */ |
179 | GNUNET_FS_unindex_start (pcc->sc->h, | 191 | GNUNET_FS_unindex_start (pcc->pc->h, |
180 | pcc->p->filename, | 192 | pcc->p->filename, |
181 | NULL); | 193 | NULL); |
182 | } | 194 | } |
183 | } | 195 | } |
184 | if (NULL != pcc->cont) | 196 | if (NULL != pcc->cont) |
185 | pcc->sc->upload_task | 197 | { |
186 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 198 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pcc->pc->upload_task); |
187 | pcc->cont, | 199 | pcc->pc->upload_task |
188 | pcc->cont_cls); | 200 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
201 | pcc->cont, | ||
202 | pcc->cont_cls); | ||
203 | } | ||
189 | GNUNET_free (pcc); | 204 | GNUNET_free (pcc); |
190 | } | 205 | } |
191 | 206 | ||
@@ -196,18 +211,18 @@ ds_put_cont (void *cls, | |||
196 | * published. | 211 | * published. |
197 | * | 212 | * |
198 | * @param p the completed upload | 213 | * @param p the completed upload |
199 | * @param sc context of the publication | 214 | * @param pc context of the publication |
200 | */ | 215 | */ |
201 | static void | 216 | static void |
202 | signal_publish_completion (struct GNUNET_FS_FileInformation *p, | 217 | signal_publish_completion (struct GNUNET_FS_FileInformation *p, |
203 | struct GNUNET_FS_PublishContext *sc) | 218 | struct GNUNET_FS_PublishContext *pc) |
204 | { | 219 | { |
205 | struct GNUNET_FS_ProgressInfo pi; | 220 | struct GNUNET_FS_ProgressInfo pi; |
206 | 221 | ||
207 | pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED; | 222 | pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED; |
208 | pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; | 223 | pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; |
209 | pi.value.publish.specifics.completed.chk_uri = p->chk_uri; | 224 | pi.value.publish.specifics.completed.chk_uri = p->chk_uri; |
210 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, | 225 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, |
211 | GNUNET_ntohll (p->chk_uri->data.chk.file_length)); | 226 | GNUNET_ntohll (p->chk_uri->data.chk.file_length)); |
212 | } | 227 | } |
213 | 228 | ||
@@ -218,12 +233,12 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, | |||
218 | * a problem during publication. | 233 | * a problem during publication. |
219 | * | 234 | * |
220 | * @param p the upload that had trouble | 235 | * @param p the upload that had trouble |
221 | * @param sc context of the publication | 236 | * @param pc context of the publication |
222 | * @param emsg error message | 237 | * @param emsg error message |
223 | */ | 238 | */ |
224 | static void | 239 | static void |
225 | signal_publish_error (struct GNUNET_FS_FileInformation *p, | 240 | signal_publish_error (struct GNUNET_FS_FileInformation *p, |
226 | struct GNUNET_FS_PublishContext *sc, | 241 | struct GNUNET_FS_PublishContext *pc, |
227 | const char *emsg) | 242 | const char *emsg) |
228 | { | 243 | { |
229 | struct GNUNET_FS_ProgressInfo pi; | 244 | struct GNUNET_FS_ProgressInfo pi; |
@@ -232,13 +247,13 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p, | |||
232 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | 247 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
233 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 248 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
234 | pi.value.publish.specifics.error.message =emsg; | 249 | pi.value.publish.specifics.error.message =emsg; |
235 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, 0); | 250 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); |
236 | if ( (p->is_directory == GNUNET_NO) && | 251 | if ( (p->is_directory == GNUNET_NO) && |
237 | (p->filename != NULL) && | 252 | (p->filename != NULL) && |
238 | (p->data.file.do_index == GNUNET_YES) ) | 253 | (p->data.file.do_index == GNUNET_YES) ) |
239 | { | 254 | { |
240 | /* run unindex to clean up */ | 255 | /* run unindex to clean up */ |
241 | GNUNET_FS_unindex_start (sc->h, | 256 | GNUNET_FS_unindex_start (pc->h, |
242 | p->filename, | 257 | p->filename, |
243 | NULL); | 258 | NULL); |
244 | } | 259 | } |
@@ -261,6 +276,10 @@ finish_release_reserve (void *cls, | |||
261 | struct GNUNET_FS_PublishContext *pc = cls; | 276 | struct GNUNET_FS_PublishContext *pc = cls; |
262 | 277 | ||
263 | pc->qre = NULL; | 278 | pc->qre = NULL; |
279 | #if DEBUG_PUBLISH | ||
280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
281 | "Releasing reserve done!\n"); | ||
282 | #endif | ||
264 | signal_publish_completion (pc->fi, pc); | 283 | signal_publish_completion (pc->fi, pc); |
265 | pc->all_done = GNUNET_YES; | 284 | pc->all_done = GNUNET_YES; |
266 | GNUNET_FS_publish_sync_ (pc); | 285 | GNUNET_FS_publish_sync_ (pc); |
@@ -312,24 +331,24 @@ publish_sblocks_cont (void *cls, | |||
312 | * We are almost done publishing the structure, | 331 | * We are almost done publishing the structure, |
313 | * add SBlocks (if needed). | 332 | * add SBlocks (if needed). |
314 | * | 333 | * |
315 | * @param sc overall upload data | 334 | * @param pc overall upload data |
316 | */ | 335 | */ |
317 | static void | 336 | static void |
318 | publish_sblock (struct GNUNET_FS_PublishContext *sc) | 337 | publish_sblock (struct GNUNET_FS_PublishContext *pc) |
319 | { | 338 | { |
320 | if (NULL != sc->namespace) | 339 | if (NULL != pc->namespace) |
321 | GNUNET_FS_publish_sks (sc->h, | 340 | GNUNET_FS_publish_sks (pc->h, |
322 | sc->namespace, | 341 | pc->namespace, |
323 | sc->nid, | 342 | pc->nid, |
324 | sc->nuid, | 343 | pc->nuid, |
325 | sc->fi->meta, | 344 | pc->fi->meta, |
326 | sc->fi->chk_uri, | 345 | pc->fi->chk_uri, |
327 | &sc->fi->bo, | 346 | &pc->fi->bo, |
328 | sc->options, | 347 | pc->options, |
329 | &publish_sblocks_cont, | 348 | &publish_sblocks_cont, |
330 | sc); | 349 | pc); |
331 | else | 350 | else |
332 | publish_sblocks_cont (sc, NULL, NULL); | 351 | publish_sblocks_cont (pc, NULL, NULL); |
333 | } | 352 | } |
334 | 353 | ||
335 | 354 | ||
@@ -360,6 +379,7 @@ publish_kblocks_cont (void *cls, | |||
360 | signal_publish_error (p, pc, emsg); | 379 | signal_publish_error (p, pc, emsg); |
361 | GNUNET_FS_file_information_sync_ (p); | 380 | GNUNET_FS_file_information_sync_ (p); |
362 | GNUNET_FS_publish_sync_ (pc); | 381 | GNUNET_FS_publish_sync_ (pc); |
382 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); | ||
363 | pc->upload_task | 383 | pc->upload_task |
364 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 384 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
365 | &GNUNET_FS_publish_main_, | 385 | &GNUNET_FS_publish_main_, |
@@ -378,6 +398,7 @@ publish_kblocks_cont (void *cls, | |||
378 | else | 398 | else |
379 | pc->fi_pos = p->dir; | 399 | pc->fi_pos = p->dir; |
380 | GNUNET_FS_publish_sync_ (pc); | 400 | GNUNET_FS_publish_sync_ (pc); |
401 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); | ||
381 | pc->upload_task | 402 | pc->upload_task |
382 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 403 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
383 | &GNUNET_FS_publish_main_, | 404 | &GNUNET_FS_publish_main_, |
@@ -405,12 +426,12 @@ block_reader (void *cls, | |||
405 | void *buf, | 426 | void *buf, |
406 | char **emsg) | 427 | char **emsg) |
407 | { | 428 | { |
408 | struct GNUNET_FS_PublishContext *sc = cls; | 429 | struct GNUNET_FS_PublishContext *pc = cls; |
409 | struct GNUNET_FS_FileInformation *p; | 430 | struct GNUNET_FS_FileInformation *p; |
410 | size_t pt_size; | 431 | size_t pt_size; |
411 | const char *dd; | 432 | const char *dd; |
412 | 433 | ||
413 | p = sc->fi_pos; | 434 | p = pc->fi_pos; |
414 | if (p->is_directory) | 435 | if (p->is_directory) |
415 | { | 436 | { |
416 | pt_size = GNUNET_MIN(max, | 437 | pt_size = GNUNET_MIN(max, |
@@ -451,13 +472,13 @@ static void | |||
451 | encode_cont (void *cls, | 472 | encode_cont (void *cls, |
452 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 473 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
453 | { | 474 | { |
454 | struct GNUNET_FS_PublishContext *sc = cls; | 475 | struct GNUNET_FS_PublishContext *pc = cls; |
455 | struct GNUNET_FS_FileInformation *p; | 476 | struct GNUNET_FS_FileInformation *p; |
456 | struct GNUNET_FS_ProgressInfo pi; | 477 | struct GNUNET_FS_ProgressInfo pi; |
457 | char *emsg; | 478 | char *emsg; |
458 | uint64_t flen; | 479 | uint64_t flen; |
459 | 480 | ||
460 | p = sc->fi_pos; | 481 | p = pc->fi_pos; |
461 | GNUNET_FS_tree_encoder_finish (p->te, | 482 | GNUNET_FS_tree_encoder_finish (p->te, |
462 | &p->chk_uri, | 483 | &p->chk_uri, |
463 | &emsg); | 484 | &emsg); |
@@ -476,7 +497,7 @@ encode_cont (void *cls, | |||
476 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | 497 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
477 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 498 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
478 | pi.value.publish.specifics.error.message = p->emsg; | 499 | pi.value.publish.specifics.error.message = p->emsg; |
479 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, 0); | 500 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); |
480 | } | 501 | } |
481 | #if DEBUG_PUBLISH | 502 | #if DEBUG_PUBLISH |
482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -489,13 +510,14 @@ encode_cont (void *cls, | |||
489 | pi.value.publish.specifics.progress.offset = flen; | 510 | pi.value.publish.specifics.progress.offset = flen; |
490 | pi.value.publish.specifics.progress.data_len = 0; | 511 | pi.value.publish.specifics.progress.data_len = 0; |
491 | pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen); | 512 | pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen); |
492 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, flen); | 513 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen); |
493 | 514 | ||
494 | /* continue with main */ | 515 | /* continue with main */ |
495 | sc->upload_task | 516 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); |
517 | pc->upload_task | ||
496 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 518 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
497 | &GNUNET_FS_publish_main_, | 519 | &GNUNET_FS_publish_main_, |
498 | sc); | 520 | pc); |
499 | } | 521 | } |
500 | 522 | ||
501 | 523 | ||
@@ -522,31 +544,32 @@ block_proc (void *cls, | |||
522 | const void *block, | 544 | const void *block, |
523 | uint16_t block_size) | 545 | uint16_t block_size) |
524 | { | 546 | { |
525 | struct GNUNET_FS_PublishContext *sc = cls; | 547 | struct GNUNET_FS_PublishContext *pc = cls; |
526 | struct GNUNET_FS_FileInformation *p; | 548 | struct GNUNET_FS_FileInformation *p; |
527 | struct PutContCtx * dpc_cls; | 549 | struct PutContCtx * dpc_cls; |
528 | struct OnDemandBlock odb; | 550 | struct OnDemandBlock odb; |
529 | 551 | ||
530 | p = sc->fi_pos; | 552 | p = pc->fi_pos; |
531 | if (NULL == sc->dsh) | 553 | if (NULL == pc->dsh) |
532 | { | 554 | { |
533 | #if DEBUG_PUBLISH | 555 | #if DEBUG_PUBLISH |
534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
535 | "Waiting for datastore connection\n"); | 557 | "Waiting for datastore connection\n"); |
536 | #endif | 558 | #endif |
537 | sc->upload_task | 559 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); |
560 | pc->upload_task | ||
538 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 561 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
539 | &GNUNET_FS_publish_main_, | 562 | &GNUNET_FS_publish_main_, |
540 | sc); | 563 | pc); |
541 | return; | 564 | return; |
542 | } | 565 | } |
543 | 566 | ||
544 | GNUNET_assert (GNUNET_NO == sc->in_network_wait); | 567 | GNUNET_assert (GNUNET_NO == pc->in_network_wait); |
545 | sc->in_network_wait = GNUNET_YES; | 568 | pc->in_network_wait = GNUNET_YES; |
546 | dpc_cls = GNUNET_malloc(sizeof(struct PutContCtx)); | 569 | dpc_cls = GNUNET_malloc(sizeof(struct PutContCtx)); |
547 | dpc_cls->cont = &GNUNET_FS_publish_main_; | 570 | dpc_cls->cont = &GNUNET_FS_publish_main_; |
548 | dpc_cls->cont_cls = sc; | 571 | dpc_cls->cont_cls = pc; |
549 | dpc_cls->sc = sc; | 572 | dpc_cls->pc = pc; |
550 | dpc_cls->p = p; | 573 | dpc_cls->p = p; |
551 | if ( (! p->is_directory) && | 574 | if ( (! p->is_directory) && |
552 | (GNUNET_YES == p->data.file.do_index) && | 575 | (GNUNET_YES == p->data.file.do_index) && |
@@ -561,20 +584,21 @@ block_proc (void *cls, | |||
561 | #endif | 584 | #endif |
562 | odb.offset = GNUNET_htonll (offset); | 585 | odb.offset = GNUNET_htonll (offset); |
563 | odb.file_id = p->data.file.file_id; | 586 | odb.file_id = p->data.file.file_id; |
564 | GNUNET_DATASTORE_put (sc->dsh, | 587 | GNUNET_assert (pc->qre == NULL); |
565 | (p->is_directory) ? 0 : sc->rid, | 588 | pc->qre = GNUNET_DATASTORE_put (pc->dsh, |
566 | &chk->query, | 589 | (p->is_directory) ? 0 : pc->rid, |
567 | sizeof (struct OnDemandBlock), | 590 | &chk->query, |
568 | &odb, | 591 | sizeof (struct OnDemandBlock), |
569 | GNUNET_BLOCK_TYPE_FS_ONDEMAND, | 592 | &odb, |
570 | p->bo.content_priority, | 593 | GNUNET_BLOCK_TYPE_FS_ONDEMAND, |
571 | p->bo.anonymity_level, | 594 | p->bo.content_priority, |
572 | p->bo.replication_level, | 595 | p->bo.anonymity_level, |
573 | p->bo.expiration_time, | 596 | p->bo.replication_level, |
574 | -2, 1, | 597 | p->bo.expiration_time, |
575 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 598 | -2, 1, |
576 | &ds_put_cont, | 599 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
577 | dpc_cls); | 600 | &ds_put_cont, |
601 | dpc_cls); | ||
578 | return; | 602 | return; |
579 | } | 603 | } |
580 | #if DEBUG_PUBLISH | 604 | #if DEBUG_PUBLISH |
@@ -584,20 +608,21 @@ block_proc (void *cls, | |||
584 | (unsigned long long) offset, | 608 | (unsigned long long) offset, |
585 | (unsigned int) block_size); | 609 | (unsigned int) block_size); |
586 | #endif | 610 | #endif |
587 | GNUNET_DATASTORE_put (sc->dsh, | 611 | GNUNET_assert (pc->qre == NULL); |
588 | (p->is_directory) ? 0 : sc->rid, | 612 | pc->qre = GNUNET_DATASTORE_put (pc->dsh, |
589 | &chk->query, | 613 | (p->is_directory) ? 0 : pc->rid, |
590 | block_size, | 614 | &chk->query, |
591 | block, | 615 | block_size, |
592 | type, | 616 | block, |
593 | p->bo.content_priority, | 617 | type, |
594 | p->bo.anonymity_level, | 618 | p->bo.content_priority, |
595 | p->bo.replication_level, | 619 | p->bo.anonymity_level, |
596 | p->bo.expiration_time, | 620 | p->bo.replication_level, |
597 | -2, 1, | 621 | p->bo.expiration_time, |
598 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 622 | -2, 1, |
599 | &ds_put_cont, | 623 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
600 | dpc_cls); | 624 | &ds_put_cont, |
625 | dpc_cls); | ||
601 | } | 626 | } |
602 | 627 | ||
603 | 628 | ||
@@ -618,17 +643,17 @@ progress_proc (void *cls, | |||
618 | size_t pt_size, | 643 | size_t pt_size, |
619 | unsigned int depth) | 644 | unsigned int depth) |
620 | { | 645 | { |
621 | struct GNUNET_FS_PublishContext *sc = cls; | 646 | struct GNUNET_FS_PublishContext *pc = cls; |
622 | struct GNUNET_FS_FileInformation *p; | 647 | struct GNUNET_FS_FileInformation *p; |
623 | struct GNUNET_FS_ProgressInfo pi; | 648 | struct GNUNET_FS_ProgressInfo pi; |
624 | 649 | ||
625 | p = sc->fi_pos; | 650 | p = pc->fi_pos; |
626 | pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS; | 651 | pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS; |
627 | pi.value.publish.specifics.progress.data = pt_block; | 652 | pi.value.publish.specifics.progress.data = pt_block; |
628 | pi.value.publish.specifics.progress.offset = offset; | 653 | pi.value.publish.specifics.progress.offset = offset; |
629 | pi.value.publish.specifics.progress.data_len = pt_size; | 654 | pi.value.publish.specifics.progress.data_len = pt_size; |
630 | pi.value.publish.specifics.progress.depth = depth; | 655 | pi.value.publish.specifics.progress.depth = depth; |
631 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, offset); | 656 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, offset); |
632 | } | 657 | } |
633 | 658 | ||
634 | 659 | ||
@@ -637,10 +662,10 @@ progress_proc (void *cls, | |||
637 | * block into memory, encrypt it and send it to the FS service. Then | 662 | * block into memory, encrypt it and send it to the FS service. Then |
638 | * continue with the main task. | 663 | * continue with the main task. |
639 | * | 664 | * |
640 | * @param sc overall upload data | 665 | * @param pc overall upload data |
641 | */ | 666 | */ |
642 | static void | 667 | static void |
643 | publish_content (struct GNUNET_FS_PublishContext *sc) | 668 | publish_content (struct GNUNET_FS_PublishContext *pc) |
644 | { | 669 | { |
645 | struct GNUNET_FS_FileInformation *p; | 670 | struct GNUNET_FS_FileInformation *p; |
646 | char *emsg; | 671 | char *emsg; |
@@ -649,7 +674,7 @@ publish_content (struct GNUNET_FS_PublishContext *sc) | |||
649 | void *raw_data; | 674 | void *raw_data; |
650 | uint64_t size; | 675 | uint64_t size; |
651 | 676 | ||
652 | p = sc->fi_pos; | 677 | p = pc->fi_pos; |
653 | GNUNET_assert (p != NULL); | 678 | GNUNET_assert (p != NULL); |
654 | if (NULL == p->te) | 679 | if (NULL == p->te) |
655 | { | 680 | { |
@@ -708,9 +733,9 @@ publish_content (struct GNUNET_FS_PublishContext *sc) | |||
708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
709 | "Creating tree encoder\n"); | 734 | "Creating tree encoder\n"); |
710 | #endif | 735 | #endif |
711 | p->te = GNUNET_FS_tree_encoder_create (sc->h, | 736 | p->te = GNUNET_FS_tree_encoder_create (pc->h, |
712 | size, | 737 | size, |
713 | sc, | 738 | pc, |
714 | &block_reader, | 739 | &block_reader, |
715 | &block_proc, | 740 | &block_proc, |
716 | &progress_proc, | 741 | &progress_proc, |
@@ -736,14 +761,14 @@ static void | |||
736 | process_index_start_response (void *cls, | 761 | process_index_start_response (void *cls, |
737 | const struct GNUNET_MessageHeader *msg) | 762 | const struct GNUNET_MessageHeader *msg) |
738 | { | 763 | { |
739 | struct GNUNET_FS_PublishContext *sc = cls; | 764 | struct GNUNET_FS_PublishContext *pc = cls; |
740 | struct GNUNET_FS_FileInformation *p; | 765 | struct GNUNET_FS_FileInformation *p; |
741 | const char *emsg; | 766 | const char *emsg; |
742 | uint16_t msize; | 767 | uint16_t msize; |
743 | 768 | ||
744 | GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); | 769 | GNUNET_CLIENT_disconnect (pc->client, GNUNET_NO); |
745 | sc->client = NULL; | 770 | pc->client = NULL; |
746 | p = sc->fi_pos; | 771 | p = pc->fi_pos; |
747 | if (msg == NULL) | 772 | if (msg == NULL) |
748 | { | 773 | { |
749 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 774 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -752,7 +777,7 @@ process_index_start_response (void *cls, | |||
752 | _("timeout on index-start request to `fs' service")); | 777 | _("timeout on index-start request to `fs' service")); |
753 | p->data.file.do_index = GNUNET_NO; | 778 | p->data.file.do_index = GNUNET_NO; |
754 | GNUNET_FS_file_information_sync_ (p); | 779 | GNUNET_FS_file_information_sync_ (p); |
755 | publish_content (sc); | 780 | publish_content (pc); |
756 | return; | 781 | return; |
757 | } | 782 | } |
758 | if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK) | 783 | if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK) |
@@ -768,13 +793,13 @@ process_index_start_response (void *cls, | |||
768 | gettext (emsg)); | 793 | gettext (emsg)); |
769 | p->data.file.do_index = GNUNET_NO; | 794 | p->data.file.do_index = GNUNET_NO; |
770 | GNUNET_FS_file_information_sync_ (p); | 795 | GNUNET_FS_file_information_sync_ (p); |
771 | publish_content (sc); | 796 | publish_content (pc); |
772 | return; | 797 | return; |
773 | } | 798 | } |
774 | p->data.file.index_start_confirmed = GNUNET_YES; | 799 | p->data.file.index_start_confirmed = GNUNET_YES; |
775 | /* success! continue with indexing */ | 800 | /* success! continue with indexing */ |
776 | GNUNET_FS_file_information_sync_ (p); | 801 | GNUNET_FS_file_information_sync_ (p); |
777 | publish_content (sc); | 802 | publish_content (pc); |
778 | } | 803 | } |
779 | 804 | ||
780 | 805 | ||
@@ -790,7 +815,7 @@ hash_for_index_cb (void *cls, | |||
790 | const GNUNET_HashCode * | 815 | const GNUNET_HashCode * |
791 | res) | 816 | res) |
792 | { | 817 | { |
793 | struct GNUNET_FS_PublishContext *sc = cls; | 818 | struct GNUNET_FS_PublishContext *pc = cls; |
794 | struct GNUNET_FS_FileInformation *p; | 819 | struct GNUNET_FS_FileInformation *p; |
795 | struct IndexStartMessage *ism; | 820 | struct IndexStartMessage *ism; |
796 | size_t slen; | 821 | size_t slen; |
@@ -799,8 +824,8 @@ hash_for_index_cb (void *cls, | |||
799 | uint64_t ino; | 824 | uint64_t ino; |
800 | char *fn; | 825 | char *fn; |
801 | 826 | ||
802 | sc->fhc = NULL; | 827 | pc->fhc = NULL; |
803 | p = sc->fi_pos; | 828 | p = pc->fi_pos; |
804 | if (NULL == res) | 829 | if (NULL == res) |
805 | { | 830 | { |
806 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 831 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -809,12 +834,12 @@ hash_for_index_cb (void *cls, | |||
809 | _("failed to compute hash")); | 834 | _("failed to compute hash")); |
810 | p->data.file.do_index = GNUNET_NO; | 835 | p->data.file.do_index = GNUNET_NO; |
811 | GNUNET_FS_file_information_sync_ (p); | 836 | GNUNET_FS_file_information_sync_ (p); |
812 | publish_content (sc); | 837 | publish_content (pc); |
813 | return; | 838 | return; |
814 | } | 839 | } |
815 | if (GNUNET_YES == p->data.file.index_start_confirmed) | 840 | if (GNUNET_YES == p->data.file.index_start_confirmed) |
816 | { | 841 | { |
817 | publish_content (sc); | 842 | publish_content (pc); |
818 | return; | 843 | return; |
819 | } | 844 | } |
820 | fn = GNUNET_STRINGS_filename_expand (p->filename); | 845 | fn = GNUNET_STRINGS_filename_expand (p->filename); |
@@ -829,7 +854,7 @@ hash_for_index_cb (void *cls, | |||
829 | GNUNET_free (fn); | 854 | GNUNET_free (fn); |
830 | p->data.file.do_index = GNUNET_NO; | 855 | p->data.file.do_index = GNUNET_NO; |
831 | GNUNET_FS_file_information_sync_ (p); | 856 | GNUNET_FS_file_information_sync_ (p); |
832 | publish_content (sc); | 857 | publish_content (pc); |
833 | return; | 858 | return; |
834 | } | 859 | } |
835 | #if DEBUG_PUBLISH | 860 | #if DEBUG_PUBLISH |
@@ -838,18 +863,18 @@ hash_for_index_cb (void *cls, | |||
838 | p->filename, | 863 | p->filename, |
839 | GNUNET_h2s (res)); | 864 | GNUNET_h2s (res)); |
840 | #endif | 865 | #endif |
841 | if (0 != (sc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) | 866 | if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) |
842 | { | 867 | { |
843 | p->data.file.file_id = *res; | 868 | p->data.file.file_id = *res; |
844 | p->data.file.have_hash = GNUNET_YES; | 869 | p->data.file.have_hash = GNUNET_YES; |
845 | p->data.file.index_start_confirmed = GNUNET_YES; | 870 | p->data.file.index_start_confirmed = GNUNET_YES; |
846 | GNUNET_FS_file_information_sync_ (p); | 871 | GNUNET_FS_file_information_sync_ (p); |
847 | publish_content (sc); | 872 | publish_content (pc); |
848 | GNUNET_free (fn); | 873 | GNUNET_free (fn); |
849 | return; | 874 | return; |
850 | } | 875 | } |
851 | client = GNUNET_CLIENT_connect ("fs", | 876 | client = GNUNET_CLIENT_connect ("fs", |
852 | sc->h->cfg); | 877 | pc->h->cfg); |
853 | if (NULL == client) | 878 | if (NULL == client) |
854 | { | 879 | { |
855 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 880 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -857,7 +882,7 @@ hash_for_index_cb (void *cls, | |||
857 | p->filename, | 882 | p->filename, |
858 | _("could not connect to `fs' service")); | 883 | _("could not connect to `fs' service")); |
859 | p->data.file.do_index = GNUNET_NO; | 884 | p->data.file.do_index = GNUNET_NO; |
860 | publish_content (sc); | 885 | publish_content (pc); |
861 | GNUNET_free (fn); | 886 | GNUNET_free (fn); |
862 | return; | 887 | return; |
863 | } | 888 | } |
@@ -893,14 +918,14 @@ hash_for_index_cb (void *cls, | |||
893 | fn, | 918 | fn, |
894 | slen); | 919 | slen); |
895 | GNUNET_free (fn); | 920 | GNUNET_free (fn); |
896 | sc->client = client; | 921 | pc->client = client; |
897 | GNUNET_break (GNUNET_YES == | 922 | GNUNET_break (GNUNET_YES == |
898 | GNUNET_CLIENT_transmit_and_get_response (client, | 923 | GNUNET_CLIENT_transmit_and_get_response (client, |
899 | &ism->header, | 924 | &ism->header, |
900 | GNUNET_TIME_UNIT_FOREVER_REL, | 925 | GNUNET_TIME_UNIT_FOREVER_REL, |
901 | GNUNET_YES, | 926 | GNUNET_YES, |
902 | &process_index_start_response, | 927 | &process_index_start_response, |
903 | sc)); | 928 | pc)); |
904 | GNUNET_free (ism); | 929 | GNUNET_free (ism); |
905 | } | 930 | } |
906 | 931 | ||
@@ -1078,42 +1103,46 @@ fip_signal_start(void *cls, | |||
1078 | int *do_index, | 1103 | int *do_index, |
1079 | void **client_info) | 1104 | void **client_info) |
1080 | { | 1105 | { |
1081 | struct GNUNET_FS_PublishContext *sc = cls; | 1106 | struct GNUNET_FS_PublishContext *pc = cls; |
1082 | struct GNUNET_FS_ProgressInfo pi; | 1107 | struct GNUNET_FS_ProgressInfo pi; |
1083 | unsigned int kc; | 1108 | unsigned int kc; |
1084 | uint64_t left; | 1109 | uint64_t left; |
1085 | 1110 | ||
1111 | #if DEBUG_PUBLISH | ||
1112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1113 | "Starting publish operation\n"); | ||
1114 | #endif | ||
1086 | if (*do_index) | 1115 | if (*do_index) |
1087 | { | 1116 | { |
1088 | /* space for on-demand blocks */ | 1117 | /* space for on-demand blocks */ |
1089 | sc->reserve_space += ((length + DBLOCK_SIZE - 1) / DBLOCK_SIZE) * sizeof (struct OnDemandBlock); | 1118 | pc->reserve_space += ((length + DBLOCK_SIZE - 1) / DBLOCK_SIZE) * sizeof (struct OnDemandBlock); |
1090 | } | 1119 | } |
1091 | else | 1120 | else |
1092 | { | 1121 | { |
1093 | /* space for DBlocks */ | 1122 | /* space for DBlocks */ |
1094 | sc->reserve_space += length; | 1123 | pc->reserve_space += length; |
1095 | } | 1124 | } |
1096 | /* entries for IBlocks and DBlocks, space for IBlocks */ | 1125 | /* entries for IBlocks and DBlocks, space for IBlocks */ |
1097 | left = length; | 1126 | left = length; |
1098 | while (1) | 1127 | while (1) |
1099 | { | 1128 | { |
1100 | left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE; | 1129 | left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE; |
1101 | sc->reserve_entries += left; | 1130 | pc->reserve_entries += left; |
1102 | if (left <= 1) | 1131 | if (left <= 1) |
1103 | break; | 1132 | break; |
1104 | left = left * sizeof (struct ContentHashKey); | 1133 | left = left * sizeof (struct ContentHashKey); |
1105 | sc->reserve_space += left; | 1134 | pc->reserve_space += left; |
1106 | } | 1135 | } |
1107 | sc->reserve_entries++; | 1136 | pc->reserve_entries++; |
1108 | /* entries and space for keywords */ | 1137 | /* entries and space for keywords */ |
1109 | if (NULL != *uri) | 1138 | if (NULL != *uri) |
1110 | { | 1139 | { |
1111 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); | 1140 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); |
1112 | sc->reserve_entries += kc; | 1141 | pc->reserve_entries += kc; |
1113 | sc->reserve_space += GNUNET_SERVER_MAX_MESSAGE_SIZE * kc; | 1142 | pc->reserve_space += GNUNET_SERVER_MAX_MESSAGE_SIZE * kc; |
1114 | } | 1143 | } |
1115 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; | 1144 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; |
1116 | *client_info = GNUNET_FS_publish_make_status_ (&pi, sc, fi, 0); | 1145 | *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0); |
1117 | GNUNET_FS_file_information_sync_ (fi); | 1146 | GNUNET_FS_file_information_sync_ (fi); |
1118 | return GNUNET_OK; | 1147 | return GNUNET_OK; |
1119 | } | 1148 | } |
@@ -1143,21 +1172,31 @@ fip_signal_suspend(void *cls, | |||
1143 | int *do_index, | 1172 | int *do_index, |
1144 | void **client_info) | 1173 | void **client_info) |
1145 | { | 1174 | { |
1146 | struct GNUNET_FS_PublishContext*sc = cls; | 1175 | struct GNUNET_FS_PublishContext*pc = cls; |
1147 | struct GNUNET_FS_ProgressInfo pi; | 1176 | struct GNUNET_FS_ProgressInfo pi; |
1148 | uint64_t off; | 1177 | uint64_t off; |
1149 | 1178 | ||
1179 | #if DEBUG_PUBLISH | ||
1180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1181 | "Suspending publish operation\n"); | ||
1182 | #endif | ||
1150 | GNUNET_free_non_null (fi->serialization); | 1183 | GNUNET_free_non_null (fi->serialization); |
1151 | fi->serialization = NULL; | 1184 | fi->serialization = NULL; |
1152 | off = (fi->chk_uri == NULL) ? 0 : length; | 1185 | off = (fi->chk_uri == NULL) ? 0 : length; |
1153 | pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; | 1186 | pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; |
1154 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, sc, fi, off)); | 1187 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off)); |
1155 | *client_info = NULL; | 1188 | *client_info = NULL; |
1156 | if (NULL != sc->dsh) | 1189 | if (NULL != pc->qre) |
1157 | { | 1190 | { |
1158 | GNUNET_DATASTORE_disconnect (sc->dsh, GNUNET_NO); | 1191 | GNUNET_DATASTORE_cancel (pc->qre); |
1159 | sc->dsh = NULL; | 1192 | pc->qre = NULL; |
1193 | } | ||
1194 | if (NULL != pc->dsh) | ||
1195 | { | ||
1196 | GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO); | ||
1197 | pc->dsh = NULL; | ||
1160 | } | 1198 | } |
1199 | pc->rid = 0; | ||
1161 | return GNUNET_OK; | 1200 | return GNUNET_OK; |
1162 | } | 1201 | } |
1163 | 1202 | ||
@@ -1182,6 +1221,7 @@ GNUNET_FS_publish_signal_suspend_ (void *cls) | |||
1182 | &fip_signal_suspend, | 1221 | &fip_signal_suspend, |
1183 | pc); | 1222 | pc); |
1184 | GNUNET_FS_end_top (pc->h, pc->top); | 1223 | GNUNET_FS_end_top (pc->h, pc->top); |
1224 | pc->top = NULL; | ||
1185 | publish_cleanup (pc, NULL); | 1225 | publish_cleanup (pc, NULL); |
1186 | } | 1226 | } |
1187 | 1227 | ||
@@ -1202,6 +1242,11 @@ finish_reserve (void *cls, | |||
1202 | struct GNUNET_FS_PublishContext *pc = cls; | 1242 | struct GNUNET_FS_PublishContext *pc = cls; |
1203 | 1243 | ||
1204 | pc->qre = NULL; | 1244 | pc->qre = NULL; |
1245 | #if DEBUG_PUBLISH | ||
1246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1247 | "Reservation complete (%d)!\n", | ||
1248 | success); | ||
1249 | #endif | ||
1205 | if ( (msg != NULL) || | 1250 | if ( (msg != NULL) || |
1206 | (success <= 0) ) | 1251 | (success <= 0) ) |
1207 | { | 1252 | { |
@@ -1214,6 +1259,7 @@ finish_reserve (void *cls, | |||
1214 | return; | 1259 | return; |
1215 | } | 1260 | } |
1216 | pc->rid = success; | 1261 | pc->rid = success; |
1262 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); | ||
1217 | pc->upload_task | 1263 | pc->upload_task |
1218 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 1264 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
1219 | &GNUNET_FS_publish_main_, | 1265 | &GNUNET_FS_publish_main_, |
@@ -1279,6 +1325,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | |||
1279 | GNUNET_FS_publish_sync_ (ret); | 1325 | GNUNET_FS_publish_sync_ (ret); |
1280 | if (NULL != ret->dsh) | 1326 | if (NULL != ret->dsh) |
1281 | { | 1327 | { |
1328 | GNUNET_assert (NULL == ret->qre); | ||
1282 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1329 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1283 | _("Reserving space for %u entries and %llu bytes for publication\n"), | 1330 | _("Reserving space for %u entries and %llu bytes for publication\n"), |
1284 | (unsigned int) ret->reserve_entries, | 1331 | (unsigned int) ret->reserve_entries, |
@@ -1294,6 +1341,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | |||
1294 | } | 1341 | } |
1295 | else | 1342 | else |
1296 | { | 1343 | { |
1344 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ret->upload_task); | ||
1297 | ret->upload_task | 1345 | ret->upload_task |
1298 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 1346 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
1299 | &GNUNET_FS_publish_main_, | 1347 | &GNUNET_FS_publish_main_, |
@@ -1327,13 +1375,13 @@ fip_signal_stop(void *cls, | |||
1327 | int *do_index, | 1375 | int *do_index, |
1328 | void **client_info) | 1376 | void **client_info) |
1329 | { | 1377 | { |
1330 | struct GNUNET_FS_PublishContext*sc = cls; | 1378 | struct GNUNET_FS_PublishContext*pc = cls; |
1331 | struct GNUNET_FS_ProgressInfo pi; | 1379 | struct GNUNET_FS_ProgressInfo pi; |
1332 | uint64_t off; | 1380 | uint64_t off; |
1333 | 1381 | ||
1334 | if (fi->serialization != NULL) | 1382 | if (fi->serialization != NULL) |
1335 | { | 1383 | { |
1336 | GNUNET_FS_remove_sync_file_ (sc->h, | 1384 | GNUNET_FS_remove_sync_file_ (pc->h, |
1337 | GNUNET_FS_SYNC_PATH_FILE_INFO, | 1385 | GNUNET_FS_SYNC_PATH_FILE_INFO, |
1338 | fi->serialization); | 1386 | fi->serialization); |
1339 | GNUNET_free (fi->serialization); | 1387 | GNUNET_free (fi->serialization); |
@@ -1341,7 +1389,7 @@ fip_signal_stop(void *cls, | |||
1341 | } | 1389 | } |
1342 | off = (fi->chk_uri == NULL) ? 0 : length; | 1390 | off = (fi->chk_uri == NULL) ? 0 : length; |
1343 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; | 1391 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; |
1344 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, sc, fi, off)); | 1392 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off)); |
1345 | *client_info = NULL; | 1393 | *client_info = NULL; |
1346 | return GNUNET_OK; | 1394 | return GNUNET_OK; |
1347 | } | 1395 | } |
@@ -1358,6 +1406,10 @@ fip_signal_stop(void *cls, | |||
1358 | void | 1406 | void |
1359 | GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) | 1407 | GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) |
1360 | { | 1408 | { |
1409 | #if DEBUG_PUBLISH | ||
1410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1411 | "Publish stop called\n"); | ||
1412 | #endif | ||
1361 | GNUNET_FS_end_top (pc->h, pc->top); | 1413 | GNUNET_FS_end_top (pc->h, pc->top); |
1362 | if (NULL != pc->qre) | 1414 | if (NULL != pc->qre) |
1363 | { | 1415 | { |
@@ -1428,6 +1480,11 @@ struct PublishKskContext | |||
1428 | struct GNUNET_DATASTORE_Handle *dsh; | 1480 | struct GNUNET_DATASTORE_Handle *dsh; |
1429 | 1481 | ||
1430 | /** | 1482 | /** |
1483 | * Handle to datastore PUT request. | ||
1484 | */ | ||
1485 | struct GNUNET_DATASTORE_QueueEntry *qre; | ||
1486 | |||
1487 | /** | ||
1431 | * Function to call once we're done. | 1488 | * Function to call once we're done. |
1432 | */ | 1489 | */ |
1433 | GNUNET_FS_PublishContinuation cont; | 1490 | GNUNET_FS_PublishContinuation cont; |
@@ -1488,8 +1545,13 @@ kb_put_cont (void *cls, | |||
1488 | { | 1545 | { |
1489 | struct PublishKskContext *pkc = cls; | 1546 | struct PublishKskContext *pkc = cls; |
1490 | 1547 | ||
1548 | pkc->qre = NULL; | ||
1491 | if (GNUNET_OK != success) | 1549 | if (GNUNET_OK != success) |
1492 | { | 1550 | { |
1551 | #if DEBUG_PUBLISH | ||
1552 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1553 | "KB PUT operation complete\n"); | ||
1554 | #endif | ||
1493 | if (NULL != pkc->dsh) | 1555 | if (NULL != pkc->dsh) |
1494 | { | 1556 | { |
1495 | GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); | 1557 | GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); |
@@ -1533,6 +1595,10 @@ publish_ksk_cont (void *cls, | |||
1533 | if ( (pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || | 1595 | if ( (pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || |
1534 | (NULL == pkc->dsh) ) | 1596 | (NULL == pkc->dsh) ) |
1535 | { | 1597 | { |
1598 | #if DEBUG_PUBLISH | ||
1599 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1600 | "KSK PUT operation complete\n"); | ||
1601 | #endif | ||
1536 | if (NULL != pkc->dsh) | 1602 | if (NULL != pkc->dsh) |
1537 | { | 1603 | { |
1538 | GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); | 1604 | GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); |
@@ -1573,22 +1639,22 @@ publish_ksk_cont (void *cls, | |||
1573 | &pkc->cpy->purpose, | 1639 | &pkc->cpy->purpose, |
1574 | &pkc->cpy->signature)); | 1640 | &pkc->cpy->signature)); |
1575 | GNUNET_CRYPTO_rsa_key_free (pk); | 1641 | GNUNET_CRYPTO_rsa_key_free (pk); |
1576 | GNUNET_DATASTORE_put (pkc->dsh, | 1642 | pkc->qre = GNUNET_DATASTORE_put (pkc->dsh, |
1577 | 0, | 1643 | 0, |
1578 | &query, | 1644 | &query, |
1579 | pkc->mdsize + | 1645 | pkc->mdsize + |
1580 | sizeof (struct KBlock) + | 1646 | sizeof (struct KBlock) + |
1581 | pkc->slen, | 1647 | pkc->slen, |
1582 | pkc->cpy, | 1648 | pkc->cpy, |
1583 | GNUNET_BLOCK_TYPE_FS_KBLOCK, | 1649 | GNUNET_BLOCK_TYPE_FS_KBLOCK, |
1584 | pkc->bo.content_priority, | 1650 | pkc->bo.content_priority, |
1585 | pkc->bo.anonymity_level, | 1651 | pkc->bo.anonymity_level, |
1586 | pkc->bo.replication_level, | 1652 | pkc->bo.replication_level, |
1587 | pkc->bo.expiration_time, | 1653 | pkc->bo.expiration_time, |
1588 | -2, 1, | 1654 | -2, 1, |
1589 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1655 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
1590 | &kb_put_cont, | 1656 | &kb_put_cont, |
1591 | pkc); | 1657 | pkc); |
1592 | } | 1658 | } |
1593 | 1659 | ||
1594 | 1660 | ||
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index fdb5beb7d..e06d5c18f 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c | |||
@@ -147,9 +147,8 @@ progress_cb (void *cls, | |||
147 | (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); | 147 | (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024)); |
148 | if (0 == strcmp ("publish-context-dir", | 148 | if (0 == strcmp ("publish-context-dir", |
149 | event->value.publish.cctx)) | 149 | event->value.publish.cctx)) |
150 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, | 150 | GNUNET_SCHEDULER_add_now (&abort_publish_task, |
151 | NULL, | 151 | NULL); |
152 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
153 | break; | 152 | break; |
154 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 153 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
155 | consider_restart (event->status); | 154 | consider_restart (event->status); |
@@ -180,11 +179,8 @@ progress_cb (void *cls, | |||
180 | "Error publishing file: %s\n", | 179 | "Error publishing file: %s\n", |
181 | event->value.publish.specifics.error.message); | 180 | event->value.publish.specifics.error.message); |
182 | err = 1; | 181 | err = 1; |
183 | if (0 == strcmp ("publish-context-dir", | 182 | GNUNET_SCHEDULER_add_now (&abort_publish_task, |
184 | event->value.publish.cctx)) | 183 | NULL); |
185 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, | ||
186 | NULL, | ||
187 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
188 | break; | 184 | break; |
189 | case GNUNET_FS_STATUS_PUBLISH_START: | 185 | case GNUNET_FS_STATUS_PUBLISH_START: |
190 | consider_restart (event->status); | 186 | consider_restart (event->status); |