diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/fs/fs_publish.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r-- | src/fs/fs_publish.c | 1659 |
1 files changed, 828 insertions, 831 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 71ab1122c..b599bb06e 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file fs/fs_publish.c | 21 | * @file fs/fs_publish.c |
22 | * @brief publish a file or directory in GNUnet | 22 | * @brief publish a file or directory in GNUnet |
@@ -44,10 +44,10 @@ | |||
44 | * @return value returned from callback | 44 | * @return value returned from callback |
45 | */ | 45 | */ |
46 | void * | 46 | void * |
47 | GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | 47 | GNUNET_FS_publish_make_status_(struct GNUNET_FS_ProgressInfo *pi, |
48 | struct GNUNET_FS_PublishContext *pc, | 48 | struct GNUNET_FS_PublishContext *pc, |
49 | const struct GNUNET_FS_FileInformation *p, | 49 | const struct GNUNET_FS_FileInformation *p, |
50 | uint64_t offset) | 50 | uint64_t offset) |
51 | { | 51 | { |
52 | pi->value.publish.pc = pc; | 52 | pi->value.publish.pc = pc; |
53 | pi->value.publish.fi = p; | 53 | pi->value.publish.fi = p; |
@@ -55,16 +55,16 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
55 | pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; | 55 | pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; |
56 | pi->value.publish.filename = p->filename; | 56 | pi->value.publish.filename = p->filename; |
57 | pi->value.publish.size = | 57 | pi->value.publish.size = |
58 | (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; | 58 | (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; |
59 | pi->value.publish.eta = | 59 | pi->value.publish.eta = |
60 | GNUNET_TIME_calculate_eta (p->start_time, offset, | 60 | GNUNET_TIME_calculate_eta(p->start_time, offset, |
61 | pi->value.publish.size); | 61 | pi->value.publish.size); |
62 | pi->value.publish.completed = offset; | 62 | pi->value.publish.completed = offset; |
63 | pi->value.publish.duration = | 63 | pi->value.publish.duration = |
64 | GNUNET_TIME_absolute_get_duration (p->start_time); | 64 | GNUNET_TIME_absolute_get_duration(p->start_time); |
65 | pi->value.publish.anonymity = p->bo.anonymity_level; | 65 | pi->value.publish.anonymity = p->bo.anonymity_level; |
66 | pi->fsh = pc->h; | 66 | pi->fsh = pc->h; |
67 | return pc->h->upcb (pc->h->upcb_cls, pi); | 67 | return pc->h->upcb(pc->h->upcb_cls, pi); |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
@@ -74,31 +74,31 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
74 | * @param pc struct to clean up | 74 | * @param pc struct to clean up |
75 | */ | 75 | */ |
76 | static void | 76 | static void |
77 | publish_cleanup (struct GNUNET_FS_PublishContext *pc) | 77 | publish_cleanup(struct GNUNET_FS_PublishContext *pc) |
78 | { | 78 | { |
79 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 79 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
80 | "Cleaning up publish context (done!)\n"); | 80 | "Cleaning up publish context (done!)\n"); |
81 | if (NULL != pc->fhc) | 81 | if (NULL != pc->fhc) |
82 | { | 82 | { |
83 | GNUNET_CRYPTO_hash_file_cancel (pc->fhc); | 83 | GNUNET_CRYPTO_hash_file_cancel(pc->fhc); |
84 | pc->fhc = NULL; | 84 | pc->fhc = NULL; |
85 | } | 85 | } |
86 | GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); | 86 | GNUNET_FS_file_information_destroy(pc->fi, NULL, NULL); |
87 | GNUNET_free_non_null (pc->nid); | 87 | GNUNET_free_non_null(pc->nid); |
88 | GNUNET_free_non_null (pc->nuid); | 88 | GNUNET_free_non_null(pc->nuid); |
89 | GNUNET_free_non_null (pc->serialization); | 89 | GNUNET_free_non_null(pc->serialization); |
90 | if (NULL != pc->dsh) | 90 | if (NULL != pc->dsh) |
91 | { | 91 | { |
92 | GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO); | 92 | GNUNET_DATASTORE_disconnect(pc->dsh, GNUNET_NO); |
93 | pc->dsh = NULL; | 93 | pc->dsh = NULL; |
94 | } | 94 | } |
95 | if (NULL != pc->mq) | 95 | if (NULL != pc->mq) |
96 | { | 96 | { |
97 | GNUNET_MQ_destroy (pc->mq); | 97 | GNUNET_MQ_destroy(pc->mq); |
98 | pc->mq = NULL; | 98 | pc->mq = NULL; |
99 | } | 99 | } |
100 | GNUNET_assert (NULL == pc->upload_task); | 100 | GNUNET_assert(NULL == pc->upload_task); |
101 | GNUNET_free (pc); | 101 | GNUNET_free(pc); |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
@@ -112,42 +112,42 @@ publish_cleanup (struct GNUNET_FS_PublishContext *pc) | |||
112 | * @param msg error message (or NULL) | 112 | * @param msg error message (or NULL) |
113 | */ | 113 | */ |
114 | static void | 114 | static void |
115 | ds_put_cont (void *cls, | 115 | ds_put_cont(void *cls, |
116 | int success, | 116 | int success, |
117 | struct GNUNET_TIME_Absolute min_expiration, | 117 | struct GNUNET_TIME_Absolute min_expiration, |
118 | const char *msg) | 118 | const char *msg) |
119 | { | 119 | { |
120 | struct GNUNET_FS_PublishContext *pc = cls; | 120 | struct GNUNET_FS_PublishContext *pc = cls; |
121 | struct GNUNET_FS_ProgressInfo pi; | 121 | struct GNUNET_FS_ProgressInfo pi; |
122 | 122 | ||
123 | pc->qre = NULL; | 123 | pc->qre = NULL; |
124 | if (GNUNET_SYSERR == success) | 124 | if (GNUNET_SYSERR == success) |
125 | { | ||
126 | GNUNET_asprintf (&pc->fi_pos->emsg, | ||
127 | _("Publishing failed: %s"), | ||
128 | msg); | ||
129 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | ||
130 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | ||
131 | pi.value.publish.specifics.error.message = pc->fi_pos->emsg; | ||
132 | pc->fi_pos->client_info = | ||
133 | GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0); | ||
134 | if ((GNUNET_YES != pc->fi_pos->is_directory) && | ||
135 | (NULL != pc->fi_pos->filename) && | ||
136 | (GNUNET_YES == pc->any_done) && | ||
137 | (GNUNET_YES == pc->fi_pos->data.file.do_index)) | ||
138 | { | 125 | { |
139 | /* run unindex to clean up */ | 126 | GNUNET_asprintf(&pc->fi_pos->emsg, |
140 | GNUNET_FS_unindex_start (pc->h, | 127 | _("Publishing failed: %s"), |
141 | pc->fi_pos->filename, | 128 | msg); |
142 | NULL); | 129 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
130 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | ||
131 | pi.value.publish.specifics.error.message = pc->fi_pos->emsg; | ||
132 | pc->fi_pos->client_info = | ||
133 | GNUNET_FS_publish_make_status_(&pi, pc, pc->fi_pos, 0); | ||
134 | if ((GNUNET_YES != pc->fi_pos->is_directory) && | ||
135 | (NULL != pc->fi_pos->filename) && | ||
136 | (GNUNET_YES == pc->any_done) && | ||
137 | (GNUNET_YES == pc->fi_pos->data.file.do_index)) | ||
138 | { | ||
139 | /* run unindex to clean up */ | ||
140 | GNUNET_FS_unindex_start(pc->h, | ||
141 | pc->fi_pos->filename, | ||
142 | NULL); | ||
143 | } | ||
144 | return; | ||
143 | } | 145 | } |
144 | return; | ||
145 | } | ||
146 | pc->any_done = GNUNET_YES; | 146 | pc->any_done = GNUNET_YES; |
147 | GNUNET_assert (NULL == pc->upload_task); | 147 | GNUNET_assert(NULL == pc->upload_task); |
148 | pc->upload_task = | 148 | pc->upload_task = |
149 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 149 | GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
150 | &GNUNET_FS_publish_main_, pc); | 150 | &GNUNET_FS_publish_main_, pc); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
@@ -160,8 +160,8 @@ ds_put_cont (void *cls, | |||
160 | * @param pc context of the publication | 160 | * @param pc context of the publication |
161 | */ | 161 | */ |
162 | static void | 162 | static void |
163 | signal_publish_completion (struct GNUNET_FS_FileInformation *p, | 163 | signal_publish_completion(struct GNUNET_FS_FileInformation *p, |
164 | struct GNUNET_FS_PublishContext *pc) | 164 | struct GNUNET_FS_PublishContext *pc) |
165 | { | 165 | { |
166 | struct GNUNET_FS_ProgressInfo pi; | 166 | struct GNUNET_FS_ProgressInfo pi; |
167 | 167 | ||
@@ -170,8 +170,8 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, | |||
170 | pi.value.publish.specifics.completed.chk_uri = p->chk_uri; | 170 | pi.value.publish.specifics.completed.chk_uri = p->chk_uri; |
171 | pi.value.publish.specifics.completed.sks_uri = p->sks_uri; | 171 | pi.value.publish.specifics.completed.sks_uri = p->sks_uri; |
172 | p->client_info = | 172 | p->client_info = |
173 | GNUNET_FS_publish_make_status_ (&pi, pc, p, | 173 | GNUNET_FS_publish_make_status_(&pi, pc, p, |
174 | p->data.file.file_size); | 174 | p->data.file.file_size); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
@@ -185,28 +185,27 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, | |||
185 | * @param emsg error message | 185 | * @param emsg error message |
186 | */ | 186 | */ |
187 | static void | 187 | static void |
188 | signal_publish_error (struct GNUNET_FS_FileInformation *p, | 188 | signal_publish_error(struct GNUNET_FS_FileInformation *p, |
189 | struct GNUNET_FS_PublishContext *pc, | 189 | struct GNUNET_FS_PublishContext *pc, |
190 | const char *emsg) | 190 | const char *emsg) |
191 | { | 191 | { |
192 | struct GNUNET_FS_ProgressInfo pi; | 192 | struct GNUNET_FS_ProgressInfo pi; |
193 | 193 | ||
194 | p->emsg = GNUNET_strdup (emsg); | 194 | p->emsg = GNUNET_strdup(emsg); |
195 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | 195 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
196 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 196 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
197 | pi.value.publish.specifics.error.message = emsg; | 197 | pi.value.publish.specifics.error.message = emsg; |
198 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); | 198 | p->client_info = GNUNET_FS_publish_make_status_(&pi, pc, p, 0); |
199 | if ((p->is_directory != GNUNET_YES) && | 199 | if ((p->is_directory != GNUNET_YES) && |
200 | (NULL != p->filename) && | 200 | (NULL != p->filename) && |
201 | (GNUNET_YES == pc->any_done) && | 201 | (GNUNET_YES == pc->any_done) && |
202 | (p->data.file.do_index == GNUNET_YES)) | 202 | (p->data.file.do_index == GNUNET_YES)) |
203 | { | 203 | { |
204 | /* run unindex to clean up */ | 204 | /* run unindex to clean up */ |
205 | GNUNET_FS_unindex_start (pc->h, | 205 | GNUNET_FS_unindex_start(pc->h, |
206 | p->filename, | 206 | p->filename, |
207 | NULL); | 207 | NULL); |
208 | } | 208 | } |
209 | |||
210 | } | 209 | } |
211 | 210 | ||
212 | 211 | ||
@@ -219,18 +218,18 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p, | |||
219 | * @param msg error message (typically NULL, not used) | 218 | * @param msg error message (typically NULL, not used) |
220 | */ | 219 | */ |
221 | static void | 220 | static void |
222 | finish_release_reserve (void *cls, int success, | 221 | finish_release_reserve(void *cls, int success, |
223 | struct GNUNET_TIME_Absolute min_expiration, | 222 | struct GNUNET_TIME_Absolute min_expiration, |
224 | const char *msg) | 223 | const char *msg) |
225 | { | 224 | { |
226 | struct GNUNET_FS_PublishContext *pc = cls; | 225 | struct GNUNET_FS_PublishContext *pc = cls; |
227 | 226 | ||
228 | pc->qre = NULL; | 227 | pc->qre = NULL; |
229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 228 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
230 | "Releasing reserve done!\n"); | 229 | "Releasing reserve done!\n"); |
231 | signal_publish_completion (pc->fi, pc); | 230 | signal_publish_completion(pc->fi, pc); |
232 | pc->all_done = GNUNET_YES; | 231 | pc->all_done = GNUNET_YES; |
233 | GNUNET_FS_publish_sync_ (pc); | 232 | GNUNET_FS_publish_sync_(pc); |
234 | } | 233 | } |
235 | 234 | ||
236 | 235 | ||
@@ -243,35 +242,35 @@ finish_release_reserve (void *cls, int success, | |||
243 | * @param emsg NULL on success, otherwise error message | 242 | * @param emsg NULL on success, otherwise error message |
244 | */ | 243 | */ |
245 | static void | 244 | static void |
246 | publish_sblocks_cont (void *cls, | 245 | publish_sblocks_cont(void *cls, |
247 | const struct GNUNET_FS_Uri *uri, | 246 | const struct GNUNET_FS_Uri *uri, |
248 | const char *emsg) | 247 | const char *emsg) |
249 | { | 248 | { |
250 | struct GNUNET_FS_PublishContext *pc = cls; | 249 | struct GNUNET_FS_PublishContext *pc = cls; |
251 | 250 | ||
252 | pc->sks_pc = NULL; | 251 | pc->sks_pc = NULL; |
253 | if (NULL != emsg) | 252 | if (NULL != emsg) |
254 | { | 253 | { |
255 | signal_publish_error (pc->fi, pc, emsg); | 254 | signal_publish_error(pc->fi, pc, emsg); |
256 | GNUNET_FS_publish_sync_ (pc); | 255 | GNUNET_FS_publish_sync_(pc); |
257 | return; | 256 | return; |
258 | } | 257 | } |
259 | if (NULL != uri) | 258 | if (NULL != uri) |
260 | { | 259 | { |
261 | /* sks publication, remember namespace URI */ | 260 | /* sks publication, remember namespace URI */ |
262 | pc->fi->sks_uri = GNUNET_FS_uri_dup (uri); | 261 | pc->fi->sks_uri = GNUNET_FS_uri_dup(uri); |
263 | } | 262 | } |
264 | GNUNET_assert (pc->qre == NULL); | 263 | GNUNET_assert(pc->qre == NULL); |
265 | if ((pc->dsh != NULL) && (pc->rid != 0)) | 264 | if ((pc->dsh != NULL) && (pc->rid != 0)) |
266 | { | 265 | { |
267 | pc->qre = | 266 | pc->qre = |
268 | GNUNET_DATASTORE_release_reserve (pc->dsh, pc->rid, UINT_MAX, UINT_MAX, | 267 | GNUNET_DATASTORE_release_reserve(pc->dsh, pc->rid, UINT_MAX, UINT_MAX, |
269 | &finish_release_reserve, pc); | 268 | &finish_release_reserve, pc); |
270 | } | 269 | } |
271 | else | 270 | else |
272 | { | 271 | { |
273 | finish_release_reserve (pc, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL); | 272 | finish_release_reserve(pc, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL); |
274 | } | 273 | } |
275 | } | 274 | } |
276 | 275 | ||
277 | 276 | ||
@@ -282,20 +281,20 @@ publish_sblocks_cont (void *cls, | |||
282 | * @param pc overall upload data | 281 | * @param pc overall upload data |
283 | */ | 282 | */ |
284 | static void | 283 | static void |
285 | publish_sblock (struct GNUNET_FS_PublishContext *pc) | 284 | publish_sblock(struct GNUNET_FS_PublishContext *pc) |
286 | { | 285 | { |
287 | if (NULL != pc->ns) | 286 | if (NULL != pc->ns) |
288 | pc->sks_pc = GNUNET_FS_publish_sks (pc->h, | 287 | pc->sks_pc = GNUNET_FS_publish_sks(pc->h, |
289 | pc->ns, | 288 | pc->ns, |
290 | pc->nid, | 289 | pc->nid, |
291 | pc->nuid, | 290 | pc->nuid, |
292 | pc->fi->meta, | 291 | pc->fi->meta, |
293 | pc->fi->chk_uri, | 292 | pc->fi->chk_uri, |
294 | &pc->fi->bo, | 293 | &pc->fi->bo, |
295 | pc->options, | 294 | pc->options, |
296 | &publish_sblocks_cont, pc); | 295 | &publish_sblocks_cont, pc); |
297 | else | 296 | else |
298 | publish_sblocks_cont (pc, NULL, NULL); | 297 | publish_sblocks_cont(pc, NULL, NULL); |
299 | } | 298 | } |
300 | 299 | ||
301 | 300 | ||
@@ -309,44 +308,44 @@ publish_sblock (struct GNUNET_FS_PublishContext *pc) | |||
309 | * @param emsg NULL on success, otherwise error message | 308 | * @param emsg NULL on success, otherwise error message |
310 | */ | 309 | */ |
311 | static void | 310 | static void |
312 | publish_kblocks_cont (void *cls, | 311 | publish_kblocks_cont(void *cls, |
313 | const struct GNUNET_FS_Uri *uri, | 312 | const struct GNUNET_FS_Uri *uri, |
314 | const char *emsg) | 313 | const char *emsg) |
315 | { | 314 | { |
316 | struct GNUNET_FS_PublishContext *pc = cls; | 315 | struct GNUNET_FS_PublishContext *pc = cls; |
317 | struct GNUNET_FS_FileInformation *p = pc->fi_pos; | 316 | struct GNUNET_FS_FileInformation *p = pc->fi_pos; |
318 | 317 | ||
319 | pc->ksk_pc = NULL; | 318 | pc->ksk_pc = NULL; |
320 | if (NULL != emsg) | 319 | if (NULL != emsg) |
321 | { | 320 | { |
322 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 321 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
323 | "Error uploading KSK blocks: %s\n", | 322 | "Error uploading KSK blocks: %s\n", |
324 | emsg); | 323 | emsg); |
325 | signal_publish_error (p, pc, emsg); | 324 | signal_publish_error(p, pc, emsg); |
326 | GNUNET_FS_file_information_sync_ (p); | 325 | GNUNET_FS_file_information_sync_(p); |
327 | GNUNET_FS_publish_sync_ (pc); | 326 | GNUNET_FS_publish_sync_(pc); |
328 | GNUNET_assert (NULL == pc->upload_task); | 327 | GNUNET_assert(NULL == pc->upload_task); |
329 | pc->upload_task = | 328 | pc->upload_task = |
330 | GNUNET_SCHEDULER_add_with_priority | 329 | GNUNET_SCHEDULER_add_with_priority |
331 | (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 330 | (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
332 | &GNUNET_FS_publish_main_, | 331 | &GNUNET_FS_publish_main_, |
333 | pc); | 332 | pc); |
334 | return; | 333 | return; |
335 | } | 334 | } |
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 335 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
337 | "KSK blocks published, moving on to next file\n"); | 336 | "KSK blocks published, moving on to next file\n"); |
338 | if (NULL != p->dir) | 337 | if (NULL != p->dir) |
339 | signal_publish_completion (p, pc); | 338 | signal_publish_completion(p, pc); |
340 | /* move on to next file */ | 339 | /* move on to next file */ |
341 | if (NULL != p->next) | 340 | if (NULL != p->next) |
342 | pc->fi_pos = p->next; | 341 | pc->fi_pos = p->next; |
343 | else | 342 | else |
344 | pc->fi_pos = p->dir; | 343 | pc->fi_pos = p->dir; |
345 | GNUNET_FS_publish_sync_ (pc); | 344 | GNUNET_FS_publish_sync_(pc); |
346 | GNUNET_assert (NULL == pc->upload_task); | 345 | GNUNET_assert(NULL == pc->upload_task); |
347 | pc->upload_task = | 346 | pc->upload_task = |
348 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 347 | GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
349 | &GNUNET_FS_publish_main_, pc); | 348 | &GNUNET_FS_publish_main_, pc); |
350 | } | 349 | } |
351 | 350 | ||
352 | 351 | ||
@@ -364,11 +363,11 @@ publish_kblocks_cont (void *cls, | |||
364 | * @return number of bytes copied to buf, 0 on error | 363 | * @return number of bytes copied to buf, 0 on error |
365 | */ | 364 | */ |
366 | static size_t | 365 | static size_t |
367 | block_reader (void *cls, | 366 | block_reader(void *cls, |
368 | uint64_t offset, | 367 | uint64_t offset, |
369 | size_t max, | 368 | size_t max, |
370 | void *buf, | 369 | void *buf, |
371 | char **emsg) | 370 | char **emsg) |
372 | { | 371 | { |
373 | struct GNUNET_FS_PublishContext *pc = cls; | 372 | struct GNUNET_FS_PublishContext *pc = cls; |
374 | struct GNUNET_FS_FileInformation *p; | 373 | struct GNUNET_FS_FileInformation *p; |
@@ -377,31 +376,31 @@ block_reader (void *cls, | |||
377 | 376 | ||
378 | p = pc->fi_pos; | 377 | p = pc->fi_pos; |
379 | if (GNUNET_YES == p->is_directory) | 378 | if (GNUNET_YES == p->is_directory) |
380 | { | 379 | { |
381 | pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset); | 380 | pt_size = GNUNET_MIN(max, p->data.dir.dir_size - offset); |
382 | dd = p->data.dir.dir_data; | 381 | dd = p->data.dir.dir_data; |
383 | GNUNET_memcpy (buf, &dd[offset], pt_size); | 382 | GNUNET_memcpy(buf, &dd[offset], pt_size); |
384 | } | 383 | } |
385 | else | 384 | else |
386 | { | 385 | { |
387 | if (UINT64_MAX == offset) | 386 | if (UINT64_MAX == offset) |
388 | { | 387 | { |
389 | if (&GNUNET_FS_data_reader_file_ == p->data.file.reader) | 388 | if (&GNUNET_FS_data_reader_file_ == p->data.file.reader) |
390 | { | 389 | { |
391 | /* force closing the file to avoid keeping too many files open */ | 390 | /* force closing the file to avoid keeping too many files open */ |
392 | p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, NULL); | 391 | p->data.file.reader(p->data.file.reader_cls, offset, 0, NULL, NULL); |
393 | } | 392 | } |
394 | return 0; | 393 | return 0; |
395 | } | 394 | } |
396 | pt_size = GNUNET_MIN (max, p->data.file.file_size - offset); | 395 | pt_size = GNUNET_MIN(max, p->data.file.file_size - offset); |
397 | if (0 == pt_size) | 396 | if (0 == pt_size) |
398 | return 0; /* calling reader with pt_size==0 | 397 | return 0; /* calling reader with pt_size==0 |
399 | * might free buf, so don't! */ | 398 | * might free buf, so don't! */ |
400 | if (pt_size != | 399 | if (pt_size != |
401 | p->data.file.reader (p->data.file.reader_cls, offset, pt_size, buf, | 400 | p->data.file.reader(p->data.file.reader_cls, offset, pt_size, buf, |
402 | emsg)) | 401 | emsg)) |
403 | return 0; | 402 | return 0; |
404 | } | 403 | } |
405 | return pt_size; | 404 | return pt_size; |
406 | } | 405 | } |
407 | 406 | ||
@@ -414,7 +413,7 @@ block_reader (void *cls, | |||
414 | * @param cls our publishing context | 413 | * @param cls our publishing context |
415 | */ | 414 | */ |
416 | static void | 415 | static void |
417 | encode_cont (void *cls) | 416 | encode_cont(void *cls) |
418 | { | 417 | { |
419 | struct GNUNET_FS_PublishContext *pc = cls; | 418 | struct GNUNET_FS_PublishContext *pc = cls; |
420 | struct GNUNET_FS_FileInformation *p; | 419 | struct GNUNET_FS_FileInformation *p; |
@@ -422,44 +421,44 @@ encode_cont (void *cls) | |||
422 | char *emsg; | 421 | char *emsg; |
423 | uint64_t flen; | 422 | uint64_t flen; |
424 | 423 | ||
425 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 424 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
426 | "Finished with tree encoder\n"); | 425 | "Finished with tree encoder\n"); |
427 | p = pc->fi_pos; | 426 | p = pc->fi_pos; |
428 | p->chk_uri = GNUNET_FS_tree_encoder_get_uri (p->te); | 427 | p->chk_uri = GNUNET_FS_tree_encoder_get_uri(p->te); |
429 | GNUNET_FS_file_information_sync_ (p); | 428 | GNUNET_FS_file_information_sync_(p); |
430 | GNUNET_FS_tree_encoder_finish (p->te, &emsg); | 429 | GNUNET_FS_tree_encoder_finish(p->te, &emsg); |
431 | p->te = NULL; | 430 | p->te = NULL; |
432 | if (NULL != emsg) | 431 | if (NULL != emsg) |
433 | { | 432 | { |
434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 433 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
435 | "Error during tree walk: %s\n", | 434 | "Error during tree walk: %s\n", |
436 | emsg); | 435 | emsg); |
437 | GNUNET_asprintf (&p->emsg, | 436 | GNUNET_asprintf(&p->emsg, |
438 | _("Publishing failed: %s"), | 437 | _("Publishing failed: %s"), |
439 | emsg); | 438 | emsg); |
440 | GNUNET_free (emsg); | 439 | GNUNET_free(emsg); |
441 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | 440 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
442 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 441 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
443 | pi.value.publish.specifics.error.message = p->emsg; | 442 | pi.value.publish.specifics.error.message = p->emsg; |
444 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); | 443 | p->client_info = GNUNET_FS_publish_make_status_(&pi, pc, p, 0); |
445 | } | 444 | } |
446 | else | 445 | else |
447 | { | 446 | { |
448 | /* final progress event */ | 447 | /* final progress event */ |
449 | GNUNET_assert (NULL != p->chk_uri); | 448 | GNUNET_assert(NULL != p->chk_uri); |
450 | flen = GNUNET_FS_uri_chk_get_file_size (p->chk_uri); | 449 | flen = GNUNET_FS_uri_chk_get_file_size(p->chk_uri); |
451 | pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS; | 450 | pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS; |
452 | pi.value.publish.specifics.progress.data = NULL; | 451 | pi.value.publish.specifics.progress.data = NULL; |
453 | pi.value.publish.specifics.progress.offset = flen; | 452 | pi.value.publish.specifics.progress.offset = flen; |
454 | pi.value.publish.specifics.progress.data_len = 0; | 453 | pi.value.publish.specifics.progress.data_len = 0; |
455 | pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen); | 454 | pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth(flen); |
456 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen); | 455 | p->client_info = GNUNET_FS_publish_make_status_(&pi, pc, p, flen); |
457 | } | 456 | } |
458 | /* continue with main */ /* continue with main */ | 457 | /* continue with main */ /* continue with main */ |
459 | GNUNET_assert (NULL == pc->upload_task); | 458 | GNUNET_assert(NULL == pc->upload_task); |
460 | pc->upload_task = | 459 | pc->upload_task = |
461 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 460 | GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
462 | &GNUNET_FS_publish_main_, pc); | 461 | &GNUNET_FS_publish_main_, pc); |
463 | } | 462 | } |
464 | 463 | ||
465 | 464 | ||
@@ -478,13 +477,13 @@ encode_cont (void *cls) | |||
478 | * @param block_size size of @a block (in bytes) | 477 | * @param block_size size of @a block (in bytes) |
479 | */ | 478 | */ |
480 | static void | 479 | static void |
481 | block_proc (void *cls, | 480 | block_proc(void *cls, |
482 | const struct ContentHashKey *chk, | 481 | const struct ContentHashKey *chk, |
483 | uint64_t offset, | 482 | uint64_t offset, |
484 | unsigned int depth, | 483 | unsigned int depth, |
485 | enum GNUNET_BLOCK_Type type, | 484 | enum GNUNET_BLOCK_Type type, |
486 | const void *block, | 485 | const void *block, |
487 | uint16_t block_size) | 486 | uint16_t block_size) |
488 | { | 487 | { |
489 | struct GNUNET_FS_PublishContext *pc = cls; | 488 | struct GNUNET_FS_PublishContext *pc = cls; |
490 | struct GNUNET_FS_FileInformation *p; | 489 | struct GNUNET_FS_FileInformation *p; |
@@ -492,62 +491,62 @@ block_proc (void *cls, | |||
492 | 491 | ||
493 | p = pc->fi_pos; | 492 | p = pc->fi_pos; |
494 | if (NULL == pc->dsh) | 493 | if (NULL == pc->dsh) |
495 | { | 494 | { |
496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 495 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
497 | "Waiting for datastore connection\n"); | 496 | "Waiting for datastore connection\n"); |
498 | GNUNET_assert (NULL == pc->upload_task); | 497 | GNUNET_assert(NULL == pc->upload_task); |
499 | pc->upload_task = | 498 | pc->upload_task = |
500 | GNUNET_SCHEDULER_add_with_priority | 499 | GNUNET_SCHEDULER_add_with_priority |
501 | (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); | 500 | (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); |
502 | return; | 501 | return; |
503 | } | 502 | } |
504 | 503 | ||
505 | if ( (GNUNET_YES != p->is_directory) && | 504 | if ((GNUNET_YES != p->is_directory) && |
506 | (GNUNET_YES == p->data.file.do_index) && | 505 | (GNUNET_YES == p->data.file.do_index) && |
507 | (GNUNET_BLOCK_TYPE_FS_DBLOCK == type) ) | 506 | (GNUNET_BLOCK_TYPE_FS_DBLOCK == type)) |
508 | { | 507 | { |
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 508 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
510 | "Indexing block `%s' for offset %llu with index size %u\n", | 509 | "Indexing block `%s' for offset %llu with index size %u\n", |
511 | GNUNET_h2s (&chk->query), | 510 | GNUNET_h2s(&chk->query), |
512 | (unsigned long long) offset, | 511 | (unsigned long long)offset, |
513 | (unsigned int) sizeof (struct OnDemandBlock)); | 512 | (unsigned int)sizeof(struct OnDemandBlock)); |
514 | odb.offset = GNUNET_htonll (offset); | 513 | odb.offset = GNUNET_htonll(offset); |
515 | odb.file_id = p->data.file.file_id; | 514 | odb.file_id = p->data.file.file_id; |
516 | GNUNET_assert (pc->qre == NULL); | 515 | GNUNET_assert(pc->qre == NULL); |
517 | pc->qre = | 516 | pc->qre = |
518 | GNUNET_DATASTORE_put (pc->dsh, | 517 | GNUNET_DATASTORE_put(pc->dsh, |
519 | (p->is_directory == GNUNET_YES) ? 0 : pc->rid, | 518 | (p->is_directory == GNUNET_YES) ? 0 : pc->rid, |
520 | &chk->query, | 519 | &chk->query, |
521 | sizeof (struct OnDemandBlock), | 520 | sizeof(struct OnDemandBlock), |
522 | &odb, | 521 | &odb, |
523 | GNUNET_BLOCK_TYPE_FS_ONDEMAND, | 522 | GNUNET_BLOCK_TYPE_FS_ONDEMAND, |
524 | p->bo.content_priority, | 523 | p->bo.content_priority, |
525 | p->bo.anonymity_level, | 524 | p->bo.anonymity_level, |
526 | p->bo.replication_level, | 525 | p->bo.replication_level, |
527 | p->bo.expiration_time, | 526 | p->bo.expiration_time, |
528 | -2, 1, | 527 | -2, 1, |
529 | &ds_put_cont, pc); | 528 | &ds_put_cont, pc); |
530 | return; | 529 | return; |
531 | } | 530 | } |
532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 531 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
533 | "Publishing block `%s' for offset %llu with size %u\n", | 532 | "Publishing block `%s' for offset %llu with size %u\n", |
534 | GNUNET_h2s (&chk->query), | 533 | GNUNET_h2s(&chk->query), |
535 | (unsigned long long) offset, | 534 | (unsigned long long)offset, |
536 | (unsigned int) block_size); | 535 | (unsigned int)block_size); |
537 | GNUNET_assert (pc->qre == NULL); | 536 | GNUNET_assert(pc->qre == NULL); |
538 | pc->qre = | 537 | pc->qre = |
539 | GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : pc->rid, | 538 | GNUNET_DATASTORE_put(pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : pc->rid, |
540 | &chk->query, | 539 | &chk->query, |
541 | block_size, | 540 | block_size, |
542 | block, | 541 | block, |
543 | type, | 542 | type, |
544 | p->bo.content_priority, | 543 | p->bo.content_priority, |
545 | p->bo.anonymity_level, | 544 | p->bo.anonymity_level, |
546 | p->bo.replication_level, | 545 | p->bo.replication_level, |
547 | p->bo.expiration_time, | 546 | p->bo.expiration_time, |
548 | -2, 1, | 547 | -2, 1, |
549 | &ds_put_cont, | 548 | &ds_put_cont, |
550 | pc); | 549 | pc); |
551 | } | 550 | } |
552 | 551 | ||
553 | 552 | ||
@@ -562,10 +561,10 @@ block_proc (void *cls, | |||
562 | * @param depth depth of the block in the tree, 0 for DBLOCK | 561 | * @param depth depth of the block in the tree, 0 for DBLOCK |
563 | */ | 562 | */ |
564 | static void | 563 | static void |
565 | progress_proc (void *cls, uint64_t offset, | 564 | progress_proc(void *cls, uint64_t offset, |
566 | const void *pt_block, | 565 | const void *pt_block, |
567 | size_t pt_size, | 566 | size_t pt_size, |
568 | unsigned int depth) | 567 | unsigned int depth) |
569 | { | 568 | { |
570 | struct GNUNET_FS_PublishContext *pc = cls; | 569 | struct GNUNET_FS_PublishContext *pc = cls; |
571 | struct GNUNET_FS_FileInformation *p; | 570 | struct GNUNET_FS_FileInformation *p; |
@@ -578,24 +577,23 @@ progress_proc (void *cls, uint64_t offset, | |||
578 | pi.value.publish.specifics.progress.offset = offset; | 577 | pi.value.publish.specifics.progress.offset = offset; |
579 | pi.value.publish.specifics.progress.data_len = pt_size; | 578 | pi.value.publish.specifics.progress.data_len = pt_size; |
580 | pi.value.publish.specifics.progress.depth = depth; | 579 | pi.value.publish.specifics.progress.depth = depth; |
581 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, offset); | 580 | p->client_info = GNUNET_FS_publish_make_status_(&pi, pc, p, offset); |
582 | if ( (0 != depth) || | 581 | if ((0 != depth) || |
583 | (GNUNET_YES == p->is_directory) ) | 582 | (GNUNET_YES == p->is_directory)) |
584 | return; | 583 | return; |
585 | while (NULL != (par = p->dir)) | 584 | while (NULL != (par = p->dir)) |
586 | { | 585 | { |
587 | p = par; | 586 | p = par; |
588 | GNUNET_assert (GNUNET_YES == par->is_directory); | 587 | GNUNET_assert(GNUNET_YES == par->is_directory); |
589 | p->data.dir.contents_completed += pt_size; | 588 | p->data.dir.contents_completed += pt_size; |
590 | pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY; | 589 | pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY; |
591 | pi.value.publish.specifics.progress_directory.completed = p->data.dir.contents_completed; | 590 | pi.value.publish.specifics.progress_directory.completed = p->data.dir.contents_completed; |
592 | pi.value.publish.specifics.progress_directory.total = p->data.dir.contents_size; | 591 | pi.value.publish.specifics.progress_directory.total = p->data.dir.contents_size; |
593 | pi.value.publish.specifics.progress_directory.eta = GNUNET_TIME_calculate_eta (p->start_time, | 592 | pi.value.publish.specifics.progress_directory.eta = GNUNET_TIME_calculate_eta(p->start_time, |
594 | p->data.dir.contents_completed, | 593 | p->data.dir.contents_completed, |
595 | p->data.dir.contents_size); | 594 | p->data.dir.contents_size); |
596 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); | 595 | p->client_info = GNUNET_FS_publish_make_status_(&pi, pc, p, 0); |
597 | 596 | } | |
598 | } | ||
599 | } | 597 | } |
600 | 598 | ||
601 | 599 | ||
@@ -607,7 +605,7 @@ progress_proc (void *cls, uint64_t offset, | |||
607 | * @param pc overall upload data | 605 | * @param pc overall upload data |
608 | */ | 606 | */ |
609 | static void | 607 | static void |
610 | publish_content (struct GNUNET_FS_PublishContext *pc) | 608 | publish_content(struct GNUNET_FS_PublishContext *pc) |
611 | { | 609 | { |
612 | struct GNUNET_FS_FileInformation *p; | 610 | struct GNUNET_FS_FileInformation *p; |
613 | char *emsg; | 611 | char *emsg; |
@@ -617,65 +615,64 @@ publish_content (struct GNUNET_FS_PublishContext *pc) | |||
617 | uint64_t size; | 615 | uint64_t size; |
618 | 616 | ||
619 | p = pc->fi_pos; | 617 | p = pc->fi_pos; |
620 | GNUNET_assert (NULL != p); | 618 | GNUNET_assert(NULL != p); |
621 | if (NULL == p->te) | 619 | if (NULL == p->te) |
622 | { | 620 | { |
623 | if (GNUNET_YES == p->is_directory) | 621 | if (GNUNET_YES == p->is_directory) |
624 | { | ||
625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n"); | ||
626 | db = GNUNET_FS_directory_builder_create (p->meta); | ||
627 | dirpos = p->data.dir.entries; | ||
628 | while (NULL != dirpos) | ||
629 | { | ||
630 | if (GNUNET_YES == dirpos->is_directory) | ||
631 | { | ||
632 | raw_data = dirpos->data.dir.dir_data; | ||
633 | dirpos->data.dir.dir_data = NULL; | ||
634 | } | ||
635 | else | ||
636 | { | 622 | { |
637 | raw_data = NULL; | 623 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n"); |
638 | if ((dirpos->data.file.file_size < MAX_INLINE_SIZE) && | 624 | db = GNUNET_FS_directory_builder_create(p->meta); |
639 | (dirpos->data.file.file_size > 0)) | 625 | dirpos = p->data.dir.entries; |
640 | { | 626 | while (NULL != dirpos) |
641 | raw_data = GNUNET_malloc (dirpos->data.file.file_size); | ||
642 | emsg = NULL; | ||
643 | if (dirpos->data.file.file_size != | ||
644 | dirpos->data.file.reader (dirpos->data.file.reader_cls, 0, | ||
645 | dirpos->data.file.file_size, raw_data, | ||
646 | &emsg)) | ||
647 | { | 627 | { |
648 | GNUNET_free_non_null (emsg); | 628 | if (GNUNET_YES == dirpos->is_directory) |
649 | GNUNET_free (raw_data); | 629 | { |
650 | raw_data = NULL; | 630 | raw_data = dirpos->data.dir.dir_data; |
631 | dirpos->data.dir.dir_data = NULL; | ||
632 | } | ||
633 | else | ||
634 | { | ||
635 | raw_data = NULL; | ||
636 | if ((dirpos->data.file.file_size < MAX_INLINE_SIZE) && | ||
637 | (dirpos->data.file.file_size > 0)) | ||
638 | { | ||
639 | raw_data = GNUNET_malloc(dirpos->data.file.file_size); | ||
640 | emsg = NULL; | ||
641 | if (dirpos->data.file.file_size != | ||
642 | dirpos->data.file.reader(dirpos->data.file.reader_cls, 0, | ||
643 | dirpos->data.file.file_size, raw_data, | ||
644 | &emsg)) | ||
645 | { | ||
646 | GNUNET_free_non_null(emsg); | ||
647 | GNUNET_free(raw_data); | ||
648 | raw_data = NULL; | ||
649 | } | ||
650 | dirpos->data.file.reader(dirpos->data.file.reader_cls, UINT64_MAX, 0, 0, NULL); | ||
651 | } | ||
652 | } | ||
653 | GNUNET_FS_directory_builder_add(db, dirpos->chk_uri, dirpos->meta, | ||
654 | raw_data); | ||
655 | GNUNET_free_non_null(raw_data); | ||
656 | dirpos = dirpos->next; | ||
651 | } | 657 | } |
652 | dirpos->data.file.reader (dirpos->data.file.reader_cls, UINT64_MAX, 0, 0, NULL); | 658 | GNUNET_free_non_null(p->data.dir.dir_data); |
653 | } | 659 | p->data.dir.dir_data = NULL; |
660 | p->data.dir.dir_size = 0; | ||
661 | GNUNET_FS_directory_builder_finish(db, &p->data.dir.dir_size, | ||
662 | &p->data.dir.dir_data); | ||
663 | GNUNET_FS_file_information_sync_(p); | ||
654 | } | 664 | } |
655 | GNUNET_FS_directory_builder_add (db, dirpos->chk_uri, dirpos->meta, | 665 | size = (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; |
656 | raw_data); | 666 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
657 | GNUNET_free_non_null (raw_data); | 667 | "Creating tree encoder\n"); |
658 | dirpos = dirpos->next; | 668 | p->te = |
659 | } | 669 | GNUNET_FS_tree_encoder_create(pc->h, size, pc, &block_reader, |
660 | GNUNET_free_non_null (p->data.dir.dir_data); | 670 | &block_proc, &progress_proc, |
661 | p->data.dir.dir_data = NULL; | 671 | &encode_cont); |
662 | p->data.dir.dir_size = 0; | 672 | } |
663 | GNUNET_FS_directory_builder_finish (db, &p->data.dir.dir_size, | 673 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
664 | &p->data.dir.dir_data); | 674 | "Processing next block from tree\n"); |
665 | GNUNET_FS_file_information_sync_ (p); | 675 | GNUNET_FS_tree_encoder_next(p->te); |
666 | } | ||
667 | size = (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; | ||
668 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
669 | "Creating tree encoder\n"); | ||
670 | p->te = | ||
671 | GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader, | ||
672 | &block_proc, &progress_proc, | ||
673 | &encode_cont); | ||
674 | |||
675 | } | ||
676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
677 | "Processing next block from tree\n"); | ||
678 | GNUNET_FS_tree_encoder_next (p->te); | ||
679 | } | 676 | } |
680 | 677 | ||
681 | 678 | ||
@@ -687,17 +684,17 @@ publish_content (struct GNUNET_FS_PublishContext *pc) | |||
687 | * @param msg the response we got | 684 | * @param msg the response we got |
688 | */ | 685 | */ |
689 | static int | 686 | static int |
690 | check_index_start_failed (void *cls, | 687 | check_index_start_failed(void *cls, |
691 | const struct GNUNET_MessageHeader *msg) | 688 | const struct GNUNET_MessageHeader *msg) |
692 | { | 689 | { |
693 | size_t msize = ntohs (msg->size) - sizeof (*msg); | 690 | size_t msize = ntohs(msg->size) - sizeof(*msg); |
694 | const char *emsg = (const char *) &msg[1]; | 691 | const char *emsg = (const char *)&msg[1]; |
695 | 692 | ||
696 | if (emsg[msize - sizeof (struct GNUNET_MessageHeader) - 1] != '\0') | 693 | if (emsg[msize - sizeof(struct GNUNET_MessageHeader) - 1] != '\0') |
697 | { | 694 | { |
698 | GNUNET_break (0); | 695 | GNUNET_break(0); |
699 | return GNUNET_SYSERR; | 696 | return GNUNET_SYSERR; |
700 | } | 697 | } |
701 | return GNUNET_OK; | 698 | return GNUNET_OK; |
702 | } | 699 | } |
703 | 700 | ||
@@ -710,27 +707,27 @@ check_index_start_failed (void *cls, | |||
710 | * @param msg the response we got | 707 | * @param msg the response we got |
711 | */ | 708 | */ |
712 | static void | 709 | static void |
713 | handle_index_start_failed (void *cls, | 710 | handle_index_start_failed(void *cls, |
714 | const struct GNUNET_MessageHeader *msg) | 711 | const struct GNUNET_MessageHeader *msg) |
715 | { | 712 | { |
716 | struct GNUNET_FS_PublishContext *pc = cls; | 713 | struct GNUNET_FS_PublishContext *pc = cls; |
717 | struct GNUNET_FS_FileInformation *p; | 714 | struct GNUNET_FS_FileInformation *p; |
718 | const char *emsg = (const char *) &msg[1]; | 715 | const char *emsg = (const char *)&msg[1]; |
719 | char *msgtxt; | 716 | char *msgtxt; |
720 | 717 | ||
721 | GNUNET_MQ_destroy (pc->mq); | 718 | GNUNET_MQ_destroy(pc->mq); |
722 | pc->mq = NULL; | 719 | pc->mq = NULL; |
723 | p = pc->fi_pos; | 720 | p = pc->fi_pos; |
724 | GNUNET_asprintf (&msgtxt, | 721 | GNUNET_asprintf(&msgtxt, |
725 | _("Can not index file `%s': %s.\n"), | 722 | _("Can not index file `%s': %s.\n"), |
726 | p->filename, | 723 | p->filename, |
727 | gettext (emsg)); | 724 | gettext(emsg)); |
728 | signal_publish_error (p, | 725 | signal_publish_error(p, |
729 | pc, | 726 | pc, |
730 | msgtxt); | 727 | msgtxt); |
731 | GNUNET_free (msgtxt); | 728 | GNUNET_free(msgtxt); |
732 | GNUNET_FS_file_information_sync_ (p); | 729 | GNUNET_FS_file_information_sync_(p); |
733 | GNUNET_FS_publish_sync_ (pc); | 730 | GNUNET_FS_publish_sync_(pc); |
734 | } | 731 | } |
735 | 732 | ||
736 | 733 | ||
@@ -742,18 +739,18 @@ handle_index_start_failed (void *cls, | |||
742 | * @param msg the response we got | 739 | * @param msg the response we got |
743 | */ | 740 | */ |
744 | static void | 741 | static void |
745 | handle_index_start_ok (void *cls, | 742 | handle_index_start_ok(void *cls, |
746 | const struct GNUNET_MessageHeader *msg) | 743 | const struct GNUNET_MessageHeader *msg) |
747 | { | 744 | { |
748 | struct GNUNET_FS_PublishContext *pc = cls; | 745 | struct GNUNET_FS_PublishContext *pc = cls; |
749 | struct GNUNET_FS_FileInformation *p; | 746 | struct GNUNET_FS_FileInformation *p; |
750 | 747 | ||
751 | GNUNET_MQ_destroy (pc->mq); | 748 | GNUNET_MQ_destroy(pc->mq); |
752 | pc->mq = NULL; | 749 | pc->mq = NULL; |
753 | p = pc->fi_pos; | 750 | p = pc->fi_pos; |
754 | p->data.file.index_start_confirmed = GNUNET_YES; | 751 | p->data.file.index_start_confirmed = GNUNET_YES; |
755 | GNUNET_FS_file_information_sync_ (p); | 752 | GNUNET_FS_file_information_sync_(p); |
756 | publish_content (pc); | 753 | publish_content(pc); |
757 | } | 754 | } |
758 | 755 | ||
759 | 756 | ||
@@ -766,25 +763,25 @@ handle_index_start_ok (void *cls, | |||
766 | * @param error error code | 763 | * @param error error code |
767 | */ | 764 | */ |
768 | static void | 765 | static void |
769 | index_mq_error_handler (void *cls, | 766 | index_mq_error_handler(void *cls, |
770 | enum GNUNET_MQ_Error error) | 767 | enum GNUNET_MQ_Error error) |
771 | { | 768 | { |
772 | struct GNUNET_FS_PublishContext *pc = cls; | 769 | struct GNUNET_FS_PublishContext *pc = cls; |
773 | struct GNUNET_FS_FileInformation *p; | 770 | struct GNUNET_FS_FileInformation *p; |
774 | 771 | ||
775 | if (NULL != pc->mq) | 772 | if (NULL != pc->mq) |
776 | { | 773 | { |
777 | GNUNET_MQ_destroy (pc->mq); | 774 | GNUNET_MQ_destroy(pc->mq); |
778 | pc->mq = NULL; | 775 | pc->mq = NULL; |
779 | } | 776 | } |
780 | p = pc->fi_pos; | 777 | p = pc->fi_pos; |
781 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 778 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
782 | _("Can not index file `%s': %s. Will try to insert instead.\n"), | 779 | _("Can not index file `%s': %s. Will try to insert instead.\n"), |
783 | p->filename, | 780 | p->filename, |
784 | _("error on index-start request to `fs' service")); | 781 | _("error on index-start request to `fs' service")); |
785 | p->data.file.do_index = GNUNET_NO; | 782 | p->data.file.do_index = GNUNET_NO; |
786 | GNUNET_FS_file_information_sync_ (p); | 783 | GNUNET_FS_file_information_sync_(p); |
787 | publish_content (pc); | 784 | publish_content(pc); |
788 | } | 785 | } |
789 | 786 | ||
790 | 787 | ||
@@ -796,20 +793,20 @@ index_mq_error_handler (void *cls, | |||
796 | * @param res resulting hash, NULL on error | 793 | * @param res resulting hash, NULL on error |
797 | */ | 794 | */ |
798 | static void | 795 | static void |
799 | hash_for_index_cb (void *cls, | 796 | hash_for_index_cb(void *cls, |
800 | const struct GNUNET_HashCode *res) | 797 | const struct GNUNET_HashCode *res) |
801 | { | 798 | { |
802 | struct GNUNET_FS_PublishContext *pc = cls; | 799 | struct GNUNET_FS_PublishContext *pc = cls; |
803 | struct GNUNET_MQ_MessageHandler handlers[] = { | 800 | struct GNUNET_MQ_MessageHandler handlers[] = { |
804 | GNUNET_MQ_hd_fixed_size (index_start_ok, | 801 | GNUNET_MQ_hd_fixed_size(index_start_ok, |
805 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK, | 802 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK, |
806 | struct GNUNET_MessageHeader, | 803 | struct GNUNET_MessageHeader, |
807 | pc), | 804 | pc), |
808 | GNUNET_MQ_hd_var_size (index_start_failed, | 805 | GNUNET_MQ_hd_var_size(index_start_failed, |
809 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED, | 806 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED, |
810 | struct GNUNET_MessageHeader, | 807 | struct GNUNET_MessageHeader, |
811 | pc), | 808 | pc), |
812 | GNUNET_MQ_handler_end () | 809 | GNUNET_MQ_handler_end() |
813 | }; | 810 | }; |
814 | struct GNUNET_FS_FileInformation *p; | 811 | struct GNUNET_FS_FileInformation *p; |
815 | struct GNUNET_MQ_Envelope *env; | 812 | struct GNUNET_MQ_Envelope *env; |
@@ -822,97 +819,97 @@ hash_for_index_cb (void *cls, | |||
822 | pc->fhc = NULL; | 819 | pc->fhc = NULL; |
823 | p = pc->fi_pos; | 820 | p = pc->fi_pos; |
824 | if (NULL == res) | 821 | if (NULL == res) |
825 | { | 822 | { |
826 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 823 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
827 | _("Can not index file `%s': %s. Will try to insert instead.\n"), | 824 | _("Can not index file `%s': %s. Will try to insert instead.\n"), |
828 | p->filename, | 825 | p->filename, |
829 | _("failed to compute hash")); | 826 | _("failed to compute hash")); |
830 | p->data.file.do_index = GNUNET_NO; | 827 | p->data.file.do_index = GNUNET_NO; |
831 | GNUNET_FS_file_information_sync_ (p); | 828 | GNUNET_FS_file_information_sync_(p); |
832 | publish_content (pc); | 829 | publish_content(pc); |
833 | return; | 830 | return; |
834 | } | 831 | } |
835 | if (GNUNET_YES == p->data.file.index_start_confirmed) | 832 | if (GNUNET_YES == p->data.file.index_start_confirmed) |
836 | { | 833 | { |
837 | publish_content (pc); | 834 | publish_content(pc); |
838 | return; | 835 | return; |
839 | } | 836 | } |
840 | fn = GNUNET_STRINGS_filename_expand (p->filename); | 837 | fn = GNUNET_STRINGS_filename_expand(p->filename); |
841 | GNUNET_assert (fn != NULL); | 838 | GNUNET_assert(fn != NULL); |
842 | slen = strlen (fn) + 1; | 839 | slen = strlen(fn) + 1; |
843 | if (slen >= | 840 | if (slen >= |
844 | GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage)) | 841 | GNUNET_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage)) |
845 | { | 842 | { |
846 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 843 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
847 | _ | 844 | _ |
848 | ("Can not index file `%s': %s. Will try to insert instead.\n"), | 845 | ("Can not index file `%s': %s. Will try to insert instead.\n"), |
849 | fn, _("filename too long")); | 846 | fn, _("filename too long")); |
850 | GNUNET_free (fn); | 847 | GNUNET_free(fn); |
851 | p->data.file.do_index = GNUNET_NO; | 848 | p->data.file.do_index = GNUNET_NO; |
852 | GNUNET_FS_file_information_sync_ (p); | 849 | GNUNET_FS_file_information_sync_(p); |
853 | publish_content (pc); | 850 | publish_content(pc); |
854 | return; | 851 | return; |
855 | } | 852 | } |
856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 853 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
857 | "Hash of indexed file `%s' is `%s'\n", | 854 | "Hash of indexed file `%s' is `%s'\n", |
858 | p->filename, | 855 | p->filename, |
859 | GNUNET_h2s (res)); | 856 | GNUNET_h2s(res)); |
860 | if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) | 857 | if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) |
861 | { | 858 | { |
862 | p->data.file.file_id = *res; | 859 | p->data.file.file_id = *res; |
863 | p->data.file.have_hash = GNUNET_YES; | 860 | p->data.file.have_hash = GNUNET_YES; |
864 | p->data.file.index_start_confirmed = GNUNET_YES; | 861 | p->data.file.index_start_confirmed = GNUNET_YES; |
865 | GNUNET_FS_file_information_sync_ (p); | 862 | GNUNET_FS_file_information_sync_(p); |
866 | publish_content (pc); | 863 | publish_content(pc); |
867 | GNUNET_free (fn); | 864 | GNUNET_free(fn); |
868 | return; | 865 | return; |
869 | } | 866 | } |
870 | pc->mq = GNUNET_CLIENT_connect (pc->h->cfg, | 867 | pc->mq = GNUNET_CLIENT_connect(pc->h->cfg, |
871 | "fs", | 868 | "fs", |
872 | handlers, | 869 | handlers, |
873 | &index_mq_error_handler, | 870 | &index_mq_error_handler, |
874 | pc); | 871 | pc); |
875 | if (NULL == pc->mq) | 872 | if (NULL == pc->mq) |
876 | { | 873 | { |
877 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 874 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
878 | _("Can not index file `%s': %s. Will try to insert instead.\n"), | 875 | _("Can not index file `%s': %s. Will try to insert instead.\n"), |
879 | p->filename, | 876 | p->filename, |
880 | _("could not connect to `fs' service")); | 877 | _("could not connect to `fs' service")); |
881 | p->data.file.do_index = GNUNET_NO; | 878 | p->data.file.do_index = GNUNET_NO; |
882 | publish_content (pc); | 879 | publish_content(pc); |
883 | GNUNET_free (fn); | 880 | GNUNET_free(fn); |
884 | return; | 881 | return; |
885 | } | 882 | } |
886 | if (p->data.file.have_hash != GNUNET_YES) | 883 | if (p->data.file.have_hash != GNUNET_YES) |
887 | { | 884 | { |
888 | p->data.file.file_id = *res; | 885 | p->data.file.file_id = *res; |
889 | p->data.file.have_hash = GNUNET_YES; | 886 | p->data.file.have_hash = GNUNET_YES; |
890 | GNUNET_FS_file_information_sync_ (p); | 887 | GNUNET_FS_file_information_sync_(p); |
891 | } | 888 | } |
892 | env = GNUNET_MQ_msg_extra (ism, | 889 | env = GNUNET_MQ_msg_extra(ism, |
893 | slen, | 890 | slen, |
894 | GNUNET_MESSAGE_TYPE_FS_INDEX_START); | 891 | GNUNET_MESSAGE_TYPE_FS_INDEX_START); |
895 | if (GNUNET_OK == | 892 | if (GNUNET_OK == |
896 | GNUNET_DISK_file_get_identifiers (p->filename, | 893 | GNUNET_DISK_file_get_identifiers(p->filename, |
897 | &dev, | 894 | &dev, |
898 | &ino)) | 895 | &ino)) |
899 | { | 896 | { |
900 | ism->device = GNUNET_htonll (dev); | 897 | ism->device = GNUNET_htonll(dev); |
901 | ism->inode = GNUNET_htonll (ino); | 898 | ism->inode = GNUNET_htonll(ino); |
902 | } | 899 | } |
903 | else | 900 | else |
904 | { | 901 | { |
905 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 902 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
906 | _("Failed to get file identifiers for `%s'\n"), | 903 | _("Failed to get file identifiers for `%s'\n"), |
907 | p->filename); | 904 | p->filename); |
908 | } | 905 | } |
909 | ism->file_id = *res; | 906 | ism->file_id = *res; |
910 | GNUNET_memcpy (&ism[1], | 907 | GNUNET_memcpy(&ism[1], |
911 | fn, | 908 | fn, |
912 | slen); | 909 | slen); |
913 | GNUNET_free (fn); | 910 | GNUNET_free(fn); |
914 | GNUNET_MQ_send (pc->mq, | 911 | GNUNET_MQ_send(pc->mq, |
915 | env); | 912 | env); |
916 | } | 913 | } |
917 | 914 | ||
918 | 915 | ||
@@ -922,27 +919,27 @@ hash_for_index_cb (void *cls, | |||
922 | * @param pc publishing context to do this for | 919 | * @param pc publishing context to do this for |
923 | */ | 920 | */ |
924 | static void | 921 | static void |
925 | publish_kblocks (struct GNUNET_FS_PublishContext *pc) | 922 | publish_kblocks(struct GNUNET_FS_PublishContext *pc) |
926 | { | 923 | { |
927 | struct GNUNET_FS_FileInformation *p; | 924 | struct GNUNET_FS_FileInformation *p; |
928 | 925 | ||
929 | p = pc->fi_pos; | 926 | p = pc->fi_pos; |
930 | /* upload of "p" complete, publish KBlocks! */ | 927 | /* upload of "p" complete, publish KBlocks! */ |
931 | if (NULL != p->keywords) | 928 | if (NULL != p->keywords) |
932 | { | 929 | { |
933 | pc->ksk_pc = GNUNET_FS_publish_ksk (pc->h, | 930 | pc->ksk_pc = GNUNET_FS_publish_ksk(pc->h, |
934 | p->keywords, | 931 | p->keywords, |
935 | p->meta, | 932 | p->meta, |
936 | p->chk_uri, | 933 | p->chk_uri, |
937 | &p->bo, | 934 | &p->bo, |
938 | pc->options, | 935 | pc->options, |
939 | &publish_kblocks_cont, | 936 | &publish_kblocks_cont, |
940 | pc); | 937 | pc); |
941 | } | 938 | } |
942 | else | 939 | else |
943 | { | 940 | { |
944 | publish_kblocks_cont (pc, p->chk_uri, NULL); | 941 | publish_kblocks_cont(pc, p->chk_uri, NULL); |
945 | } | 942 | } |
946 | } | 943 | } |
947 | 944 | ||
948 | 945 | ||
@@ -953,8 +950,8 @@ publish_kblocks (struct GNUNET_FS_PublishContext *pc) | |||
953 | * @param sig the response we got | 950 | * @param sig the response we got |
954 | */ | 951 | */ |
955 | static void | 952 | static void |
956 | handle_signature_response (void *cls, | 953 | handle_signature_response(void *cls, |
957 | const struct ResponseLocSignatureMessage *sig) | 954 | const struct ResponseLocSignatureMessage *sig) |
958 | { | 955 | { |
959 | struct GNUNET_FS_PublishContext *pc = cls; | 956 | struct GNUNET_FS_PublishContext *pc = cls; |
960 | struct GNUNET_FS_FileInformation *p; | 957 | struct GNUNET_FS_FileInformation *p; |
@@ -964,11 +961,11 @@ handle_signature_response (void *cls, | |||
964 | /* p->data.loc.fi kept from CHK before */ | 961 | /* p->data.loc.fi kept from CHK before */ |
965 | p->chk_uri->data.loc.peer = sig->peer; | 962 | p->chk_uri->data.loc.peer = sig->peer; |
966 | p->chk_uri->data.loc.expirationTime | 963 | p->chk_uri->data.loc.expirationTime |
967 | = GNUNET_TIME_absolute_ntoh (sig->expiration_time); | 964 | = GNUNET_TIME_absolute_ntoh(sig->expiration_time); |
968 | p->chk_uri->data.loc.contentSignature = sig->signature; | 965 | p->chk_uri->data.loc.contentSignature = sig->signature; |
969 | GNUNET_FS_file_information_sync_ (p); | 966 | GNUNET_FS_file_information_sync_(p); |
970 | GNUNET_FS_publish_sync_ (pc); | 967 | GNUNET_FS_publish_sync_(pc); |
971 | publish_kblocks (pc); | 968 | publish_kblocks(pc); |
972 | } | 969 | } |
973 | 970 | ||
974 | 971 | ||
@@ -981,19 +978,19 @@ handle_signature_response (void *cls, | |||
981 | * @param error error code | 978 | * @param error error code |
982 | */ | 979 | */ |
983 | static void | 980 | static void |
984 | loc_mq_error_handler (void *cls, | 981 | loc_mq_error_handler(void *cls, |
985 | enum GNUNET_MQ_Error error) | 982 | enum GNUNET_MQ_Error error) |
986 | { | 983 | { |
987 | struct GNUNET_FS_PublishContext *pc = cls; | 984 | struct GNUNET_FS_PublishContext *pc = cls; |
988 | 985 | ||
989 | if (NULL != pc->mq) | 986 | if (NULL != pc->mq) |
990 | { | 987 | { |
991 | GNUNET_MQ_destroy (pc->mq); | 988 | GNUNET_MQ_destroy(pc->mq); |
992 | pc->mq = NULL; | 989 | pc->mq = NULL; |
993 | } | 990 | } |
994 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 991 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
995 | _("Can not create LOC URI. Will continue with CHK instead.\n")); | 992 | _("Can not create LOC URI. Will continue with CHK instead.\n")); |
996 | publish_kblocks (pc); | 993 | publish_kblocks(pc); |
997 | } | 994 | } |
998 | 995 | ||
999 | 996 | ||
@@ -1005,42 +1002,42 @@ loc_mq_error_handler (void *cls, | |||
1005 | * @param pc the publishing context do to this for | 1002 | * @param pc the publishing context do to this for |
1006 | */ | 1003 | */ |
1007 | static void | 1004 | static void |
1008 | create_loc_uri (struct GNUNET_FS_PublishContext *pc) | 1005 | create_loc_uri(struct GNUNET_FS_PublishContext *pc) |
1009 | { | 1006 | { |
1010 | struct GNUNET_MQ_MessageHandler handlers[] = { | 1007 | struct GNUNET_MQ_MessageHandler handlers[] = { |
1011 | GNUNET_MQ_hd_fixed_size (signature_response, | 1008 | GNUNET_MQ_hd_fixed_size(signature_response, |
1012 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE, | 1009 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE, |
1013 | struct ResponseLocSignatureMessage, | 1010 | struct ResponseLocSignatureMessage, |
1014 | pc), | 1011 | pc), |
1015 | GNUNET_MQ_handler_end () | 1012 | GNUNET_MQ_handler_end() |
1016 | }; | 1013 | }; |
1017 | struct GNUNET_MQ_Envelope *env; | 1014 | struct GNUNET_MQ_Envelope *env; |
1018 | struct RequestLocSignatureMessage *req; | 1015 | struct RequestLocSignatureMessage *req; |
1019 | struct GNUNET_FS_FileInformation *p; | 1016 | struct GNUNET_FS_FileInformation *p; |
1020 | 1017 | ||
1021 | if (NULL != pc->mq) | 1018 | if (NULL != pc->mq) |
1022 | GNUNET_MQ_destroy (pc->mq); | 1019 | GNUNET_MQ_destroy(pc->mq); |
1023 | pc->mq = GNUNET_CLIENT_connect (pc->h->cfg, | 1020 | pc->mq = GNUNET_CLIENT_connect(pc->h->cfg, |
1024 | "fs", | 1021 | "fs", |
1025 | handlers, | 1022 | handlers, |
1026 | &loc_mq_error_handler, | 1023 | &loc_mq_error_handler, |
1027 | pc); | 1024 | pc); |
1028 | if (NULL == pc->mq) | 1025 | if (NULL == pc->mq) |
1029 | { | 1026 | { |
1030 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1027 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
1031 | _("Can not create LOC URI. Will continue with CHK instead.\n")); | 1028 | _("Can not create LOC URI. Will continue with CHK instead.\n")); |
1032 | publish_kblocks (pc); | 1029 | publish_kblocks(pc); |
1033 | return; | 1030 | return; |
1034 | } | 1031 | } |
1035 | p = pc->fi_pos; | 1032 | p = pc->fi_pos; |
1036 | env = GNUNET_MQ_msg (req, | 1033 | env = GNUNET_MQ_msg(req, |
1037 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN); | 1034 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN); |
1038 | req->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); | 1035 | req->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); |
1039 | req->expiration_time = GNUNET_TIME_absolute_hton (p->bo.expiration_time); | 1036 | req->expiration_time = GNUNET_TIME_absolute_hton(p->bo.expiration_time); |
1040 | req->chk = p->chk_uri->data.chk.chk; | 1037 | req->chk = p->chk_uri->data.chk.chk; |
1041 | req->file_length = GNUNET_htonll (p->chk_uri->data.chk.file_length); | 1038 | req->file_length = GNUNET_htonll(p->chk_uri->data.chk.file_length); |
1042 | GNUNET_MQ_send (pc->mq, | 1039 | GNUNET_MQ_send(pc->mq, |
1043 | env); | 1040 | env); |
1044 | } | 1041 | } |
1045 | 1042 | ||
1046 | 1043 | ||
@@ -1050,7 +1047,7 @@ create_loc_uri (struct GNUNET_FS_PublishContext *pc) | |||
1050 | * @param cls `struct GNUNET_FS_PublishContext *` identifies the upload | 1047 | * @param cls `struct GNUNET_FS_PublishContext *` identifies the upload |
1051 | */ | 1048 | */ |
1052 | void | 1049 | void |
1053 | GNUNET_FS_publish_main_ (void *cls) | 1050 | GNUNET_FS_publish_main_(void *cls) |
1054 | { | 1051 | { |
1055 | struct GNUNET_FS_PublishContext *pc = cls; | 1052 | struct GNUNET_FS_PublishContext *pc = cls; |
1056 | struct GNUNET_FS_ProgressInfo pi; | 1053 | struct GNUNET_FS_ProgressInfo pi; |
@@ -1060,108 +1057,108 @@ GNUNET_FS_publish_main_ (void *cls) | |||
1060 | pc->upload_task = NULL; | 1057 | pc->upload_task = NULL; |
1061 | p = pc->fi_pos; | 1058 | p = pc->fi_pos; |
1062 | if (NULL == p) | 1059 | if (NULL == p) |
1063 | { | 1060 | { |
1064 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1061 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1065 | "Publishing complete, now publishing SKS and KSK blocks.\n"); | 1062 | "Publishing complete, now publishing SKS and KSK blocks.\n"); |
1066 | /* upload of entire hierarchy complete, | 1063 | /* upload of entire hierarchy complete, |
1067 | * publish namespace entries */ | 1064 | * publish namespace entries */ |
1068 | GNUNET_FS_publish_sync_ (pc); | 1065 | GNUNET_FS_publish_sync_(pc); |
1069 | publish_sblock (pc); | 1066 | publish_sblock(pc); |
1070 | return; | 1067 | return; |
1071 | } | 1068 | } |
1072 | /* find starting position */ | 1069 | /* find starting position */ |
1073 | while ( (GNUNET_YES == p->is_directory) && | 1070 | while ((GNUNET_YES == p->is_directory) && |
1074 | (NULL != p->data.dir.entries) && | 1071 | (NULL != p->data.dir.entries) && |
1075 | (NULL == p->emsg) && | 1072 | (NULL == p->emsg) && |
1076 | (NULL == p->data.dir.entries->chk_uri) ) | 1073 | (NULL == p->data.dir.entries->chk_uri)) |
1077 | { | 1074 | { |
1078 | p = p->data.dir.entries; | 1075 | p = p->data.dir.entries; |
1079 | pc->fi_pos = p; | 1076 | pc->fi_pos = p; |
1080 | GNUNET_FS_publish_sync_ (pc); | 1077 | GNUNET_FS_publish_sync_(pc); |
1081 | } | 1078 | } |
1082 | /* abort on error */ | 1079 | /* abort on error */ |
1083 | if (NULL != p->emsg) | 1080 | if (NULL != p->emsg) |
1084 | { | 1081 | { |
1085 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1082 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1086 | "Error uploading: %s\n", | 1083 | "Error uploading: %s\n", |
1087 | p->emsg); | 1084 | p->emsg); |
1088 | /* error with current file, abort all | 1085 | /* error with current file, abort all |
1089 | * related files as well! */ | 1086 | * related files as well! */ |
1090 | while (NULL != p->dir) | 1087 | while (NULL != p->dir) |
1091 | { | 1088 | { |
1092 | fn = GNUNET_CONTAINER_meta_data_get_by_type (p->meta, | 1089 | fn = GNUNET_CONTAINER_meta_data_get_by_type(p->meta, |
1093 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | 1090 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); |
1094 | p = p->dir; | 1091 | p = p->dir; |
1095 | if (fn != NULL) | 1092 | if (fn != NULL) |
1096 | { | 1093 | { |
1097 | GNUNET_asprintf (&p->emsg, | 1094 | GNUNET_asprintf(&p->emsg, |
1098 | _("Recursive upload failed at `%s': %s"), | 1095 | _("Recursive upload failed at `%s': %s"), |
1099 | fn, | 1096 | fn, |
1100 | p->emsg); | 1097 | p->emsg); |
1101 | GNUNET_free (fn); | 1098 | GNUNET_free(fn); |
1102 | } | 1099 | } |
1103 | else | 1100 | else |
1104 | { | 1101 | { |
1105 | GNUNET_asprintf (&p->emsg, | 1102 | GNUNET_asprintf(&p->emsg, |
1106 | _("Recursive upload failed: %s"), | 1103 | _("Recursive upload failed: %s"), |
1107 | p->emsg); | 1104 | p->emsg); |
1108 | } | 1105 | } |
1109 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; | 1106 | pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; |
1110 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 1107 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
1111 | pi.value.publish.specifics.error.message = p->emsg; | 1108 | pi.value.publish.specifics.error.message = p->emsg; |
1112 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); | 1109 | p->client_info = GNUNET_FS_publish_make_status_(&pi, pc, p, 0); |
1110 | } | ||
1111 | pc->all_done = GNUNET_YES; | ||
1112 | GNUNET_FS_publish_sync_(pc); | ||
1113 | return; | ||
1113 | } | 1114 | } |
1114 | pc->all_done = GNUNET_YES; | ||
1115 | GNUNET_FS_publish_sync_ (pc); | ||
1116 | return; | ||
1117 | } | ||
1118 | /* handle completion */ | 1115 | /* handle completion */ |
1119 | if (NULL != p->chk_uri) | 1116 | if (NULL != p->chk_uri) |
1120 | { | ||
1121 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1122 | "File upload complete, now publishing KSK blocks.\n"); | ||
1123 | GNUNET_FS_publish_sync_ (pc); | ||
1124 | |||
1125 | if ( (0 == p->bo.anonymity_level) && | ||
1126 | (GNUNET_YES != | ||
1127 | GNUNET_FS_uri_test_loc (p->chk_uri)) ) | ||
1128 | { | ||
1129 | /* zero anonymity, box CHK URI in LOC URI */ | ||
1130 | create_loc_uri (pc); | ||
1131 | } | ||
1132 | else | ||
1133 | { | 1117 | { |
1134 | publish_kblocks (pc); | 1118 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1119 | "File upload complete, now publishing KSK blocks.\n"); | ||
1120 | GNUNET_FS_publish_sync_(pc); | ||
1121 | |||
1122 | if ((0 == p->bo.anonymity_level) && | ||
1123 | (GNUNET_YES != | ||
1124 | GNUNET_FS_uri_test_loc(p->chk_uri))) | ||
1125 | { | ||
1126 | /* zero anonymity, box CHK URI in LOC URI */ | ||
1127 | create_loc_uri(pc); | ||
1128 | } | ||
1129 | else | ||
1130 | { | ||
1131 | publish_kblocks(pc); | ||
1132 | } | ||
1133 | return; | ||
1135 | } | 1134 | } |
1136 | return; | ||
1137 | } | ||
1138 | if ((GNUNET_YES != p->is_directory) && (p->data.file.do_index)) | 1135 | if ((GNUNET_YES != p->is_directory) && (p->data.file.do_index)) |
1139 | { | ||
1140 | if (NULL == p->filename) | ||
1141 | { | 1136 | { |
1142 | p->data.file.do_index = GNUNET_NO; | 1137 | if (NULL == p->filename) |
1143 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1138 | { |
1144 | _("Can not index file `%s': %s. Will try to insert instead.\n"), | 1139 | p->data.file.do_index = GNUNET_NO; |
1145 | "<no-name>", | 1140 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
1146 | _("needs to be an actual file")); | 1141 | _("Can not index file `%s': %s. Will try to insert instead.\n"), |
1147 | GNUNET_FS_file_information_sync_ (p); | 1142 | "<no-name>", |
1148 | publish_content (pc); | 1143 | _("needs to be an actual file")); |
1144 | GNUNET_FS_file_information_sync_(p); | ||
1145 | publish_content(pc); | ||
1146 | return; | ||
1147 | } | ||
1148 | if (p->data.file.have_hash) | ||
1149 | { | ||
1150 | hash_for_index_cb(pc, &p->data.file.file_id); | ||
1151 | } | ||
1152 | else | ||
1153 | { | ||
1154 | p->start_time = GNUNET_TIME_absolute_get(); | ||
1155 | pc->fhc = | ||
1156 | GNUNET_CRYPTO_hash_file(GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename, | ||
1157 | HASHING_BLOCKSIZE, &hash_for_index_cb, pc); | ||
1158 | } | ||
1149 | return; | 1159 | return; |
1150 | } | 1160 | } |
1151 | if (p->data.file.have_hash) | 1161 | publish_content(pc); |
1152 | { | ||
1153 | hash_for_index_cb (pc, &p->data.file.file_id); | ||
1154 | } | ||
1155 | else | ||
1156 | { | ||
1157 | p->start_time = GNUNET_TIME_absolute_get (); | ||
1158 | pc->fhc = | ||
1159 | GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename, | ||
1160 | HASHING_BLOCKSIZE, &hash_for_index_cb, pc); | ||
1161 | } | ||
1162 | return; | ||
1163 | } | ||
1164 | publish_content (pc); | ||
1165 | } | 1162 | } |
1166 | 1163 | ||
1167 | 1164 | ||
@@ -1180,14 +1177,14 @@ GNUNET_FS_publish_main_ (void *cls) | |||
1180 | * @return #GNUNET_OK to continue (always) | 1177 | * @return #GNUNET_OK to continue (always) |
1181 | */ | 1178 | */ |
1182 | static int | 1179 | static int |
1183 | fip_signal_start (void *cls, | 1180 | fip_signal_start(void *cls, |
1184 | struct GNUNET_FS_FileInformation *fi, | 1181 | struct GNUNET_FS_FileInformation *fi, |
1185 | uint64_t length, | 1182 | uint64_t length, |
1186 | struct GNUNET_CONTAINER_MetaData *meta, | 1183 | struct GNUNET_CONTAINER_MetaData *meta, |
1187 | struct GNUNET_FS_Uri **uri, | 1184 | struct GNUNET_FS_Uri **uri, |
1188 | struct GNUNET_FS_BlockOptions *bo, | 1185 | struct GNUNET_FS_BlockOptions *bo, |
1189 | int *do_index, | 1186 | int *do_index, |
1190 | void **client_info) | 1187 | void **client_info) |
1191 | { | 1188 | { |
1192 | struct GNUNET_FS_PublishContext *pc = cls; | 1189 | struct GNUNET_FS_PublishContext *pc = cls; |
1193 | struct GNUNET_FS_ProgressInfo pi; | 1190 | struct GNUNET_FS_ProgressInfo pi; |
@@ -1195,52 +1192,52 @@ fip_signal_start (void *cls, | |||
1195 | uint64_t left; | 1192 | uint64_t left; |
1196 | 1193 | ||
1197 | if (GNUNET_YES == pc->skip_next_fi_callback) | 1194 | if (GNUNET_YES == pc->skip_next_fi_callback) |
1198 | { | 1195 | { |
1199 | pc->skip_next_fi_callback = GNUNET_NO; | 1196 | pc->skip_next_fi_callback = GNUNET_NO; |
1200 | return GNUNET_OK; | 1197 | return GNUNET_OK; |
1201 | } | 1198 | } |
1202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1199 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1203 | "Starting publish operation\n"); | 1200 | "Starting publish operation\n"); |
1204 | if (*do_index) | 1201 | if (*do_index) |
1205 | { | 1202 | { |
1206 | /* space for on-demand blocks */ | 1203 | /* space for on-demand blocks */ |
1207 | pc->reserve_space += | 1204 | pc->reserve_space += |
1208 | ((length + DBLOCK_SIZE - | 1205 | ((length + DBLOCK_SIZE - |
1209 | 1) / DBLOCK_SIZE) * sizeof (struct OnDemandBlock); | 1206 | 1) / DBLOCK_SIZE) * sizeof(struct OnDemandBlock); |
1210 | } | 1207 | } |
1211 | else | 1208 | else |
1212 | { | 1209 | { |
1213 | /* space for DBlocks */ | 1210 | /* space for DBlocks */ |
1214 | pc->reserve_space += length; | 1211 | pc->reserve_space += length; |
1215 | } | 1212 | } |
1216 | /* entries for IBlocks and DBlocks, space for IBlocks */ | 1213 | /* entries for IBlocks and DBlocks, space for IBlocks */ |
1217 | left = length; | 1214 | left = length; |
1218 | while (1) | 1215 | while (1) |
1219 | { | 1216 | { |
1220 | left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE; | 1217 | left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE; |
1221 | pc->reserve_entries += left; | 1218 | pc->reserve_entries += left; |
1222 | if (left <= 1) | 1219 | if (left <= 1) |
1223 | break; | 1220 | break; |
1224 | left = left * sizeof (struct ContentHashKey); | 1221 | left = left * sizeof(struct ContentHashKey); |
1225 | pc->reserve_space += left; | 1222 | pc->reserve_space += left; |
1226 | } | 1223 | } |
1227 | pc->reserve_entries++; | 1224 | pc->reserve_entries++; |
1228 | /* entries and space for keywords */ | 1225 | /* entries and space for keywords */ |
1229 | if (NULL != *uri) | 1226 | if (NULL != *uri) |
1230 | { | 1227 | { |
1231 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); | 1228 | kc = GNUNET_FS_uri_ksk_get_keyword_count(*uri); |
1232 | pc->reserve_entries += kc; | 1229 | pc->reserve_entries += kc; |
1233 | pc->reserve_space += GNUNET_MAX_MESSAGE_SIZE * kc; | 1230 | pc->reserve_space += GNUNET_MAX_MESSAGE_SIZE * kc; |
1234 | } | 1231 | } |
1235 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; | 1232 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; |
1236 | *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0); | 1233 | *client_info = GNUNET_FS_publish_make_status_(&pi, pc, fi, 0); |
1237 | GNUNET_FS_file_information_sync_ (fi); | 1234 | GNUNET_FS_file_information_sync_(fi); |
1238 | if ((fi->is_directory) && (fi->dir != NULL)) | 1235 | if ((fi->is_directory) && (fi->dir != NULL)) |
1239 | { | 1236 | { |
1240 | /* We are a directory, and we are not top-level; process entries in directory */ | 1237 | /* We are a directory, and we are not top-level; process entries in directory */ |
1241 | pc->skip_next_fi_callback = GNUNET_YES; | 1238 | pc->skip_next_fi_callback = GNUNET_YES; |
1242 | GNUNET_FS_file_information_inspect (fi, &fip_signal_start, pc); | 1239 | GNUNET_FS_file_information_inspect(fi, &fip_signal_start, pc); |
1243 | } | 1240 | } |
1244 | return GNUNET_OK; | 1241 | return GNUNET_OK; |
1245 | } | 1242 | } |
1246 | 1243 | ||
@@ -1253,39 +1250,39 @@ fip_signal_start (void *cls, | |||
1253 | * @param pc the publish context of which a file is being suspended | 1250 | * @param pc the publish context of which a file is being suspended |
1254 | */ | 1251 | */ |
1255 | static void | 1252 | static void |
1256 | suspend_operation (struct GNUNET_FS_FileInformation *fi, | 1253 | suspend_operation(struct GNUNET_FS_FileInformation *fi, |
1257 | struct GNUNET_FS_PublishContext *pc) | 1254 | struct GNUNET_FS_PublishContext *pc) |
1258 | { | 1255 | { |
1259 | struct GNUNET_FS_ProgressInfo pi; | 1256 | struct GNUNET_FS_ProgressInfo pi; |
1260 | uint64_t off; | 1257 | uint64_t off; |
1261 | 1258 | ||
1262 | if (NULL != pc->ksk_pc) | 1259 | if (NULL != pc->ksk_pc) |
1263 | { | 1260 | { |
1264 | GNUNET_FS_publish_ksk_cancel (pc->ksk_pc); | 1261 | GNUNET_FS_publish_ksk_cancel(pc->ksk_pc); |
1265 | pc->ksk_pc = NULL; | 1262 | pc->ksk_pc = NULL; |
1266 | } | 1263 | } |
1267 | if (NULL != pc->sks_pc) | 1264 | if (NULL != pc->sks_pc) |
1268 | { | 1265 | { |
1269 | GNUNET_FS_publish_sks_cancel (pc->sks_pc); | 1266 | GNUNET_FS_publish_sks_cancel(pc->sks_pc); |
1270 | pc->sks_pc = NULL; | 1267 | pc->sks_pc = NULL; |
1271 | } | 1268 | } |
1272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1269 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1273 | "Suspending publish operation\n"); | 1270 | "Suspending publish operation\n"); |
1274 | GNUNET_free_non_null (fi->serialization); | 1271 | GNUNET_free_non_null(fi->serialization); |
1275 | fi->serialization = NULL; | 1272 | fi->serialization = NULL; |
1276 | off = (NULL == fi->chk_uri) ? 0 : (GNUNET_YES == fi->is_directory) ? fi->data.dir.dir_size : fi->data.file.file_size; | 1273 | off = (NULL == fi->chk_uri) ? 0 : (GNUNET_YES == fi->is_directory) ? fi->data.dir.dir_size : fi->data.file.file_size; |
1277 | pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; | 1274 | pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; |
1278 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off)); | 1275 | GNUNET_break(NULL == GNUNET_FS_publish_make_status_(&pi, pc, fi, off)); |
1279 | if (NULL != pc->qre) | 1276 | if (NULL != pc->qre) |
1280 | { | 1277 | { |
1281 | GNUNET_DATASTORE_cancel (pc->qre); | 1278 | GNUNET_DATASTORE_cancel(pc->qre); |
1282 | pc->qre = NULL; | 1279 | pc->qre = NULL; |
1283 | } | 1280 | } |
1284 | if (NULL != pc->dsh) | 1281 | if (NULL != pc->dsh) |
1285 | { | 1282 | { |
1286 | GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO); | 1283 | GNUNET_DATASTORE_disconnect(pc->dsh, GNUNET_NO); |
1287 | pc->dsh = NULL; | 1284 | pc->dsh = NULL; |
1288 | } | 1285 | } |
1289 | pc->rid = 0; | 1286 | pc->rid = 0; |
1290 | } | 1287 | } |
1291 | 1288 | ||
@@ -1305,29 +1302,29 @@ suspend_operation (struct GNUNET_FS_FileInformation *fi, | |||
1305 | * @return #GNUNET_OK to continue (always) | 1302 | * @return #GNUNET_OK to continue (always) |
1306 | */ | 1303 | */ |
1307 | static int | 1304 | static int |
1308 | fip_signal_suspend (void *cls, | 1305 | fip_signal_suspend(void *cls, |
1309 | struct GNUNET_FS_FileInformation *fi, | 1306 | struct GNUNET_FS_FileInformation *fi, |
1310 | uint64_t length, | 1307 | uint64_t length, |
1311 | struct GNUNET_CONTAINER_MetaData *meta, | 1308 | struct GNUNET_CONTAINER_MetaData *meta, |
1312 | struct GNUNET_FS_Uri **uri, | 1309 | struct GNUNET_FS_Uri **uri, |
1313 | struct GNUNET_FS_BlockOptions *bo, | 1310 | struct GNUNET_FS_BlockOptions *bo, |
1314 | int *do_index, | 1311 | int *do_index, |
1315 | void **client_info) | 1312 | void **client_info) |
1316 | { | 1313 | { |
1317 | struct GNUNET_FS_PublishContext *pc = cls; | 1314 | struct GNUNET_FS_PublishContext *pc = cls; |
1318 | 1315 | ||
1319 | if (GNUNET_YES == pc->skip_next_fi_callback) | 1316 | if (GNUNET_YES == pc->skip_next_fi_callback) |
1320 | { | 1317 | { |
1321 | pc->skip_next_fi_callback = GNUNET_NO; | 1318 | pc->skip_next_fi_callback = GNUNET_NO; |
1322 | return GNUNET_OK; | 1319 | return GNUNET_OK; |
1323 | } | 1320 | } |
1324 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta)) | 1321 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory(meta)) |
1325 | { | 1322 | { |
1326 | /* process entries in directory */ | 1323 | /* process entries in directory */ |
1327 | pc->skip_next_fi_callback = GNUNET_YES; | 1324 | pc->skip_next_fi_callback = GNUNET_YES; |
1328 | GNUNET_FS_file_information_inspect (fi, &fip_signal_suspend, pc); | 1325 | GNUNET_FS_file_information_inspect(fi, &fip_signal_suspend, pc); |
1329 | } | 1326 | } |
1330 | suspend_operation (fi, pc); | 1327 | suspend_operation(fi, pc); |
1331 | *client_info = NULL; | 1328 | *client_info = NULL; |
1332 | return GNUNET_OK; | 1329 | return GNUNET_OK; |
1333 | } | 1330 | } |
@@ -1340,21 +1337,21 @@ fip_signal_suspend (void *cls, | |||
1340 | * @param cls the `struct GNUNET_FS_PublishContext` to signal for | 1337 | * @param cls the `struct GNUNET_FS_PublishContext` to signal for |
1341 | */ | 1338 | */ |
1342 | void | 1339 | void |
1343 | GNUNET_FS_publish_signal_suspend_ (void *cls) | 1340 | GNUNET_FS_publish_signal_suspend_(void *cls) |
1344 | { | 1341 | { |
1345 | struct GNUNET_FS_PublishContext *pc = cls; | 1342 | struct GNUNET_FS_PublishContext *pc = cls; |
1346 | 1343 | ||
1347 | if (NULL != pc->upload_task) | 1344 | if (NULL != pc->upload_task) |
1348 | { | 1345 | { |
1349 | GNUNET_SCHEDULER_cancel (pc->upload_task); | 1346 | GNUNET_SCHEDULER_cancel(pc->upload_task); |
1350 | pc->upload_task = NULL; | 1347 | pc->upload_task = NULL; |
1351 | } | 1348 | } |
1352 | pc->skip_next_fi_callback = GNUNET_YES; | 1349 | pc->skip_next_fi_callback = GNUNET_YES; |
1353 | GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_suspend, pc); | 1350 | GNUNET_FS_file_information_inspect(pc->fi, &fip_signal_suspend, pc); |
1354 | suspend_operation (pc->fi, pc); | 1351 | suspend_operation(pc->fi, pc); |
1355 | GNUNET_FS_end_top (pc->h, pc->top); | 1352 | GNUNET_FS_end_top(pc->h, pc->top); |
1356 | pc->top = NULL; | 1353 | pc->top = NULL; |
1357 | publish_cleanup (pc); | 1354 | publish_cleanup(pc); |
1358 | } | 1355 | } |
1359 | 1356 | ||
1360 | 1357 | ||
@@ -1368,30 +1365,30 @@ GNUNET_FS_publish_signal_suspend_ (void *cls) | |||
1368 | * @param msg error message on error, otherwise NULL | 1365 | * @param msg error message on error, otherwise NULL |
1369 | */ | 1366 | */ |
1370 | static void | 1367 | static void |
1371 | finish_reserve (void *cls, | 1368 | finish_reserve(void *cls, |
1372 | int success, | 1369 | int success, |
1373 | struct GNUNET_TIME_Absolute min_expiration, | 1370 | struct GNUNET_TIME_Absolute min_expiration, |
1374 | const char *msg) | 1371 | const char *msg) |
1375 | { | 1372 | { |
1376 | struct GNUNET_FS_PublishContext *pc = cls; | 1373 | struct GNUNET_FS_PublishContext *pc = cls; |
1377 | 1374 | ||
1378 | pc->qre = NULL; | 1375 | pc->qre = NULL; |
1379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1376 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1380 | "Reservation complete (%d)!\n", | 1377 | "Reservation complete (%d)!\n", |
1381 | success); | 1378 | success); |
1382 | if ((msg != NULL) || (success <= 0)) | 1379 | if ((msg != NULL) || (success <= 0)) |
1383 | { | 1380 | { |
1384 | GNUNET_asprintf (&pc->fi->emsg, | 1381 | GNUNET_asprintf(&pc->fi->emsg, |
1385 | _("Datastore failure: %s"), | 1382 | _("Datastore failure: %s"), |
1386 | msg); | 1383 | msg); |
1387 | signal_publish_error (pc->fi, pc, pc->fi->emsg); | 1384 | signal_publish_error(pc->fi, pc, pc->fi->emsg); |
1388 | return; | 1385 | return; |
1389 | } | 1386 | } |
1390 | pc->rid = success; | 1387 | pc->rid = success; |
1391 | GNUNET_assert (NULL == pc->upload_task); | 1388 | GNUNET_assert(NULL == pc->upload_task); |
1392 | pc->upload_task = | 1389 | pc->upload_task = |
1393 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | 1390 | GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_BACKGROUND, |
1394 | &GNUNET_FS_publish_main_, pc); | 1391 | &GNUNET_FS_publish_main_, pc); |
1395 | } | 1392 | } |
1396 | 1393 | ||
1397 | 1394 | ||
@@ -1401,7 +1398,7 @@ finish_reserve (void *cls, | |||
1401 | * @param fi file structure to traverse | 1398 | * @param fi file structure to traverse |
1402 | */ | 1399 | */ |
1403 | static uint64_t | 1400 | static uint64_t |
1404 | compute_contents_size (struct GNUNET_FS_FileInformation *fi) | 1401 | compute_contents_size(struct GNUNET_FS_FileInformation *fi) |
1405 | { | 1402 | { |
1406 | struct GNUNET_FS_FileInformation *ent; | 1403 | struct GNUNET_FS_FileInformation *ent; |
1407 | 1404 | ||
@@ -1409,7 +1406,7 @@ compute_contents_size (struct GNUNET_FS_FileInformation *fi) | |||
1409 | return fi->data.file.file_size; | 1406 | return fi->data.file.file_size; |
1410 | fi->data.dir.contents_size = 0; | 1407 | fi->data.dir.contents_size = 0; |
1411 | for (ent = fi->data.dir.entries; NULL != ent; ent = ent->next) | 1408 | for (ent = fi->data.dir.entries; NULL != ent; ent = ent->next) |
1412 | fi->data.dir.contents_size += compute_contents_size (ent); | 1409 | fi->data.dir.contents_size += compute_contents_size(ent); |
1413 | return fi->data.dir.contents_size; | 1410 | return fi->data.dir.contents_size; |
1414 | } | 1411 | } |
1415 | 1412 | ||
@@ -1428,67 +1425,67 @@ compute_contents_size (struct GNUNET_FS_FileInformation *fi) | |||
1428 | * @return context that can be used to control the publish operation | 1425 | * @return context that can be used to control the publish operation |
1429 | */ | 1426 | */ |
1430 | struct GNUNET_FS_PublishContext * | 1427 | struct GNUNET_FS_PublishContext * |
1431 | GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | 1428 | GNUNET_FS_publish_start(struct GNUNET_FS_Handle *h, |
1432 | struct GNUNET_FS_FileInformation *fi, | 1429 | struct GNUNET_FS_FileInformation *fi, |
1433 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, | 1430 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, |
1434 | const char *nid, | 1431 | const char *nid, |
1435 | const char *nuid, | 1432 | const char *nuid, |
1436 | enum GNUNET_FS_PublishOptions options) | 1433 | enum GNUNET_FS_PublishOptions options) |
1437 | { | 1434 | { |
1438 | struct GNUNET_FS_PublishContext *ret; | 1435 | struct GNUNET_FS_PublishContext *ret; |
1439 | struct GNUNET_DATASTORE_Handle *dsh; | 1436 | struct GNUNET_DATASTORE_Handle *dsh; |
1440 | 1437 | ||
1441 | GNUNET_assert (NULL != h); | 1438 | GNUNET_assert(NULL != h); |
1442 | compute_contents_size (fi); | 1439 | compute_contents_size(fi); |
1443 | if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) | 1440 | if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) |
1444 | { | 1441 | { |
1445 | dsh = GNUNET_DATASTORE_connect (h->cfg); | 1442 | dsh = GNUNET_DATASTORE_connect(h->cfg); |
1446 | if (NULL == dsh) | 1443 | if (NULL == dsh) |
1447 | return NULL; | 1444 | return NULL; |
1448 | } | 1445 | } |
1449 | else | 1446 | else |
1450 | { | 1447 | { |
1451 | dsh = NULL; | 1448 | dsh = NULL; |
1452 | } | 1449 | } |
1453 | ret = GNUNET_new (struct GNUNET_FS_PublishContext); | 1450 | ret = GNUNET_new(struct GNUNET_FS_PublishContext); |
1454 | ret->dsh = dsh; | 1451 | ret->dsh = dsh; |
1455 | ret->h = h; | 1452 | ret->h = h; |
1456 | ret->fi = fi; | 1453 | ret->fi = fi; |
1457 | if (NULL != ns) | 1454 | if (NULL != ns) |
1458 | { | 1455 | { |
1459 | ret->ns = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); | 1456 | ret->ns = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey); |
1460 | *ret->ns = *ns; | 1457 | *ret->ns = *ns; |
1461 | GNUNET_assert (NULL != nid); | 1458 | GNUNET_assert(NULL != nid); |
1462 | ret->nid = GNUNET_strdup (nid); | 1459 | ret->nid = GNUNET_strdup(nid); |
1463 | if (NULL != nuid) | 1460 | if (NULL != nuid) |
1464 | ret->nuid = GNUNET_strdup (nuid); | 1461 | ret->nuid = GNUNET_strdup(nuid); |
1465 | } | 1462 | } |
1466 | ret->options = options; | 1463 | ret->options = options; |
1467 | /* signal start */ | 1464 | /* signal start */ |
1468 | GNUNET_FS_file_information_inspect (ret->fi, &fip_signal_start, ret); | 1465 | GNUNET_FS_file_information_inspect(ret->fi, &fip_signal_start, ret); |
1469 | ret->fi_pos = ret->fi; | 1466 | ret->fi_pos = ret->fi; |
1470 | ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_publish_signal_suspend_, ret); | 1467 | ret->top = GNUNET_FS_make_top(h, &GNUNET_FS_publish_signal_suspend_, ret); |
1471 | GNUNET_FS_publish_sync_ (ret); | 1468 | GNUNET_FS_publish_sync_(ret); |
1472 | if (NULL != ret->dsh) | 1469 | if (NULL != ret->dsh) |
1473 | { | 1470 | { |
1474 | GNUNET_assert (NULL == ret->qre); | 1471 | GNUNET_assert(NULL == ret->qre); |
1475 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1472 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1476 | _("Reserving space for %u entries and %llu bytes for publication\n"), | 1473 | _("Reserving space for %u entries and %llu bytes for publication\n"), |
1477 | (unsigned int) ret->reserve_entries, | 1474 | (unsigned int)ret->reserve_entries, |
1478 | (unsigned long long) ret->reserve_space); | 1475 | (unsigned long long)ret->reserve_space); |
1479 | ret->qre = | 1476 | ret->qre = |
1480 | GNUNET_DATASTORE_reserve (ret->dsh, ret->reserve_space, | 1477 | GNUNET_DATASTORE_reserve(ret->dsh, ret->reserve_space, |
1481 | ret->reserve_entries, | 1478 | ret->reserve_entries, |
1482 | &finish_reserve, | 1479 | &finish_reserve, |
1483 | ret); | 1480 | ret); |
1484 | } | 1481 | } |
1485 | else | 1482 | else |
1486 | { | 1483 | { |
1487 | GNUNET_assert (NULL == ret->upload_task); | 1484 | GNUNET_assert(NULL == ret->upload_task); |
1488 | ret->upload_task = | 1485 | ret->upload_task = |
1489 | GNUNET_SCHEDULER_add_with_priority | 1486 | GNUNET_SCHEDULER_add_with_priority |
1490 | (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret); | 1487 | (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret); |
1491 | } | 1488 | } |
1492 | return ret; | 1489 | return ret; |
1493 | } | 1490 | } |
1494 | 1491 | ||
@@ -1508,39 +1505,39 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | |||
1508 | * @return #GNUNET_OK to continue (always) | 1505 | * @return #GNUNET_OK to continue (always) |
1509 | */ | 1506 | */ |
1510 | static int | 1507 | static int |
1511 | fip_signal_stop (void *cls, | 1508 | fip_signal_stop(void *cls, |
1512 | struct GNUNET_FS_FileInformation *fi, | 1509 | struct GNUNET_FS_FileInformation *fi, |
1513 | uint64_t length, | 1510 | uint64_t length, |
1514 | struct GNUNET_CONTAINER_MetaData *meta, | 1511 | struct GNUNET_CONTAINER_MetaData *meta, |
1515 | struct GNUNET_FS_Uri **uri, | 1512 | struct GNUNET_FS_Uri **uri, |
1516 | struct GNUNET_FS_BlockOptions *bo, | 1513 | struct GNUNET_FS_BlockOptions *bo, |
1517 | int *do_index, void **client_info) | 1514 | int *do_index, void **client_info) |
1518 | { | 1515 | { |
1519 | struct GNUNET_FS_PublishContext *pc = cls; | 1516 | struct GNUNET_FS_PublishContext *pc = cls; |
1520 | struct GNUNET_FS_ProgressInfo pi; | 1517 | struct GNUNET_FS_ProgressInfo pi; |
1521 | uint64_t off; | 1518 | uint64_t off; |
1522 | 1519 | ||
1523 | if (GNUNET_YES == pc->skip_next_fi_callback) | 1520 | if (GNUNET_YES == pc->skip_next_fi_callback) |
1524 | { | 1521 | { |
1525 | pc->skip_next_fi_callback = GNUNET_NO; | 1522 | pc->skip_next_fi_callback = GNUNET_NO; |
1526 | return GNUNET_OK; | 1523 | return GNUNET_OK; |
1527 | } | 1524 | } |
1528 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta)) | 1525 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory(meta)) |
1529 | { | 1526 | { |
1530 | /* process entries in directory first */ | 1527 | /* process entries in directory first */ |
1531 | pc->skip_next_fi_callback = GNUNET_YES; | 1528 | pc->skip_next_fi_callback = GNUNET_YES; |
1532 | GNUNET_FS_file_information_inspect (fi, &fip_signal_stop, pc); | 1529 | GNUNET_FS_file_information_inspect(fi, &fip_signal_stop, pc); |
1533 | } | 1530 | } |
1534 | if (NULL != fi->serialization) | 1531 | if (NULL != fi->serialization) |
1535 | { | 1532 | { |
1536 | GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO, | 1533 | GNUNET_FS_remove_sync_file_(pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO, |
1537 | fi->serialization); | 1534 | fi->serialization); |
1538 | GNUNET_free (fi->serialization); | 1535 | GNUNET_free(fi->serialization); |
1539 | fi->serialization = NULL; | 1536 | fi->serialization = NULL; |
1540 | } | 1537 | } |
1541 | off = (fi->chk_uri == NULL) ? 0 : length; | 1538 | off = (fi->chk_uri == NULL) ? 0 : length; |
1542 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; | 1539 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; |
1543 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off)); | 1540 | GNUNET_break(NULL == GNUNET_FS_publish_make_status_(&pi, pc, fi, off)); |
1544 | *client_info = NULL; | 1541 | *client_info = NULL; |
1545 | return GNUNET_OK; | 1542 | return GNUNET_OK; |
1546 | } | 1543 | } |
@@ -1555,56 +1552,56 @@ fip_signal_stop (void *cls, | |||
1555 | * @param pc context for the upload to stop | 1552 | * @param pc context for the upload to stop |
1556 | */ | 1553 | */ |
1557 | void | 1554 | void |
1558 | GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) | 1555 | GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc) |
1559 | { | 1556 | { |
1560 | struct GNUNET_FS_ProgressInfo pi; | 1557 | struct GNUNET_FS_ProgressInfo pi; |
1561 | uint64_t off; | 1558 | uint64_t off; |
1562 | 1559 | ||
1563 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1560 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1564 | "Publish stop called\n"); | 1561 | "Publish stop called\n"); |
1565 | GNUNET_FS_end_top (pc->h, pc->top); | 1562 | GNUNET_FS_end_top(pc->h, pc->top); |
1566 | if (NULL != pc->ksk_pc) | 1563 | if (NULL != pc->ksk_pc) |
1567 | { | 1564 | { |
1568 | GNUNET_FS_publish_ksk_cancel (pc->ksk_pc); | 1565 | GNUNET_FS_publish_ksk_cancel(pc->ksk_pc); |
1569 | pc->ksk_pc = NULL; | 1566 | pc->ksk_pc = NULL; |
1570 | } | 1567 | } |
1571 | if (NULL != pc->sks_pc) | 1568 | if (NULL != pc->sks_pc) |
1572 | { | 1569 | { |
1573 | GNUNET_FS_publish_sks_cancel (pc->sks_pc); | 1570 | GNUNET_FS_publish_sks_cancel(pc->sks_pc); |
1574 | pc->sks_pc = NULL; | 1571 | pc->sks_pc = NULL; |
1575 | } | 1572 | } |
1576 | if (NULL != pc->upload_task) | 1573 | if (NULL != pc->upload_task) |
1577 | { | 1574 | { |
1578 | GNUNET_SCHEDULER_cancel (pc->upload_task); | 1575 | GNUNET_SCHEDULER_cancel(pc->upload_task); |
1579 | pc->upload_task = NULL; | 1576 | pc->upload_task = NULL; |
1580 | } | 1577 | } |
1581 | pc->skip_next_fi_callback = GNUNET_YES; | 1578 | pc->skip_next_fi_callback = GNUNET_YES; |
1582 | GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_stop, pc); | 1579 | GNUNET_FS_file_information_inspect(pc->fi, &fip_signal_stop, pc); |
1583 | 1580 | ||
1584 | if (NULL != pc->fi->serialization) | 1581 | if (NULL != pc->fi->serialization) |
1585 | { | 1582 | { |
1586 | GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO, | 1583 | GNUNET_FS_remove_sync_file_(pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO, |
1587 | pc->fi->serialization); | 1584 | pc->fi->serialization); |
1588 | GNUNET_free (pc->fi->serialization); | 1585 | GNUNET_free(pc->fi->serialization); |
1589 | pc->fi->serialization = NULL; | 1586 | pc->fi->serialization = NULL; |
1590 | } | 1587 | } |
1591 | off = (NULL == pc->fi->chk_uri) ? 0 : GNUNET_ntohll (pc->fi->chk_uri->data.chk.file_length); | 1588 | off = (NULL == pc->fi->chk_uri) ? 0 : GNUNET_ntohll(pc->fi->chk_uri->data.chk.file_length); |
1592 | 1589 | ||
1593 | if (NULL != pc->serialization) | 1590 | if (NULL != pc->serialization) |
1594 | { | 1591 | { |
1595 | GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, | 1592 | GNUNET_FS_remove_sync_file_(pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, |
1596 | pc->serialization); | 1593 | pc->serialization); |
1597 | GNUNET_free (pc->serialization); | 1594 | GNUNET_free(pc->serialization); |
1598 | pc->serialization = NULL; | 1595 | pc->serialization = NULL; |
1599 | } | 1596 | } |
1600 | if (NULL != pc->qre) | 1597 | if (NULL != pc->qre) |
1601 | { | 1598 | { |
1602 | GNUNET_DATASTORE_cancel (pc->qre); | 1599 | GNUNET_DATASTORE_cancel(pc->qre); |
1603 | pc->qre = NULL; | 1600 | pc->qre = NULL; |
1604 | } | 1601 | } |
1605 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; | 1602 | pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; |
1606 | GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi, off)); | 1603 | GNUNET_break(NULL == GNUNET_FS_publish_make_status_(&pi, pc, pc->fi, off)); |
1607 | publish_cleanup (pc); | 1604 | publish_cleanup(pc); |
1608 | } | 1605 | } |
1609 | 1606 | ||
1610 | 1607 | ||