diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-21 21:34:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-21 21:34:27 +0000 |
commit | e94ad8771c6ffe61b6ffb53c15567793760e75ca (patch) | |
tree | 1e2d184877a323b1d9c4b9a4c2e3961bf5d84b51 /src/fs | |
parent | 7121694a98f57aab4dd60e683b02a84b907d6ad7 (diff) | |
download | gnunet-e94ad8771c6ffe61b6ffb53c15567793760e75ca.tar.gz gnunet-e94ad8771c6ffe61b6ffb53c15567793760e75ca.zip |
-branching cleanup
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_api.c | 242 |
1 files changed, 118 insertions, 124 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 5c6f373ae..6d9af1187 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2001--2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -124,15 +124,15 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
124 | { | 124 | { |
125 | switch (qe->priority) | 125 | switch (qe->priority) |
126 | { | 126 | { |
127 | case GNUNET_FS_QUEUE_PRIORITY_PROBE: | 127 | case GNUNET_FS_QUEUE_PRIORITY_PROBE: |
128 | num_probes_waiting++; | 128 | num_probes_waiting++; |
129 | break; | 129 | break; |
130 | case GNUNET_FS_QUEUE_PRIORITY_NORMAL: | 130 | case GNUNET_FS_QUEUE_PRIORITY_NORMAL: |
131 | num_download_waiting++; | 131 | num_download_waiting++; |
132 | break; | 132 | break; |
133 | default: | 133 | default: |
134 | GNUNET_break (0); | 134 | GNUNET_break (0); |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | } | 137 | } |
138 | num_probes_active = 0; | 138 | num_probes_active = 0; |
@@ -513,7 +513,7 @@ GNUNET_FS_make_file_reader_context_ (const char *filename) | |||
513 | 513 | ||
514 | fi = GNUNET_malloc (sizeof (struct FileInfo)); | 514 | fi = GNUNET_malloc (sizeof (struct FileInfo)); |
515 | fi->filename = GNUNET_STRINGS_filename_expand (filename); | 515 | fi->filename = GNUNET_STRINGS_filename_expand (filename); |
516 | if (fi->filename == NULL) | 516 | if (NULL == fi->filename) |
517 | { | 517 | { |
518 | GNUNET_free (fi); | 518 | GNUNET_free (fi); |
519 | return NULL; | 519 | return NULL; |
@@ -550,7 +550,7 @@ GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, | |||
550 | 550 | ||
551 | if (UINT64_MAX == offset) | 551 | if (UINT64_MAX == offset) |
552 | return 0; | 552 | return 0; |
553 | if (max == 0) | 553 | if (0 == max) |
554 | { | 554 | { |
555 | GNUNET_free_non_null (data); | 555 | GNUNET_free_non_null (data); |
556 | return 0; | 556 | return 0; |
@@ -663,7 +663,7 @@ get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) | |||
663 | if (NULL == fn) | 663 | if (NULL == fn) |
664 | return NULL; | 664 | return NULL; |
665 | ret = GNUNET_BIO_write_open (fn); | 665 | ret = GNUNET_BIO_write_open (fn); |
666 | GNUNET_break (ret != NULL); | 666 | GNUNET_break (NULL != ret); |
667 | GNUNET_free (fn); | 667 | GNUNET_free (fn); |
668 | return ret; | 668 | return ret; |
669 | } | 669 | } |
@@ -686,7 +686,7 @@ get_write_handle_in_dir (struct GNUNET_FS_Handle *h, const char *ext, | |||
686 | struct GNUNET_BIO_WriteHandle *ret; | 686 | struct GNUNET_BIO_WriteHandle *ret; |
687 | 687 | ||
688 | fn = get_serialization_file_name_in_dir (h, ext, uni, ent); | 688 | fn = get_serialization_file_name_in_dir (h, ext, uni, ent); |
689 | if (fn == NULL) | 689 | if (NULL == fn) |
690 | return NULL; | 690 | return NULL; |
691 | ret = GNUNET_BIO_write_open (fn); | 691 | ret = GNUNET_BIO_write_open (fn); |
692 | GNUNET_free (fn); | 692 | GNUNET_free (fn); |
@@ -713,7 +713,7 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext, | |||
713 | return; | 713 | return; |
714 | } | 714 | } |
715 | filename = get_serialization_file_name (h, ext, ent); | 715 | filename = get_serialization_file_name (h, ext, ent); |
716 | if (filename != NULL) | 716 | if (NULL != filename) |
717 | { | 717 | { |
718 | if (0 != UNLINK (filename)) | 718 | if (0 != UNLINK (filename)) |
719 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); | 719 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); |
@@ -742,12 +742,11 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext, | |||
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | filename = get_serialization_file_name_in_dir (h, ext, uni, ent); | 744 | filename = get_serialization_file_name_in_dir (h, ext, uni, ent); |
745 | if (filename != NULL) | 745 | if (NULL == filename) |
746 | { | 746 | return; |
747 | if (0 != UNLINK (filename)) | 747 | if (0 != UNLINK (filename)) |
748 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); | 748 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); |
749 | GNUNET_free (filename); | 749 | GNUNET_free (filename); |
750 | } | ||
751 | } | 750 | } |
752 | 751 | ||
753 | 752 | ||
@@ -764,10 +763,10 @@ GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, | |||
764 | { | 763 | { |
765 | char *dn; | 764 | char *dn; |
766 | 765 | ||
767 | if (uni == NULL) | 766 | if (NULL == uni) |
768 | return; | 767 | return; |
769 | dn = get_serialization_file_name_in_dir (h, ext, uni, ""); | 768 | dn = get_serialization_file_name_in_dir (h, ext, uni, ""); |
770 | if (dn == NULL) | 769 | if (NULL == dn) |
771 | return; | 770 | return; |
772 | if ((GNUNET_OK == GNUNET_DISK_directory_test (dn)) && | 771 | if ((GNUNET_OK == GNUNET_DISK_directory_test (dn)) && |
773 | (GNUNET_OK != GNUNET_DISK_directory_remove (dn))) | 772 | (GNUNET_OK != GNUNET_DISK_directory_remove (dn))) |
@@ -1008,13 +1007,13 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, | |||
1008 | goto cleanup; | 1007 | goto cleanup; |
1009 | } | 1008 | } |
1010 | ret->data.dir.dir_size = (uint32_t) dsize; | 1009 | ret->data.dir.dir_size = (uint32_t) dsize; |
1011 | if (filename != NULL) | 1010 | if (NULL != filename) |
1012 | { | 1011 | { |
1013 | ret->data.dir.entries = deserialize_file_information (h, filename); | 1012 | ret->data.dir.entries = deserialize_file_information (h, filename); |
1014 | GNUNET_free (filename); | 1013 | GNUNET_free (filename); |
1015 | filename = NULL; | 1014 | filename = NULL; |
1016 | nxt = ret->data.dir.entries; | 1015 | nxt = ret->data.dir.entries; |
1017 | while (nxt != NULL) | 1016 | while (NULL != nxt) |
1018 | { | 1017 | { |
1019 | nxt->dir = ret; | 1018 | nxt->dir = ret; |
1020 | nxt = nxt->next; | 1019 | nxt = nxt->next; |
@@ -1032,7 +1031,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, | |||
1032 | GNUNET_break (0); | 1031 | GNUNET_break (0); |
1033 | goto cleanup; | 1032 | goto cleanup; |
1034 | } | 1033 | } |
1035 | if (filename != NULL) | 1034 | if (NULL != filename) |
1036 | { | 1035 | { |
1037 | ret->next = deserialize_file_information (h, filename); | 1036 | ret->next = deserialize_file_information (h, filename); |
1038 | GNUNET_free (filename); | 1037 | GNUNET_free (filename); |
@@ -1068,7 +1067,7 @@ deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename) | |||
1068 | char *fn; | 1067 | char *fn; |
1069 | 1068 | ||
1070 | rh = get_read_handle (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename); | 1069 | rh = get_read_handle (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename); |
1071 | if (rh == NULL) | 1070 | if (NULL == rh) |
1072 | return NULL; | 1071 | return NULL; |
1073 | ret = deserialize_fi_node (h, filename, rh); | 1072 | ret = deserialize_fi_node (h, filename, rh); |
1074 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) | 1073 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) |
@@ -1078,7 +1077,7 @@ deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename) | |||
1078 | filename, emsg); | 1077 | filename, emsg); |
1079 | GNUNET_free (emsg); | 1078 | GNUNET_free (emsg); |
1080 | } | 1079 | } |
1081 | if (ret == NULL) | 1080 | if (NULL == ret) |
1082 | { | 1081 | { |
1083 | fn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename); | 1082 | fn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename); |
1084 | if (NULL != fn) | 1083 | if (NULL != fn) |
@@ -1116,7 +1115,7 @@ get_serialization_short_name (const char *fullname) | |||
1116 | end = nxt + 1; | 1115 | end = nxt + 1; |
1117 | nxt++; | 1116 | nxt++; |
1118 | } | 1117 | } |
1119 | if ((end == NULL) || (strlen (end) == 0)) | 1118 | if ((NULL == end) || (0 == strlen (end))) |
1120 | { | 1119 | { |
1121 | GNUNET_break (0); | 1120 | GNUNET_break (0); |
1122 | return NULL; | 1121 | return NULL; |
@@ -1144,7 +1143,7 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext) | |||
1144 | if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) | 1143 | if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) |
1145 | return NULL; /* persistence not requested */ | 1144 | return NULL; /* persistence not requested */ |
1146 | dn = get_serialization_file_name (h, ext, ""); | 1145 | dn = get_serialization_file_name (h, ext, ""); |
1147 | if (dn == NULL) | 1146 | if (NULL == dn) |
1148 | return NULL; | 1147 | return NULL; |
1149 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (dn)) | 1148 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (dn)) |
1150 | { | 1149 | { |
@@ -1153,7 +1152,7 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext) | |||
1153 | } | 1152 | } |
1154 | fn = GNUNET_DISK_mktemp (dn); | 1153 | fn = GNUNET_DISK_mktemp (dn); |
1155 | GNUNET_free (dn); | 1154 | GNUNET_free (dn); |
1156 | if (fn == NULL) | 1155 | if (NULL == fn) |
1157 | return NULL; /* epic fail */ | 1156 | return NULL; /* epic fail */ |
1158 | ret = get_serialization_short_name (fn); | 1157 | ret = get_serialization_short_name (fn); |
1159 | GNUNET_free (fn); | 1158 | GNUNET_free (fn); |
@@ -1181,7 +1180,7 @@ make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, | |||
1181 | if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) | 1180 | if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) |
1182 | return NULL; /* persistence not requested */ | 1181 | return NULL; /* persistence not requested */ |
1183 | dn = get_serialization_file_name_in_dir (h, ext, uni, ""); | 1182 | dn = get_serialization_file_name_in_dir (h, ext, uni, ""); |
1184 | if (dn == NULL) | 1183 | if (NULL == dn) |
1185 | return NULL; | 1184 | return NULL; |
1186 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (dn)) | 1185 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (dn)) |
1187 | { | 1186 | { |
@@ -1190,7 +1189,7 @@ make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, | |||
1190 | } | 1189 | } |
1191 | fn = GNUNET_DISK_mktemp (dn); | 1190 | fn = GNUNET_DISK_mktemp (dn); |
1192 | GNUNET_free (dn); | 1191 | GNUNET_free (dn); |
1193 | if (fn == NULL) | 1192 | if (NULL == fn) |
1194 | return NULL; /* epic fail */ | 1193 | return NULL; /* epic fail */ |
1195 | ret = get_serialization_short_name (fn); | 1194 | ret = get_serialization_short_name (fn); |
1196 | GNUNET_free (fn); | 1195 | GNUNET_free (fn); |
@@ -1222,7 +1221,7 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh, | |||
1222 | left = GNUNET_MIN (sizeof (buf), fi->data.file.file_size - off); | 1221 | left = GNUNET_MIN (sizeof (buf), fi->data.file.file_size - off); |
1223 | ret = | 1222 | ret = |
1224 | fi->data.file.reader (fi->data.file.reader_cls, off, left, buf, &emsg); | 1223 | fi->data.file.reader (fi->data.file.reader_cls, off, left, buf, &emsg); |
1225 | if (ret == 0) | 1224 | if (0 == ret) |
1226 | { | 1225 | { |
1227 | GNUNET_free (emsg); | 1226 | GNUNET_free (emsg); |
1228 | return GNUNET_SYSERR; | 1227 | return GNUNET_SYSERR; |
@@ -1257,7 +1256,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1257 | return; | 1256 | return; |
1258 | wh = get_write_handle (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, | 1257 | wh = get_write_handle (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, |
1259 | fi->serialization); | 1258 | fi->serialization); |
1260 | if (wh == NULL) | 1259 | if (NULL == wh) |
1261 | { | 1260 | { |
1262 | GNUNET_free (fi->serialization); | 1261 | GNUNET_free (fi->serialization); |
1263 | fi->serialization = NULL; | 1262 | fi->serialization = NULL; |
@@ -1273,11 +1272,11 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1273 | b = 1; | 1272 | b = 1; |
1274 | else | 1273 | else |
1275 | b = 0; | 1274 | b = 0; |
1276 | if (fi->keywords != NULL) | 1275 | if (NULL != fi->keywords) |
1277 | ksks = GNUNET_FS_uri_to_string (fi->keywords); | 1276 | ksks = GNUNET_FS_uri_to_string (fi->keywords); |
1278 | else | 1277 | else |
1279 | ksks = NULL; | 1278 | ksks = NULL; |
1280 | if (fi->chk_uri != NULL) | 1279 | if (NULL != fi->chk_uri) |
1281 | chks = GNUNET_FS_uri_to_string (fi->chk_uri); | 1280 | chks = GNUNET_FS_uri_to_string (fi->chk_uri); |
1282 | else | 1281 | else |
1283 | chks = NULL; | 1282 | chks = NULL; |
@@ -1380,7 +1379,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) | |||
1380 | } | 1379 | } |
1381 | return; /* done! */ | 1380 | return; /* done! */ |
1382 | cleanup: | 1381 | cleanup: |
1383 | if (wh != NULL) | 1382 | if (NULL != wh) |
1384 | (void) GNUNET_BIO_write_close (wh); | 1383 | (void) GNUNET_BIO_write_close (wh); |
1385 | GNUNET_free_non_null (chks); | 1384 | GNUNET_free_non_null (chks); |
1386 | GNUNET_free_non_null (ksks); | 1385 | GNUNET_free_non_null (ksks); |
@@ -1411,16 +1410,13 @@ find_file_position (struct GNUNET_FS_FileInformation *pos, const char *srch) | |||
1411 | { | 1410 | { |
1412 | struct GNUNET_FS_FileInformation *r; | 1411 | struct GNUNET_FS_FileInformation *r; |
1413 | 1412 | ||
1414 | while (pos != NULL) | 1413 | while (NULL != pos) |
1415 | { | 1414 | { |
1416 | if (0 == strcmp (srch, pos->serialization)) | 1415 | if (0 == strcmp (srch, pos->serialization)) |
1417 | return pos; | 1416 | return pos; |
1418 | if (pos->is_directory == GNUNET_YES) | 1417 | if ( (GNUNET_YES == pos->is_directory) && |
1419 | { | 1418 | (NULL != (r = find_file_position (pos->data.dir.entries, srch))) ) |
1420 | r = find_file_position (pos->data.dir.entries, srch); | 1419 | return r; |
1421 | if (r != NULL) | ||
1422 | return r; | ||
1423 | } | ||
1424 | pos = pos->next; | 1420 | pos = pos->next; |
1425 | } | 1421 | } |
1426 | return NULL; | 1422 | return NULL; |
@@ -1498,7 +1494,7 @@ deserialize_publish_file (void *cls, const char *filename) | |||
1498 | fi_pos = NULL; | 1494 | fi_pos = NULL; |
1499 | ns = NULL; | 1495 | ns = NULL; |
1500 | rh = GNUNET_BIO_read_open (filename); | 1496 | rh = GNUNET_BIO_read_open (filename); |
1501 | if (rh == NULL) | 1497 | if (NULL == rh) |
1502 | { | 1498 | { |
1503 | GNUNET_break (0); | 1499 | GNUNET_break (0); |
1504 | goto cleanup; | 1500 | goto cleanup; |
@@ -1524,15 +1520,15 @@ deserialize_publish_file (void *cls, const char *filename) | |||
1524 | goto cleanup; | 1520 | goto cleanup; |
1525 | } | 1521 | } |
1526 | pc->fi = deserialize_file_information (h, fi_root); | 1522 | pc->fi = deserialize_file_information (h, fi_root); |
1527 | if (pc->fi == NULL) | 1523 | if (NULL == pc->fi) |
1528 | { | 1524 | { |
1529 | GNUNET_break (0); | 1525 | GNUNET_break (0); |
1530 | goto cleanup; | 1526 | goto cleanup; |
1531 | } | 1527 | } |
1532 | if (ns != NULL) | 1528 | if (NULL != ns) |
1533 | { | 1529 | { |
1534 | pc->namespace = GNUNET_FS_namespace_create (h, ns); | 1530 | pc->namespace = GNUNET_FS_namespace_create (h, ns); |
1535 | if (pc->namespace == NULL) | 1531 | if (NULL == pc->namespace) |
1536 | { | 1532 | { |
1537 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1533 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1538 | _ | 1534 | _ |
@@ -1548,16 +1544,16 @@ deserialize_publish_file (void *cls, const char *filename) | |||
1548 | if (NULL == pc->dsh) | 1544 | if (NULL == pc->dsh) |
1549 | goto cleanup; | 1545 | goto cleanup; |
1550 | } | 1546 | } |
1551 | if (fi_pos != NULL) | 1547 | if (NULL != fi_pos) |
1552 | { | 1548 | { |
1553 | pc->fi_pos = find_file_position (pc->fi, fi_pos); | 1549 | pc->fi_pos = find_file_position (pc->fi, fi_pos); |
1554 | GNUNET_free (fi_pos); | 1550 | GNUNET_free (fi_pos); |
1555 | fi_pos = NULL; | 1551 | fi_pos = NULL; |
1556 | if (pc->fi_pos == NULL) | 1552 | if (NULL == pc->fi_pos) |
1557 | { | 1553 | { |
1558 | /* failed to find position for resuming, outch! Will start from root! */ | 1554 | /* failed to find position for resuming, outch! Will start from root! */ |
1559 | GNUNET_break (0); | 1555 | GNUNET_break (0); |
1560 | if (pc->all_done != GNUNET_YES) | 1556 | if (GNUNET_YES != pc->all_done) |
1561 | pc->fi_pos = pc->fi; | 1557 | pc->fi_pos = pc->fi; |
1562 | } | 1558 | } |
1563 | } | 1559 | } |
@@ -1567,7 +1563,7 @@ deserialize_publish_file (void *cls, const char *filename) | |||
1567 | GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_resume, pc); | 1563 | GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_resume, pc); |
1568 | 1564 | ||
1569 | /* re-start publishing (if needed)... */ | 1565 | /* re-start publishing (if needed)... */ |
1570 | if (pc->all_done != GNUNET_YES) | 1566 | if (GNUNET_YES != pc->all_done) |
1571 | { | 1567 | { |
1572 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); | 1568 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); |
1573 | pc->upload_task = | 1569 | pc->upload_task = |
@@ -1591,14 +1587,14 @@ cleanup: | |||
1591 | GNUNET_free_non_null (fi_root); | 1587 | GNUNET_free_non_null (fi_root); |
1592 | GNUNET_free_non_null (fi_pos); | 1588 | GNUNET_free_non_null (fi_pos); |
1593 | GNUNET_free_non_null (ns); | 1589 | GNUNET_free_non_null (ns); |
1594 | if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) | 1590 | if ((NULL != rh) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) |
1595 | { | 1591 | { |
1596 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1592 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1597 | _("Failed to resume publishing operation `%s': %s\n"), filename, | 1593 | _("Failed to resume publishing operation `%s': %s\n"), filename, |
1598 | emsg); | 1594 | emsg); |
1599 | GNUNET_free (emsg); | 1595 | GNUNET_free (emsg); |
1600 | } | 1596 | } |
1601 | if (pc->fi != NULL) | 1597 | if (NULL != pc->fi) |
1602 | GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); | 1598 | GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); |
1603 | if (0 != UNLINK (filename)) | 1599 | if (0 != UNLINK (filename)) |
1604 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); | 1600 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); |
@@ -1636,7 +1632,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) | |||
1636 | } | 1632 | } |
1637 | wh = get_write_handle (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, | 1633 | wh = get_write_handle (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, |
1638 | pc->serialization); | 1634 | pc->serialization); |
1639 | if (wh == NULL) | 1635 | if (NULL == wh) |
1640 | { | 1636 | { |
1641 | GNUNET_break (0); | 1637 | GNUNET_break (0); |
1642 | goto cleanup; | 1638 | goto cleanup; |
@@ -1648,12 +1644,10 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) | |||
1648 | (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->fi->serialization)) || | 1644 | (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->fi->serialization)) || |
1649 | (GNUNET_OK != | 1645 | (GNUNET_OK != |
1650 | GNUNET_BIO_write_string (wh, | 1646 | GNUNET_BIO_write_string (wh, |
1651 | (pc->fi_pos == | 1647 | (NULL == pc->fi_pos) ? NULL : pc->fi_pos->serialization)) || |
1652 | NULL) ? NULL : pc->fi_pos->serialization)) || | ||
1653 | (GNUNET_OK != | 1648 | (GNUNET_OK != |
1654 | GNUNET_BIO_write_string (wh, | 1649 | GNUNET_BIO_write_string (wh, |
1655 | (pc->namespace == | 1650 | (NULL == pc->namespace) ? NULL : pc->namespace->name))) |
1656 | NULL) ? NULL : pc->namespace->name))) | ||
1657 | { | 1651 | { |
1658 | GNUNET_break (0); | 1652 | GNUNET_break (0); |
1659 | goto cleanup; | 1653 | goto cleanup; |
@@ -1666,7 +1660,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) | |||
1666 | } | 1660 | } |
1667 | return; | 1661 | return; |
1668 | cleanup: | 1662 | cleanup: |
1669 | if (wh != NULL) | 1663 | if (NULL != wh) |
1670 | (void) GNUNET_BIO_write_close (wh); | 1664 | (void) GNUNET_BIO_write_close (wh); |
1671 | GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, | 1665 | GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, |
1672 | pc->serialization); | 1666 | pc->serialization); |
@@ -1697,7 +1691,7 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) | |||
1697 | return; | 1691 | return; |
1698 | wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, | 1692 | wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, |
1699 | uc->serialization); | 1693 | uc->serialization); |
1700 | if (wh == NULL) | 1694 | if (NULL == wh) |
1701 | { | 1695 | { |
1702 | GNUNET_break (0); | 1696 | GNUNET_break (0); |
1703 | goto cleanup; | 1697 | goto cleanup; |
@@ -1731,7 +1725,7 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) | |||
1731 | } | 1725 | } |
1732 | return; | 1726 | return; |
1733 | cleanup: | 1727 | cleanup: |
1734 | if (wh != NULL) | 1728 | if (NULL != wh) |
1735 | (void) GNUNET_BIO_write_close (wh); | 1729 | (void) GNUNET_BIO_write_close (wh); |
1736 | GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, | 1730 | GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, |
1737 | uc->serialization); | 1731 | uc->serialization); |
@@ -1758,7 +1752,7 @@ write_download_request (struct GNUNET_BIO_WriteHandle *wh, | |||
1758 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->num_children)) || | 1752 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->num_children)) || |
1759 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->depth))) | 1753 | (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->depth))) |
1760 | return GNUNET_NO; | 1754 | return GNUNET_NO; |
1761 | if ((dr->state == BRS_CHK_SET) && | 1755 | if ((BRS_CHK_SET == dr->state) && |
1762 | (GNUNET_OK != | 1756 | (GNUNET_OK != |
1763 | GNUNET_BIO_write (wh, &dr->chk, sizeof (struct ContentHashKey)))) | 1757 | GNUNET_BIO_write (wh, &dr->chk, sizeof (struct ContentHashKey)))) |
1764 | return GNUNET_NO; | 1758 | return GNUNET_NO; |
@@ -1782,16 +1776,15 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh) | |||
1782 | unsigned int i; | 1776 | unsigned int i; |
1783 | 1777 | ||
1784 | dr = GNUNET_malloc (sizeof (struct DownloadRequest)); | 1778 | dr = GNUNET_malloc (sizeof (struct DownloadRequest)); |
1785 | |||
1786 | if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->state)) || | 1779 | if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->state)) || |
1787 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || | 1780 | (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || |
1788 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || | 1781 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || |
1789 | (dr->num_children > CHK_PER_INODE) || | 1782 | (dr->num_children > CHK_PER_INODE) || |
1790 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || ((dr->depth == 0) | 1783 | (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || ((0 == dr->depth) |
1791 | && | 1784 | && |
1792 | (dr->num_children | 1785 | (dr->num_children |
1793 | > 0)) || | 1786 | > 0)) || |
1794 | ((dr->depth > 0) && (dr->num_children == 0))) | 1787 | ((dr->depth > 0) && (0 == dr->num_children))) |
1795 | { | 1788 | { |
1796 | GNUNET_break (0); | 1789 | GNUNET_break (0); |
1797 | dr->num_children = 0; | 1790 | dr->num_children = 0; |
@@ -1855,10 +1848,10 @@ get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc, | |||
1855 | GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD : | 1848 | GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD : |
1856 | GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, | 1849 | GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, |
1857 | uni); | 1850 | uni); |
1858 | if (dc->parent->serialization == NULL) | 1851 | if (NULL == dc->parent->serialization) |
1859 | return NULL; | 1852 | return NULL; |
1860 | par = get_download_sync_filename (dc->parent, dc->parent->serialization, ""); | 1853 | par = get_download_sync_filename (dc->parent, dc->parent->serialization, ""); |
1861 | if (par == NULL) | 1854 | if (NULL == par) |
1862 | return NULL; | 1855 | return NULL; |
1863 | GNUNET_asprintf (&epar, "%s.dir%s%s%s", par, DIR_SEPARATOR_STR, uni, ext); | 1856 | GNUNET_asprintf (&epar, "%s.dir%s%s%s", par, DIR_SEPARATOR_STR, uni, ext); |
1864 | GNUNET_free (par); | 1857 | GNUNET_free (par); |
@@ -1887,7 +1880,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
1887 | if (NULL == dc->serialization) | 1880 | if (NULL == dc->serialization) |
1888 | { | 1881 | { |
1889 | dir = get_download_sync_filename (dc, "", ""); | 1882 | dir = get_download_sync_filename (dc, "", ""); |
1890 | if (dir == NULL) | 1883 | if (NULL == dir) |
1891 | return; | 1884 | return; |
1892 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (dir)) | 1885 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (dir)) |
1893 | { | 1886 | { |
@@ -1896,14 +1889,14 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
1896 | } | 1889 | } |
1897 | fn = GNUNET_DISK_mktemp (dir); | 1890 | fn = GNUNET_DISK_mktemp (dir); |
1898 | GNUNET_free (dir); | 1891 | GNUNET_free (dir); |
1899 | if (fn == NULL) | 1892 | if (NULL == fn) |
1900 | return; | 1893 | return; |
1901 | dc->serialization = get_serialization_short_name (fn); | 1894 | dc->serialization = get_serialization_short_name (fn); |
1902 | } | 1895 | } |
1903 | else | 1896 | else |
1904 | { | 1897 | { |
1905 | fn = get_download_sync_filename (dc, dc->serialization, ""); | 1898 | fn = get_download_sync_filename (dc, dc->serialization, ""); |
1906 | if (fn == NULL) | 1899 | if (NULL == fn) |
1907 | { | 1900 | { |
1908 | GNUNET_free (dc->serialization); | 1901 | GNUNET_free (dc->serialization); |
1909 | dc->serialization = NULL; | 1902 | dc->serialization = NULL; |
@@ -1912,7 +1905,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) | |||
1912 | } | 1905 | } |
1913 | } | 1906 | } |
1914 | wh = GNUNET_BIO_write_open (fn); | 1907 | wh = GNUNET_BIO_write_open (fn); |
1915 | if (wh == NULL) | 1908 | if (NULL == wh) |
1916 | { | 1909 | { |
1917 | GNUNET_free (dc->serialization); | 1910 | GNUNET_free (dc->serialization); |
1918 | dc->serialization = NULL; | 1911 | dc->serialization = NULL; |
@@ -2026,7 +2019,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) | |||
2026 | goto cleanup; | 2019 | goto cleanup; |
2027 | } | 2020 | } |
2028 | if ( (NULL != sr->uri) && | 2021 | if ( (NULL != sr->uri) && |
2029 | (sr->sc->uri->type == ksk) && | 2022 | (ksk == sr->sc->uri->type) && |
2030 | (GNUNET_OK != GNUNET_BIO_write (wh, sr->keyword_bitmap, | 2023 | (GNUNET_OK != GNUNET_BIO_write (wh, sr->keyword_bitmap, |
2031 | (sr->sc->uri->data.ksk.keywordCount + 7) / 8)) ) | 2024 | (sr->sc->uri->data.ksk.keywordCount + 7) / 8)) ) |
2032 | { | 2025 | { |
@@ -2046,9 +2039,9 @@ cleanup: | |||
2046 | if (NULL != wh) | 2039 | if (NULL != wh) |
2047 | (void) GNUNET_BIO_write_close (wh); | 2040 | (void) GNUNET_BIO_write_close (wh); |
2048 | remove_sync_file_in_dir (sr->sc->h, | 2041 | remove_sync_file_in_dir (sr->sc->h, |
2049 | (sr->sc->psearch_result == | 2042 | (NULL == sr->sc->psearch_result) |
2050 | NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : | 2043 | ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH |
2051 | GNUNET_FS_SYNC_PATH_CHILD_SEARCH, | 2044 | : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, |
2052 | sr->sc->serialization, sr->serialization); | 2045 | sr->sc->serialization, sr->serialization); |
2053 | GNUNET_free (sr->serialization); | 2046 | GNUNET_free (sr->serialization); |
2054 | sr->serialization = NULL; | 2047 | sr->serialization = NULL; |
@@ -2072,16 +2065,16 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) | |||
2072 | const char *category; | 2065 | const char *category; |
2073 | 2066 | ||
2074 | category = | 2067 | category = |
2075 | (sc->psearch_result == | 2068 | (NULL == sc->psearch_result) |
2076 | NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : | 2069 | ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH |
2077 | GNUNET_FS_SYNC_PATH_CHILD_SEARCH; | 2070 | : GNUNET_FS_SYNC_PATH_CHILD_SEARCH; |
2078 | if (NULL == sc->serialization) | 2071 | if (NULL == sc->serialization) |
2079 | sc->serialization = make_serialization_file_name (sc->h, category); | 2072 | sc->serialization = make_serialization_file_name (sc->h, category); |
2080 | if (NULL == sc->serialization) | 2073 | if (NULL == sc->serialization) |
2081 | return; | 2074 | return; |
2082 | uris = NULL; | 2075 | uris = NULL; |
2083 | wh = get_write_handle (sc->h, category, sc->serialization); | 2076 | wh = get_write_handle (sc->h, category, sc->serialization); |
2084 | if (wh == NULL) | 2077 | if (NULL == wh) |
2085 | { | 2078 | { |
2086 | GNUNET_break (0); | 2079 | GNUNET_break (0); |
2087 | goto cleanup; | 2080 | goto cleanup; |
@@ -2110,7 +2103,7 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) | |||
2110 | } | 2103 | } |
2111 | return; | 2104 | return; |
2112 | cleanup: | 2105 | cleanup: |
2113 | if (wh != NULL) | 2106 | if (NULL != wh) |
2114 | (void) GNUNET_BIO_write_close (wh); | 2107 | (void) GNUNET_BIO_write_close (wh); |
2115 | GNUNET_free_non_null (uris); | 2108 | GNUNET_free_non_null (uris); |
2116 | GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization); | 2109 | GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization); |
@@ -2142,7 +2135,7 @@ deserialize_unindex_file (void *cls, const char *filename) | |||
2142 | uc->h = h; | 2135 | uc->h = h; |
2143 | uc->serialization = get_serialization_short_name (filename); | 2136 | uc->serialization = get_serialization_short_name (filename); |
2144 | rh = GNUNET_BIO_read_open (filename); | 2137 | rh = GNUNET_BIO_read_open (filename); |
2145 | if (rh == NULL) | 2138 | if (NULL == rh) |
2146 | { | 2139 | { |
2147 | GNUNET_break (0); | 2140 | GNUNET_break (0); |
2148 | goto cleanup; | 2141 | goto cleanup; |
@@ -2254,14 +2247,14 @@ deserialize_unindex_file (void *cls, const char *filename) | |||
2254 | return GNUNET_OK; | 2247 | return GNUNET_OK; |
2255 | cleanup: | 2248 | cleanup: |
2256 | GNUNET_free_non_null (uc->filename); | 2249 | GNUNET_free_non_null (uc->filename); |
2257 | if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) | 2250 | if ((NULL != rh) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) |
2258 | { | 2251 | { |
2259 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2252 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2260 | _("Failed to resume unindexing operation `%s': %s\n"), filename, | 2253 | _("Failed to resume unindexing operation `%s': %s\n"), filename, |
2261 | emsg); | 2254 | emsg); |
2262 | GNUNET_free (emsg); | 2255 | GNUNET_free (emsg); |
2263 | } | 2256 | } |
2264 | if (uc->serialization != NULL) | 2257 | if (NULL != uc->serialization) |
2265 | GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, | 2258 | GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, |
2266 | uc->serialization); | 2259 | uc->serialization); |
2267 | GNUNET_free_non_null (uc->serialization); | 2260 | GNUNET_free_non_null (uc->serialization); |
@@ -2325,14 +2318,14 @@ deserialize_search_result (void *cls, const char *filename) | |||
2325 | 2318 | ||
2326 | ser = get_serialization_short_name (filename); | 2319 | ser = get_serialization_short_name (filename); |
2327 | rh = GNUNET_BIO_read_open (filename); | 2320 | rh = GNUNET_BIO_read_open (filename); |
2328 | if (rh == NULL) | 2321 | if (NULL == rh) |
2329 | { | 2322 | { |
2330 | if (ser != NULL) | 2323 | if (NULL != ser) |
2331 | { | 2324 | { |
2332 | remove_sync_file_in_dir (sc->h, | 2325 | remove_sync_file_in_dir (sc->h, |
2333 | (sc->psearch_result == | 2326 | (NULL == sc->psearch_result) |
2334 | NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : | 2327 | ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH |
2335 | GNUNET_FS_SYNC_PATH_CHILD_SEARCH, | 2328 | : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, |
2336 | sc->serialization, ser); | 2329 | sc->serialization, ser); |
2337 | GNUNET_free (ser); | 2330 | GNUNET_free (ser); |
2338 | } | 2331 | } |
@@ -2361,7 +2354,7 @@ deserialize_search_result (void *cls, const char *filename) | |||
2361 | GNUNET_break (0); | 2354 | GNUNET_break (0); |
2362 | goto cleanup; | 2355 | goto cleanup; |
2363 | } | 2356 | } |
2364 | if (sr->sc->uri->type == ksk) | 2357 | if (ksk == sr->sc->uri->type) |
2365 | { | 2358 | { |
2366 | sr->keyword_bitmap = GNUNET_malloc ((sr->sc->uri->data.ksk.keywordCount + 7) / 8); /* round up, count bits */ | 2359 | sr->keyword_bitmap = GNUNET_malloc ((sr->sc->uri->data.ksk.keywordCount + 7) / 8); /* round up, count bits */ |
2367 | if (GNUNET_OK != GNUNET_BIO_read (rh, "keyword-bitmap", | 2360 | if (GNUNET_OK != GNUNET_BIO_read (rh, "keyword-bitmap", |
@@ -2373,10 +2366,10 @@ deserialize_search_result (void *cls, const char *filename) | |||
2373 | } | 2366 | } |
2374 | } | 2367 | } |
2375 | GNUNET_free (uris); | 2368 | GNUNET_free (uris); |
2376 | if (download != NULL) | 2369 | if (NULL != download) |
2377 | { | 2370 | { |
2378 | drh = get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, download); | 2371 | drh = get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, download); |
2379 | if (drh != NULL) | 2372 | if (NULL != drh) |
2380 | { | 2373 | { |
2381 | deserialize_download (sc->h, drh, NULL, sr, download); | 2374 | deserialize_download (sc->h, drh, NULL, sr, download); |
2382 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) | 2375 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) |
@@ -2389,11 +2382,11 @@ deserialize_search_result (void *cls, const char *filename) | |||
2389 | } | 2382 | } |
2390 | GNUNET_free (download); | 2383 | GNUNET_free (download); |
2391 | } | 2384 | } |
2392 | if (update_srch != NULL) | 2385 | if (NULL != update_srch) |
2393 | { | 2386 | { |
2394 | drh = | 2387 | drh = |
2395 | get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch); | 2388 | get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch); |
2396 | if (drh != NULL) | 2389 | if (NULL != drh) |
2397 | { | 2390 | { |
2398 | deserialize_search (sc->h, drh, sr, update_srch); | 2391 | deserialize_search (sc->h, drh, sr, update_srch); |
2399 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) | 2392 | if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) |
@@ -2406,8 +2399,9 @@ deserialize_search_result (void *cls, const char *filename) | |||
2406 | } | 2399 | } |
2407 | GNUNET_free (update_srch); | 2400 | GNUNET_free (update_srch); |
2408 | } | 2401 | } |
2409 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &sr->key, sr, | 2402 | GNUNET_break (GNUNET_YES == |
2410 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2403 | GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &sr->key, sr, |
2404 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
2411 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) | 2405 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) |
2412 | { | 2406 | { |
2413 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2407 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -2421,9 +2415,9 @@ cleanup: | |||
2421 | GNUNET_free_non_null (emsg); | 2415 | GNUNET_free_non_null (emsg); |
2422 | GNUNET_free_non_null (uris); | 2416 | GNUNET_free_non_null (uris); |
2423 | GNUNET_free_non_null (update_srch); | 2417 | GNUNET_free_non_null (update_srch); |
2424 | if (sr->uri != NULL) | 2418 | if (NULL != sr->uri) |
2425 | GNUNET_FS_uri_destroy (sr->uri); | 2419 | GNUNET_FS_uri_destroy (sr->uri); |
2426 | if (sr->meta != NULL) | 2420 | if (NULL != sr->meta) |
2427 | GNUNET_CONTAINER_meta_data_destroy (sr->meta); | 2421 | GNUNET_CONTAINER_meta_data_destroy (sr->meta); |
2428 | GNUNET_free (sr->serialization); | 2422 | GNUNET_free (sr->serialization); |
2429 | GNUNET_free (sr); | 2423 | GNUNET_free (sr); |
@@ -2462,7 +2456,7 @@ signal_download_resume (struct GNUNET_FS_DownloadContext *dc) | |||
2462 | signal_download_resume (dcc); | 2456 | signal_download_resume (dcc); |
2463 | dcc = dcc->next; | 2457 | dcc = dcc->next; |
2464 | } | 2458 | } |
2465 | if (dc->pending_head != NULL) | 2459 | if (NULL != dc->pending_head) |
2466 | GNUNET_FS_download_start_downloading_ (dc); | 2460 | GNUNET_FS_download_start_downloading_ (dc); |
2467 | } | 2461 | } |
2468 | 2462 | ||
@@ -2507,7 +2501,7 @@ signal_result_resume (void *cls, const struct GNUNET_HashCode * key, void *value | |||
2507 | sr->optional_support; | 2501 | sr->optional_support; |
2508 | sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc); | 2502 | sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc); |
2509 | } | 2503 | } |
2510 | if (sr->download != NULL) | 2504 | if (NULL != sr->download) |
2511 | { | 2505 | { |
2512 | signal_download_resume (sr->download); | 2506 | signal_download_resume (sr->download); |
2513 | } | 2507 | } |
@@ -2515,7 +2509,7 @@ signal_result_resume (void *cls, const struct GNUNET_HashCode * key, void *value | |||
2515 | { | 2509 | { |
2516 | GNUNET_FS_search_start_probe_ (sr); | 2510 | GNUNET_FS_search_start_probe_ (sr); |
2517 | } | 2511 | } |
2518 | if (sr->update_search != NULL) | 2512 | if (NULL != sr->update_search) |
2519 | signal_search_resume (sr->update_search); | 2513 | signal_search_resume (sr->update_search); |
2520 | return GNUNET_YES; | 2514 | return GNUNET_YES; |
2521 | } | 2515 | } |
@@ -2543,7 +2537,7 @@ free_result (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
2543 | { | 2537 | { |
2544 | struct GNUNET_FS_SearchResult *sr = value; | 2538 | struct GNUNET_FS_SearchResult *sr = value; |
2545 | 2539 | ||
2546 | if (sr->update_search != NULL) | 2540 | if (NULL != sr->update_search) |
2547 | { | 2541 | { |
2548 | free_search_context (sr->update_search); | 2542 | free_search_context (sr->update_search); |
2549 | GNUNET_assert (NULL == sr->update_search); | 2543 | GNUNET_assert (NULL == sr->update_search); |
@@ -2563,7 +2557,7 @@ free_result (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
2563 | static void | 2557 | static void |
2564 | free_search_context (struct GNUNET_FS_SearchContext *sc) | 2558 | free_search_context (struct GNUNET_FS_SearchContext *sc) |
2565 | { | 2559 | { |
2566 | if (sc->serialization != NULL) | 2560 | if (NULL != sc->serialization) |
2567 | { | 2561 | { |
2568 | GNUNET_FS_remove_sync_file_ (sc->h, | 2562 | GNUNET_FS_remove_sync_file_ (sc->h, |
2569 | (sc->psearch_result == | 2563 | (sc->psearch_result == |
@@ -2578,9 +2572,9 @@ free_search_context (struct GNUNET_FS_SearchContext *sc) | |||
2578 | } | 2572 | } |
2579 | GNUNET_free_non_null (sc->serialization); | 2573 | GNUNET_free_non_null (sc->serialization); |
2580 | GNUNET_free_non_null (sc->emsg); | 2574 | GNUNET_free_non_null (sc->emsg); |
2581 | if (sc->uri != NULL) | 2575 | if (NULL != sc->uri) |
2582 | GNUNET_FS_uri_destroy (sc->uri); | 2576 | GNUNET_FS_uri_destroy (sc->uri); |
2583 | if (sc->master_result_map != NULL) | 2577 | if (NULL != sc->master_result_map) |
2584 | { | 2578 | { |
2585 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, &free_result, | 2579 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, &free_result, |
2586 | sc); | 2580 | sc); |
@@ -2608,7 +2602,7 @@ deserialize_subdownload (void *cls, const char *filename) | |||
2608 | 2602 | ||
2609 | ser = get_serialization_short_name (filename); | 2603 | ser = get_serialization_short_name (filename); |
2610 | rh = GNUNET_BIO_read_open (filename); | 2604 | rh = GNUNET_BIO_read_open (filename); |
2611 | if (rh == NULL) | 2605 | if (NULL == rh) |
2612 | { | 2606 | { |
2613 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2607 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2614 | _ | 2608 | _ |
@@ -2641,9 +2635,9 @@ free_download_context (struct GNUNET_FS_DownloadContext *dc) | |||
2641 | { | 2635 | { |
2642 | struct GNUNET_FS_DownloadContext *dcc; | 2636 | struct GNUNET_FS_DownloadContext *dcc; |
2643 | 2637 | ||
2644 | if (dc->meta != NULL) | 2638 | if (NULL != dc->meta) |
2645 | GNUNET_CONTAINER_meta_data_destroy (dc->meta); | 2639 | GNUNET_CONTAINER_meta_data_destroy (dc->meta); |
2646 | if (dc->uri != NULL) | 2640 | if (NULL != dc->uri) |
2647 | GNUNET_FS_uri_destroy (dc->uri); | 2641 | GNUNET_FS_uri_destroy (dc->uri); |
2648 | GNUNET_free_non_null (dc->temp_filename); | 2642 | GNUNET_free_non_null (dc->temp_filename); |
2649 | GNUNET_free_non_null (dc->emsg); | 2643 | GNUNET_free_non_null (dc->emsg); |
@@ -2724,33 +2718,33 @@ deserialize_download (struct GNUNET_FS_Handle *h, | |||
2724 | if (GNUNET_FS_uri_test_loc (dc->uri)) | 2718 | if (GNUNET_FS_uri_test_loc (dc->uri)) |
2725 | GNUNET_assert (GNUNET_OK == | 2719 | GNUNET_assert (GNUNET_OK == |
2726 | GNUNET_FS_uri_loc_get_peer_identity (dc->uri, &dc->target)); | 2720 | GNUNET_FS_uri_loc_get_peer_identity (dc->uri, &dc->target)); |
2727 | if (dc->emsg == NULL) | 2721 | if (NULL == dc->emsg) |
2728 | { | 2722 | { |
2729 | dc->top_request = read_download_request (rh); | 2723 | dc->top_request = read_download_request (rh); |
2730 | if (dc->top_request == NULL) | 2724 | if (NULL == dc->top_request) |
2731 | { | 2725 | { |
2732 | GNUNET_break (0); | 2726 | GNUNET_break (0); |
2733 | goto cleanup; | 2727 | goto cleanup; |
2734 | } | 2728 | } |
2735 | } | 2729 | } |
2736 | dn = get_download_sync_filename (dc, dc->serialization, ".dir"); | 2730 | dn = get_download_sync_filename (dc, dc->serialization, ".dir"); |
2737 | if (dn != NULL) | 2731 | if (NULL != dn) |
2738 | { | 2732 | { |
2739 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn)) | 2733 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn)) |
2740 | GNUNET_DISK_directory_scan (dn, &deserialize_subdownload, dc); | 2734 | GNUNET_DISK_directory_scan (dn, &deserialize_subdownload, dc); |
2741 | GNUNET_free (dn); | 2735 | GNUNET_free (dn); |
2742 | } | 2736 | } |
2743 | if (parent != NULL) | 2737 | if (NULL != parent) |
2744 | { | 2738 | { |
2745 | GNUNET_abort (); // for debugging for now - FIXME | 2739 | GNUNET_abort (); // for debugging for now - FIXME |
2746 | GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc); | 2740 | GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc); |
2747 | } | 2741 | } |
2748 | if (search != NULL) | 2742 | if (NULL != search) |
2749 | { | 2743 | { |
2750 | dc->search = search; | 2744 | dc->search = search; |
2751 | search->download = dc; | 2745 | search->download = dc; |
2752 | } | 2746 | } |
2753 | if ((parent == NULL) && (search == NULL)) | 2747 | if ((NULL == parent) && (NULL == search)) |
2754 | { | 2748 | { |
2755 | dc->top = | 2749 | dc->top = |
2756 | GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc); | 2750 | GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc); |
@@ -2780,7 +2774,7 @@ signal_search_resume (struct GNUNET_FS_SearchContext *sc) | |||
2780 | pi.status = GNUNET_FS_STATUS_SEARCH_RESUME; | 2774 | pi.status = GNUNET_FS_STATUS_SEARCH_RESUME; |
2781 | pi.value.search.specifics.resume.message = sc->emsg; | 2775 | pi.value.search.specifics.resume.message = sc->emsg; |
2782 | pi.value.search.specifics.resume.is_paused = | 2776 | pi.value.search.specifics.resume.is_paused = |
2783 | (sc->client == NULL) ? GNUNET_YES : GNUNET_NO; | 2777 | (NULL == sc->client) ? GNUNET_YES : GNUNET_NO; |
2784 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); | 2778 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); |
2785 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | 2779 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, |
2786 | &signal_result_resume, sc); | 2780 | &signal_result_resume, sc); |
@@ -2809,7 +2803,7 @@ deserialize_search (struct GNUNET_FS_Handle *h, | |||
2809 | uint32_t options; | 2803 | uint32_t options; |
2810 | char in_pause; | 2804 | char in_pause; |
2811 | 2805 | ||
2812 | if ((psearch_result != NULL) && (psearch_result->update_search != NULL)) | 2806 | if ((NULL != psearch_result) && (NULL != psearch_result->update_search)) |
2813 | { | 2807 | { |
2814 | GNUNET_break (0); | 2808 | GNUNET_break (0); |
2815 | return NULL; | 2809 | return NULL; |
@@ -2817,7 +2811,7 @@ deserialize_search (struct GNUNET_FS_Handle *h, | |||
2817 | uris = NULL; | 2811 | uris = NULL; |
2818 | emsg = NULL; | 2812 | emsg = NULL; |
2819 | sc = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchContext)); | 2813 | sc = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchContext)); |
2820 | if (psearch_result != NULL) | 2814 | if (NULL != psearch_result) |
2821 | { | 2815 | { |
2822 | sc->psearch_result = psearch_result; | 2816 | sc->psearch_result = psearch_result; |
2823 | psearch_result->update_search = sc; | 2817 | psearch_result->update_search = sc; |
@@ -2847,7 +2841,7 @@ deserialize_search (struct GNUNET_FS_Handle *h, | |||
2847 | GNUNET_FS_SYNC_PATH_MASTER_SEARCH : | 2841 | GNUNET_FS_SYNC_PATH_MASTER_SEARCH : |
2848 | GNUNET_FS_SYNC_PATH_CHILD_SEARCH, | 2842 | GNUNET_FS_SYNC_PATH_CHILD_SEARCH, |
2849 | sc->serialization, ""); | 2843 | sc->serialization, ""); |
2850 | if (dn != NULL) | 2844 | if (NULL != dn) |
2851 | { | 2845 | { |
2852 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn)) | 2846 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn)) |
2853 | GNUNET_DISK_directory_scan (dn, &deserialize_search_result, sc); | 2847 | GNUNET_DISK_directory_scan (dn, &deserialize_search_result, sc); |
@@ -2898,9 +2892,9 @@ deserialize_search_file (void *cls, const char *filename) | |||
2898 | return GNUNET_OK; /* skip directories */ | 2892 | return GNUNET_OK; /* skip directories */ |
2899 | ser = get_serialization_short_name (filename); | 2893 | ser = get_serialization_short_name (filename); |
2900 | rh = GNUNET_BIO_read_open (filename); | 2894 | rh = GNUNET_BIO_read_open (filename); |
2901 | if (rh == NULL) | 2895 | if (NULL == rh) |
2902 | { | 2896 | { |
2903 | if (ser != NULL) | 2897 | if (NULL != ser) |
2904 | { | 2898 | { |
2905 | GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, ser); | 2899 | GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, ser); |
2906 | GNUNET_free (ser); | 2900 | GNUNET_free (ser); |
@@ -2908,7 +2902,7 @@ deserialize_search_file (void *cls, const char *filename) | |||
2908 | return GNUNET_OK; | 2902 | return GNUNET_OK; |
2909 | } | 2903 | } |
2910 | sc = deserialize_search (h, rh, NULL, ser); | 2904 | sc = deserialize_search (h, rh, NULL, ser); |
2911 | if (sc != NULL) | 2905 | if (NULL != sc) |
2912 | sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc); | 2906 | sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc); |
2913 | GNUNET_free (ser); | 2907 | GNUNET_free (ser); |
2914 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) | 2908 | if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) |
@@ -2940,7 +2934,7 @@ deserialize_download_file (void *cls, const char *filename) | |||
2940 | 2934 | ||
2941 | ser = get_serialization_short_name (filename); | 2935 | ser = get_serialization_short_name (filename); |
2942 | rh = GNUNET_BIO_read_open (filename); | 2936 | rh = GNUNET_BIO_read_open (filename); |
2943 | if (rh == NULL) | 2937 | if (NULL == rh) |
2944 | { | 2938 | { |
2945 | if (0 != UNLINK (filename)) | 2939 | if (0 != UNLINK (filename)) |
2946 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); | 2940 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); |
@@ -2974,7 +2968,7 @@ deserialization_master (const char *master_path, GNUNET_FileNameCallback proc, | |||
2974 | char *dn; | 2968 | char *dn; |
2975 | 2969 | ||
2976 | dn = get_serialization_file_name (h, master_path, ""); | 2970 | dn = get_serialization_file_name (h, master_path, ""); |
2977 | if (dn == NULL) | 2971 | if (NULL == dn) |
2978 | return; | 2972 | return; |
2979 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn)) | 2973 | if (GNUNET_YES == GNUNET_DISK_directory_test (dn)) |
2980 | GNUNET_DISK_directory_scan (dn, proc, h); | 2974 | GNUNET_DISK_directory_scan (dn, proc, h); |