aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_unindex.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-04 11:14:25 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-04 11:14:25 +0000
commit6276a671135e01b119f198d0ae3092bfeb14903e (patch)
treebe184253d3c14e2b9ea6b2f4dd335b4c935d68b1 /src/fs/fs_unindex.c
parent6aefa4ac85435c8e7afb86e4e6daef77da69709a (diff)
downloadgnunet-6276a671135e01b119f198d0ae3092bfeb14903e.tar.gz
gnunet-6276a671135e01b119f198d0ae3092bfeb14903e.zip
calling sync, cleaning up files
Diffstat (limited to 'src/fs/fs_unindex.c')
-rw-r--r--src/fs/fs_unindex.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index c79b3413e..9d14bb0cb 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -142,14 +142,13 @@ unindex_progress (void *cls,
142 * @param emsg the error message 142 * @param emsg the error message
143 */ 143 */
144static void 144static void
145signal_unindex_error (struct GNUNET_FS_UnindexContext *uc, 145signal_unindex_error (struct GNUNET_FS_UnindexContext *uc)
146 const char *emsg)
147{ 146{
148 struct GNUNET_FS_ProgressInfo pi; 147 struct GNUNET_FS_ProgressInfo pi;
149 148
150 pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR; 149 pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR;
151 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; 150 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
152 pi.value.unindex.specifics.error.message = emsg; 151 pi.value.unindex.specifics.error.message = uc->emsg;
153 GNUNET_FS_unindex_make_status_ (&pi, uc, 0); 152 GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
154} 153}
155 154
@@ -170,11 +169,10 @@ process_cont (void *cls,
170 struct GNUNET_FS_UnindexContext *uc = cls; 169 struct GNUNET_FS_UnindexContext *uc = cls;
171 if (success == GNUNET_SYSERR) 170 if (success == GNUNET_SYSERR)
172 { 171 {
173 signal_unindex_error (uc, 172 uc->emsg = GNUNET_strdup (msg);
174 msg); 173 signal_unindex_error (uc);
175 return; 174 return;
176 } 175 }
177
178 GNUNET_FS_tree_encoder_next (uc->tc); 176 GNUNET_FS_tree_encoder_next (uc->tc);
179} 177}
180 178
@@ -254,8 +252,8 @@ unindex_finish (void *cls,
254 uc->dsh = NULL; 252 uc->dsh = NULL;
255 if (emsg != NULL) 253 if (emsg != NULL)
256 { 254 {
257 signal_unindex_error (uc, emsg); 255 uc->emsg = emsg;
258 GNUNET_free (emsg); 256 signal_unindex_error (uc);
259 } 257 }
260 else 258 else
261 { 259 {
@@ -263,6 +261,7 @@ unindex_finish (void *cls,
263 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; 261 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
264 GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size); 262 GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size);
265 } 263 }
264 GNUNET_FS_unindex_sync_ (uc);
266} 265}
267 266
268 267
@@ -292,18 +291,21 @@ process_fs_response (void *cls,
292 if (NULL == msg) 291 if (NULL == msg)
293 { 292 {
294 uc->state = UNINDEX_STATE_ERROR; 293 uc->state = UNINDEX_STATE_ERROR;
295 signal_unindex_error (uc, 294 uc->emsg = GNUNET_strdup (_("Timeout waiting for `fs' service."));
296 _("Timeout waiting for `fs' service.")); 295 GNUNET_FS_unindex_sync_ (uc);
296 signal_unindex_error (uc);
297 return; 297 return;
298 } 298 }
299 if (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK) 299 if (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK)
300 { 300 {
301 uc->state = UNINDEX_STATE_ERROR; 301 uc->state = UNINDEX_STATE_ERROR;
302 signal_unindex_error (uc, 302 uc->emsg = GNUNET_strdup (_("Invalid response from `fs' service."));
303 _("Invalid response from `fs' service.")); 303 GNUNET_FS_unindex_sync_ (uc);
304 signal_unindex_error (uc);
304 return; 305 return;
305 } 306 }
306 uc->state = UNINDEX_STATE_DS_REMOVE; 307 uc->state = UNINDEX_STATE_DS_REMOVE;
308 GNUNET_FS_unindex_sync_ (uc);
307 GNUNET_FS_unindex_do_remove_ (uc); 309 GNUNET_FS_unindex_do_remove_ (uc);
308} 310}
309 311
@@ -321,8 +323,9 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
321 if (NULL == uc->dsh) 323 if (NULL == uc->dsh)
322 { 324 {
323 uc->state = UNINDEX_STATE_ERROR; 325 uc->state = UNINDEX_STATE_ERROR;
324 signal_unindex_error (uc, 326 uc->emsg = GNUNET_strdup (_("Failed to connect to `datastore' service."));
325 _("Failed to connect to `datastore' service.")); 327 GNUNET_FS_unindex_sync_ (uc);
328 signal_unindex_error (uc);
326 return; 329 return;
327 } 330 }
328 uc->fh = GNUNET_DISK_file_open (uc->filename, 331 uc->fh = GNUNET_DISK_file_open (uc->filename,
@@ -333,8 +336,9 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
333 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); 336 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
334 uc->dsh = NULL; 337 uc->dsh = NULL;
335 uc->state = UNINDEX_STATE_ERROR; 338 uc->state = UNINDEX_STATE_ERROR;
336 signal_unindex_error (uc, 339 uc->emsg = GNUNET_strdup (_("Failed to open file for unindexing."));
337 _("Failed to open file for unindexing.")); 340 GNUNET_FS_unindex_sync_ (uc);
341 signal_unindex_error (uc);
338 return; 342 return;
339 } 343 }
340 uc->tc = GNUNET_FS_tree_encoder_create (uc->h, 344 uc->tc = GNUNET_FS_tree_encoder_create (uc->h,
@@ -370,12 +374,14 @@ GNUNET_FS_unindex_process_hash_ (void *cls,
370 if (file_id == NULL) 374 if (file_id == NULL)
371 { 375 {
372 uc->state = UNINDEX_STATE_ERROR; 376 uc->state = UNINDEX_STATE_ERROR;
373 signal_unindex_error (uc, 377 uc->emsg = GNUNET_strdup (_("Failed to compute hash of file."));
374 _("Failed to compute hash of file.")); 378 GNUNET_FS_unindex_sync_ (uc);
379 signal_unindex_error (uc);
375 return; 380 return;
376 } 381 }
377 uc->file_id = *file_id; 382 uc->file_id = *file_id;
378 uc->state = UNINDEX_STATE_FS_NOTIFY; 383 uc->state = UNINDEX_STATE_FS_NOTIFY;
384 GNUNET_FS_unindex_sync_ (uc);
379 uc->client = GNUNET_CLIENT_connect (uc->h->sched, 385 uc->client = GNUNET_CLIENT_connect (uc->h->sched,
380 "fs", 386 "fs",
381 uc->h->cfg); 387 uc->h->cfg);
@@ -445,8 +451,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
445 ret->start_time = GNUNET_TIME_absolute_get (); 451 ret->start_time = GNUNET_TIME_absolute_get ();
446 ret->file_size = size; 452 ret->file_size = size;
447 ret->client_info = cctx; 453 ret->client_info = cctx;
448 454 GNUNET_FS_unindex_sync_ (ret);
449 // FIXME: make persistent!
450 pi.status = GNUNET_FS_STATUS_UNINDEX_START; 455 pi.status = GNUNET_FS_STATUS_UNINDEX_START;
451 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; 456 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
452 GNUNET_FS_unindex_make_status_ (&pi, ret, 0); 457 GNUNET_FS_unindex_make_status_ (&pi, ret, 0);