diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-05-27 13:32:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-05-27 13:32:13 +0000 |
commit | fdc0057520fed26405a2ee9d078ed4eea1884e8c (patch) | |
tree | b6ab443a28b609bd29f89bf1c1be5ce5d86ab2e0 /src/fs | |
parent | 994d3b094b5c426561d4a8c4061a78a47be86446 (diff) | |
download | gnunet-fdc0057520fed26405a2ee9d078ed4eea1884e8c.tar.gz gnunet-fdc0057520fed26405a2ee9d078ed4eea1884e8c.zip |
check DATASTORE return values
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 176 |
1 files changed, 101 insertions, 75 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 7c1138356..74d2ad56e 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -578,16 +578,31 @@ clean_request (void *cls, | |||
578 | GSF_plan_notify_request_done_ (pr); | 578 | GSF_plan_notify_request_done_ (pr); |
579 | GNUNET_free_non_null (pr->replies_seen); | 579 | GNUNET_free_non_null (pr->replies_seen); |
580 | if (NULL != pr->bf) | 580 | if (NULL != pr->bf) |
581 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); | 581 | { |
582 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); | ||
583 | pr->bf = NULL; | ||
584 | } | ||
582 | GNUNET_PEER_change_rc (pr->sender_pid, -1); | 585 | GNUNET_PEER_change_rc (pr->sender_pid, -1); |
583 | if (NULL != pr->hnode) | 586 | if (NULL != pr->hnode) |
584 | GNUNET_CONTAINER_heap_remove_node (pr->hnode); | 587 | { |
588 | GNUNET_CONTAINER_heap_remove_node (pr->hnode); | ||
589 | pr->hnode = NULL; | ||
590 | } | ||
585 | if (NULL != pr->qe) | 591 | if (NULL != pr->qe) |
586 | GNUNET_DATASTORE_cancel (pr->qe); | 592 | { |
593 | GNUNET_DATASTORE_cancel (pr->qe); | ||
594 | pr->qe = NULL; | ||
595 | } | ||
587 | if (NULL != pr->gh) | 596 | if (NULL != pr->gh) |
588 | GNUNET_DHT_get_stop (pr->gh); | 597 | { |
598 | GNUNET_DHT_get_stop (pr->gh); | ||
599 | pr->gh = NULL; | ||
600 | } | ||
589 | if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task) | 601 | if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task) |
590 | GNUNET_SCHEDULER_cancel (pr->warn_task); | 602 | { |
603 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
604 | pr->warn_task = GNUNET_SCHEDULER_NO_TASK; | ||
605 | } | ||
591 | GNUNET_free (pr); | 606 | GNUNET_free (pr); |
592 | return GNUNET_YES; | 607 | return GNUNET_YES; |
593 | } | 608 | } |
@@ -970,15 +985,19 @@ handle_dht_reply (void *cls, | |||
970 | pmc = GNUNET_malloc (sizeof (struct PutMigrationContext)); | 985 | pmc = GNUNET_malloc (sizeof (struct PutMigrationContext)); |
971 | pmc->start = GNUNET_TIME_absolute_get (); | 986 | pmc->start = GNUNET_TIME_absolute_get (); |
972 | pmc->requested = GNUNET_YES; | 987 | pmc->requested = GNUNET_YES; |
973 | GNUNET_DATASTORE_put (GSF_dsh, | 988 | if (NULL == |
974 | 0, key, size, data, | 989 | GNUNET_DATASTORE_put (GSF_dsh, |
975 | type, prq.priority, 1 /* anonymity */, | 990 | 0, key, size, data, |
976 | 0 /* replication */, | 991 | type, prq.priority, 1 /* anonymity */, |
977 | exp, | 992 | 0 /* replication */, |
978 | 1 + prq.priority, MAX_DATASTORE_QUEUE, | 993 | exp, |
979 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 994 | 1 + prq.priority, MAX_DATASTORE_QUEUE, |
980 | &put_migration_continuation, | 995 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
981 | pmc); | 996 | &put_migration_continuation, |
997 | pmc)) | ||
998 | { | ||
999 | put_migration_continuation (pmc, GNUNET_NO, NULL); | ||
1000 | } | ||
982 | } | 1001 | } |
983 | } | 1002 | } |
984 | 1003 | ||
@@ -1127,14 +1146,7 @@ process_local_reply (void *cls, | |||
1127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1128 | "No further local responses available.\n"); | 1147 | "No further local responses available.\n"); |
1129 | #endif | 1148 | #endif |
1130 | if (NULL != (cont = pr->llc_cont)) | 1149 | goto check_error_and_continue; |
1131 | { | ||
1132 | pr->llc_cont = NULL; | ||
1133 | cont (pr->llc_cont_cls, | ||
1134 | pr, | ||
1135 | pr->local_result); | ||
1136 | } | ||
1137 | return; | ||
1138 | } | 1150 | } |
1139 | #if DEBUG_FS | 1151 | #if DEBUG_FS |
1140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1157,34 +1169,34 @@ process_local_reply (void *cls, | |||
1157 | pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 1169 | pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
1158 | &odc_warn_delay_task, | 1170 | &odc_warn_delay_task, |
1159 | pr); | 1171 | pr); |
1160 | if (GNUNET_OK != | 1172 | if (GNUNET_OK == |
1161 | GNUNET_FS_handle_on_demand_block (key, size, data, type, priority, | 1173 | GNUNET_FS_handle_on_demand_block (key, size, data, type, priority, |
1162 | anonymity, expiration, uid, | 1174 | anonymity, expiration, uid, |
1163 | &process_local_reply, | 1175 | &process_local_reply, |
1164 | pr)) | 1176 | pr)) |
1165 | { | 1177 | return; /* we're done */ |
1166 | GNUNET_SCHEDULER_cancel (pr->warn_task); | 1178 | GNUNET_SCHEDULER_cancel (pr->warn_task); |
1167 | pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 1179 | pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
1168 | &warn_delay_task, | 1180 | &warn_delay_task, |
1169 | pr); | 1181 | pr); |
1170 | pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, | 1182 | pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, |
1171 | pr->local_result_offset - 1, | 1183 | pr->local_result_offset - 1, |
1172 | &pr->public_data.query, | 1184 | &pr->public_data.query, |
1173 | pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK | 1185 | pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK |
1174 | ? GNUNET_BLOCK_TYPE_ANY | 1186 | ? GNUNET_BLOCK_TYPE_ANY |
1175 | : pr->public_data.type, | 1187 | : pr->public_data.type, |
1176 | (0 != (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) | 1188 | (0 != (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) |
1177 | ? UINT_MAX | 1189 | ? UINT_MAX |
1178 | : 1 /* queue priority */, | 1190 | : 1 /* queue priority */, |
1179 | (0 != (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) | 1191 | (0 != (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) |
1180 | ? UINT_MAX | 1192 | ? UINT_MAX |
1181 | : 1 /* max queue size */, | 1193 | : 1 /* max queue size */, |
1182 | GNUNET_TIME_UNIT_FOREVER_REL, | 1194 | GNUNET_TIME_UNIT_FOREVER_REL, |
1183 | &process_local_reply, | 1195 | &process_local_reply, |
1184 | pr); | 1196 | pr); |
1185 | GNUNET_assert (NULL != pr->qe); | 1197 | if (NULL != pr->qe) |
1186 | } | 1198 | return; /* we're done */ |
1187 | return; | 1199 | goto check_error_and_continue; |
1188 | } | 1200 | } |
1189 | old_rf = pr->public_data.results_found; | 1201 | old_rf = pr->public_data.results_found; |
1190 | memset (&prq, 0, sizeof (prq)); | 1202 | memset (&prq, 0, sizeof (prq)); |
@@ -1224,7 +1236,10 @@ process_local_reply (void *cls, | |||
1224 | GNUNET_TIME_UNIT_FOREVER_REL, | 1236 | GNUNET_TIME_UNIT_FOREVER_REL, |
1225 | &process_local_reply, | 1237 | &process_local_reply, |
1226 | pr); | 1238 | pr); |
1227 | GNUNET_assert (NULL != pr->qe); | 1239 | if (pr->qe == NULL) |
1240 | { | ||
1241 | goto check_error_and_continue; | ||
1242 | } | ||
1228 | return; | 1243 | return; |
1229 | } | 1244 | } |
1230 | prq.type = type; | 1245 | prq.type = type; |
@@ -1237,16 +1252,7 @@ process_local_reply (void *cls, | |||
1237 | process_reply (&prq, key, pr); | 1252 | process_reply (&prq, key, pr); |
1238 | pr->local_result = prq.eval; | 1253 | pr->local_result = prq.eval; |
1239 | if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST) | 1254 | if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST) |
1240 | { | 1255 | goto check_error_and_continue; |
1241 | if (NULL != (cont = pr->llc_cont)) | ||
1242 | { | ||
1243 | pr->llc_cont = NULL; | ||
1244 | cont (pr->llc_cont_cls, | ||
1245 | pr, | ||
1246 | pr->local_result); | ||
1247 | } | ||
1248 | return; | ||
1249 | } | ||
1250 | if ( (0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) && | 1256 | if ( (0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) && |
1251 | ( (GNUNET_YES == GSF_test_get_load_too_high_ (0)) || | 1257 | ( (GNUNET_YES == GSF_test_get_load_too_high_ (0)) || |
1252 | (pr->public_data.results_found > 5 + 2 * pr->public_data.priority) ) ) | 1258 | (pr->public_data.results_found > 5 + 2 * pr->public_data.priority) ) ) |
@@ -1259,14 +1265,7 @@ process_local_reply (void *cls, | |||
1259 | gettext_noop ("# processing result set cut short due to load"), | 1265 | gettext_noop ("# processing result set cut short due to load"), |
1260 | 1, | 1266 | 1, |
1261 | GNUNET_NO); | 1267 | GNUNET_NO); |
1262 | if (NULL != (cont = pr->llc_cont)) | 1268 | goto check_error_and_continue; |
1263 | { | ||
1264 | pr->llc_cont = NULL; | ||
1265 | cont (pr->llc_cont_cls, | ||
1266 | pr, | ||
1267 | pr->local_result); | ||
1268 | } | ||
1269 | return; | ||
1270 | } | 1269 | } |
1271 | pr->qe_start = GNUNET_TIME_absolute_get (); | 1270 | pr->qe_start = GNUNET_TIME_absolute_get (); |
1272 | pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 1271 | pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
@@ -1287,7 +1286,23 @@ process_local_reply (void *cls, | |||
1287 | GNUNET_TIME_UNIT_FOREVER_REL, | 1286 | GNUNET_TIME_UNIT_FOREVER_REL, |
1288 | &process_local_reply, | 1287 | &process_local_reply, |
1289 | pr); | 1288 | pr); |
1290 | GNUNET_assert (NULL != pr->qe); | 1289 | /* check if we successfully queued another datastore request; |
1290 | if so, return, otherwise call our continuation (if we have | ||
1291 | any) */ | ||
1292 | check_error_and_continue: | ||
1293 | if (NULL != pr->qe) | ||
1294 | return; | ||
1295 | if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task) | ||
1296 | { | ||
1297 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
1298 | pr->warn_task = GNUNET_SCHEDULER_NO_TASK; | ||
1299 | } | ||
1300 | if (NULL == (cont = pr->llc_cont)) | ||
1301 | return; /* no continuation */ | ||
1302 | pr->llc_cont = NULL; | ||
1303 | cont (pr->llc_cont_cls, | ||
1304 | pr, | ||
1305 | pr->local_result); | ||
1291 | } | 1306 | } |
1292 | 1307 | ||
1293 | 1308 | ||
@@ -1326,6 +1341,13 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr, | |||
1326 | GNUNET_TIME_UNIT_FOREVER_REL, | 1341 | GNUNET_TIME_UNIT_FOREVER_REL, |
1327 | &process_local_reply, | 1342 | &process_local_reply, |
1328 | pr); | 1343 | pr); |
1344 | if (NULL != pr->qe) | ||
1345 | return; | ||
1346 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
1347 | pr->warn_task = GNUNET_SCHEDULER_NO_TASK; | ||
1348 | pr->llc_cont = NULL; | ||
1349 | if (NULL != cont) | ||
1350 | cont (cont_cls, pr, pr->local_result); | ||
1329 | } | 1351 | } |
1330 | 1352 | ||
1331 | 1353 | ||
@@ -1415,15 +1437,19 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, | |||
1415 | pmc->requested = prq.request_found; | 1437 | pmc->requested = prq.request_found; |
1416 | GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid, | 1438 | GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid, |
1417 | &pmc->origin); | 1439 | &pmc->origin); |
1418 | GNUNET_DATASTORE_put (GSF_dsh, | 1440 | if (NULL == |
1419 | 0, &query, dsize, &put[1], | 1441 | GNUNET_DATASTORE_put (GSF_dsh, |
1420 | type, prq.priority, 1 /* anonymity */, | 1442 | 0, &query, dsize, &put[1], |
1421 | 0 /* replication */, | 1443 | type, prq.priority, 1 /* anonymity */, |
1422 | expiration, | 1444 | 0 /* replication */, |
1423 | 1 + prq.priority, MAX_DATASTORE_QUEUE, | 1445 | expiration, |
1424 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1446 | 1 + prq.priority, MAX_DATASTORE_QUEUE, |
1425 | &put_migration_continuation, | 1447 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
1426 | pmc); | 1448 | &put_migration_continuation, |
1449 | pmc)) | ||
1450 | { | ||
1451 | put_migration_continuation (pmc, GNUNET_NO, NULL); | ||
1452 | } | ||
1427 | } | 1453 | } |
1428 | else | 1454 | else |
1429 | { | 1455 | { |