aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-12 18:16:00 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 10:01:24 +0200
commit7a923f1b2d38d55ca921abb57980ccfd1340f634 (patch)
treeeee6c6ee633d6343cf8ac5f7394344f29c64c4ce /src/reclaim/gnunet-service-reclaim.c
parentdfe11b6b541b47c85cdf56e55ebb816d6793db31 (diff)
downloadgnunet-7a923f1b2d38d55ca921abb57980ccfd1340f634.tar.gz
gnunet-7a923f1b2d38d55ca921abb57980ccfd1340f634.zip
RECLAIM: Refactoring
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim.c410
1 files changed, 63 insertions, 347 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 634de0dfe..c8ae8a238 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -30,8 +30,6 @@
30#include "gnunet_identity_service.h" 30#include "gnunet_identity_service.h"
31#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
32#include "gnunet_namestore_service.h" 32#include "gnunet_namestore_service.h"
33#include "gnunet_statistics_service.h"
34#include "gnunet_gns_service.h"
35#include "gnunet_reclaim_plugin.h" 33#include "gnunet_reclaim_plugin.h"
36#include "gnunet_reclaim_attribute_lib.h" 34#include "gnunet_reclaim_attribute_lib.h"
37#include "gnunet_signatures.h" 35#include "gnunet_signatures.h"
@@ -84,11 +82,6 @@ static struct GNUNET_TIME_Relative token_expiration_interval;
84static struct GNUNET_NAMESTORE_Handle *nsh; 82static struct GNUNET_NAMESTORE_Handle *nsh;
85 83
86/** 84/**
87 * GNS handle
88 */
89static struct GNUNET_GNS_Handle *gns_handle;
90
91/**
92 * Timeout task 85 * Timeout task
93 */ 86 */
94static struct GNUNET_SCHEDULER_Task *timeout_task; 87static struct GNUNET_SCHEDULER_Task *timeout_task;
@@ -100,11 +93,6 @@ static struct GNUNET_SCHEDULER_Task *update_task;
100 93
101 94
102/** 95/**
103 * Handle to the statistics service.
104 */
105static struct GNUNET_STATISTICS_Handle *stats;
106
107/**
108 * Our configuration. 96 * Our configuration.
109 */ 97 */
110static const struct GNUNET_CONFIGURATION_Handle *cfg; 98static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -248,12 +236,12 @@ struct IdpClient
248 /** 236 /**
249 * Head of DLL of ticket consume ops 237 * Head of DLL of ticket consume ops
250 */ 238 */
251 struct ConsumeTicketHandle *consume_op_head; 239 struct ConsumeTicketOperation *consume_op_head;
252 240
253 /** 241 /**
254 * Tail of DLL of ticket consume ops 242 * Tail of DLL of ticket consume ops
255 */ 243 */
256 struct ConsumeTicketHandle *consume_op_tail; 244 struct ConsumeTicketOperation *consume_op_tail;
257 245
258 /** 246 /**
259 * Head of DLL of attribute store ops 247 * Head of DLL of attribute store ops
@@ -316,20 +304,17 @@ struct AttributeStoreHandle
316}; 304};
317 305
318 306
319/* Prototype */ 307struct ConsumeTicketOperation
320struct ParallelLookup;
321
322struct ConsumeTicketHandle
323{ 308{
324 /** 309 /**
325 * DLL 310 * DLL
326 */ 311 */
327 struct ConsumeTicketHandle *next; 312 struct ConsumeTicketOperation *next;
328 313
329 /** 314 /**
330 * DLL 315 * DLL
331 */ 316 */
332 struct ConsumeTicketHandle *prev; 317 struct ConsumeTicketOperation *prev;
333 318
334 /** 319 /**
335 * Client connection 320 * Client connection
@@ -337,82 +322,17 @@ struct ConsumeTicketHandle
337 struct IdpClient *client; 322 struct IdpClient *client;
338 323
339 /** 324 /**
340 * Ticket
341 */
342 struct GNUNET_RECLAIM_Ticket ticket;
343
344 /**
345 * LookupRequest
346 */
347 struct GNUNET_GNS_LookupRequest *lookup_request;
348
349 /**
350 * Audience Key
351 */
352 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
353
354 /**
355 * Audience Key
356 */
357 struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub;
358
359 /**
360 * Lookup DLL
361 */
362 struct ParallelLookup *parallel_lookups_head;
363
364 /**
365 * Lookup DLL
366 */
367 struct ParallelLookup *parallel_lookups_tail;
368
369 /**
370 * Kill task
371 */
372 struct GNUNET_SCHEDULER_Task *kill_task;
373
374 /**
375 * Attributes
376 */
377 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
378
379 /**
380 * Lookup time
381 */
382 struct GNUNET_TIME_Absolute lookup_start_time;
383
384 /**
385 * request id 325 * request id
386 */ 326 */
387 uint32_t r_id; 327 uint32_t r_id;
388};
389
390/**
391 * Handle for a parallel GNS lookup job
392 */
393struct ParallelLookup
394{
395 /* DLL */
396 struct ParallelLookup *next;
397
398 /* DLL */
399 struct ParallelLookup *prev;
400
401 /* The GNS request */
402 struct GNUNET_GNS_LookupRequest *lookup_request;
403
404 /* The handle the return to */
405 struct ConsumeTicketHandle *handle;
406 328
407 /** 329 /**
408 * Lookup time 330 * Ticket consume handle
409 */ 331 */
410 struct GNUNET_TIME_Absolute lookup_start_time; 332 struct RECLAIM_TICKETS_ConsumeHandle *ch;
411
412 /* The label to look up */
413 char *label;
414}; 333};
415 334
335
416/** 336/**
417 * Updated attribute IDs 337 * Updated attribute IDs
418 */ 338 */
@@ -578,11 +498,6 @@ cleanup()
578 "Cleaning up\n"); 498 "Cleaning up\n");
579 499
580 RECLAIM_TICKETS_deinit (); 500 RECLAIM_TICKETS_deinit ();
581 if (NULL != stats)
582 {
583 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
584 stats = NULL;
585 }
586 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, 501 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name,
587 TKT_database)); 502 TKT_database));
588 GNUNET_free (db_lib_name); 503 GNUNET_free (db_lib_name);
@@ -593,8 +508,6 @@ cleanup()
593 GNUNET_SCHEDULER_cancel (update_task); 508 GNUNET_SCHEDULER_cancel (update_task);
594 if (NULL != identity_handle) 509 if (NULL != identity_handle)
595 GNUNET_IDENTITY_disconnect (identity_handle); 510 GNUNET_IDENTITY_disconnect (identity_handle);
596 if (NULL != gns_handle)
597 GNUNET_GNS_disconnect (gns_handle);
598 if (NULL != nsh) 511 if (NULL != nsh)
599 GNUNET_NAMESTORE_disconnect (nsh); 512 GNUNET_NAMESTORE_disconnect (nsh);
600} 513}
@@ -729,11 +642,11 @@ handle_issue_ticket_message (void *cls,
729 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, 642 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head,
730 idp->issue_op_tail, 643 idp->issue_op_tail,
731 tio); 644 tio);
732 RECLAIM_TICKETS_issue_ticket (&im->identity, 645 RECLAIM_TICKETS_issue (&im->identity,
733 attrs, 646 attrs,
734 &im->rp, 647 &im->rp,
735 &issue_ticket_result_cb, 648 &issue_ticket_result_cb,
736 tio); 649 tio);
737 GNUNET_SERVICE_client_continue (idp->client); 650 GNUNET_SERVICE_client_continue (idp->client);
738 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); 651 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
739} 652}
@@ -1275,39 +1188,9 @@ handle_revoke_ticket_message (void *cls,
1275 1188
1276} 1189}
1277 1190
1278/**
1279 * Cleanup ticket consume handle
1280 * @param handle the handle to clean up
1281 */
1282static void
1283cleanup_consume_ticket_handle (struct ConsumeTicketHandle *handle)
1284{
1285 struct ParallelLookup *lu;
1286 struct ParallelLookup *tmp;
1287 if (NULL != handle->lookup_request)
1288 GNUNET_GNS_lookup_cancel (handle->lookup_request);
1289 for (lu = handle->parallel_lookups_head;
1290 NULL != lu;) {
1291 GNUNET_GNS_lookup_cancel (lu->lookup_request);
1292 GNUNET_free (lu->label);
1293 tmp = lu->next;
1294 GNUNET_CONTAINER_DLL_remove (handle->parallel_lookups_head,
1295 handle->parallel_lookups_tail,
1296 lu);
1297 GNUNET_free (lu);
1298 lu = tmp;
1299 }
1300
1301 if (NULL != handle->attrs)
1302 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (handle->attrs);
1303 GNUNET_free (handle);
1304}
1305
1306
1307
1308static int 1191static int
1309check_consume_ticket_message(void *cls, 1192check_consume_ticket_message (void *cls,
1310 const struct ConsumeTicketMessage *cm) 1193 const struct ConsumeTicketMessage *cm)
1311{ 1194{
1312 uint16_t size; 1195 uint16_t size;
1313 1196
@@ -1321,239 +1204,68 @@ check_consume_ticket_message(void *cls,
1321} 1204}
1322 1205
1323static void 1206static void
1324process_parallel_lookup2 (void *cls, uint32_t rd_count, 1207consume_result_cb (void *cls,
1325 const struct GNUNET_GNSRECORD_Data *rd) 1208 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1209 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1210 uint32_t success,
1211 const char *emsg)
1326{ 1212{
1327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1213 struct ConsumeTicketOperation *cop = cls;
1328 "Parallel lookup finished (count=%u)\n", rd_count);
1329 struct ParallelLookup *parallel_lookup = cls;
1330 struct ConsumeTicketHandle *handle = parallel_lookup->handle;
1331 struct ConsumeTicketResultMessage *crm; 1214 struct ConsumeTicketResultMessage *crm;
1332 struct GNUNET_MQ_Envelope *env; 1215 struct GNUNET_MQ_Envelope *env;
1333 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le;
1334 char *data_tmp; 1216 char *data_tmp;
1335 size_t attrs_len; 1217 size_t attrs_len;
1336 1218 if (GNUNET_OK != success)
1337 GNUNET_CONTAINER_DLL_remove (handle->parallel_lookups_head,
1338 handle->parallel_lookups_tail,
1339 parallel_lookup);
1340 GNUNET_free (parallel_lookup->label);
1341
1342 GNUNET_STATISTICS_update (stats,
1343 "attribute_lookup_time_total",
1344 GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time).rel_value_us,
1345 GNUNET_YES);
1346 GNUNET_STATISTICS_update (stats,
1347 "attribute_lookups_count",
1348 1,
1349 GNUNET_YES);
1350
1351
1352 GNUNET_free (parallel_lookup);
1353 if (1 != rd_count)
1354 GNUNET_break(0);//TODO
1355 if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR)
1356 { 1219 {
1357 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
1358 attr_le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data,
1359 rd->data_size);
1360 GNUNET_CONTAINER_DLL_insert (handle->attrs->list_head,
1361 handle->attrs->list_tail,
1362 attr_le);
1363 }
1364 if (NULL != handle->parallel_lookups_head)
1365 return; //Wait for more
1366 /* Else we are done */
1367
1368 /** Store ticket in DB
1369 * TODO: Store in GNS?
1370 */
1371 /**if (GNUNET_OK != TKT_database->store_ticket (TKT_database->cls,
1372 &handle->ticket,
1373 handle->attrs))
1374 {
1375 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1376 "Unable to store ticket after consume\n"); 1221 "Error consuming ticket: %s\n",
1377 GNUNET_break (0); 1222 emsg);
1378 }*/ 1223 }
1379 1224 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
1380 GNUNET_SCHEDULER_cancel (handle->kill_task);
1381 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (handle->attrs);
1382 env = GNUNET_MQ_msg_extra (crm, 1225 env = GNUNET_MQ_msg_extra (crm,
1383 attrs_len, 1226 attrs_len,
1384 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); 1227 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
1385 crm->id = htonl (handle->r_id); 1228 crm->id = htonl (cop->r_id);
1386 crm->attrs_len = htons (attrs_len); 1229 crm->attrs_len = htons (attrs_len);
1387 crm->identity = handle->ticket.identity; 1230 crm->identity = *identity;
1231 crm->result = htonl (success);
1388 data_tmp = (char *) &crm[1]; 1232 data_tmp = (char *) &crm[1];
1389 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (handle->attrs, 1233 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs,
1390 data_tmp); 1234 data_tmp);
1391 GNUNET_MQ_send (handle->client->mq, env); 1235 GNUNET_MQ_send (cop->client->mq, env);
1392 GNUNET_CONTAINER_DLL_remove (handle->client->consume_op_head, 1236 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
1393 handle->client->consume_op_tail, 1237 cop->client->consume_op_tail,
1394 handle); 1238 cop);
1395 cleanup_consume_ticket_handle (handle); 1239 GNUNET_free (cop);
1396}
1397
1398void
1399abort_parallel_lookups2 (void *cls)
1400{
1401 struct ConsumeTicketHandle *handle = cls;
1402 struct ParallelLookup *lu;
1403 struct ParallelLookup *tmp;
1404 struct AttributeResultMessage *arm;
1405 struct GNUNET_MQ_Envelope *env;
1406
1407 handle->kill_task = NULL;
1408 for (lu = handle->parallel_lookups_head;
1409 NULL != lu;) {
1410 GNUNET_GNS_lookup_cancel (lu->lookup_request);
1411 GNUNET_free (lu->label);
1412 tmp = lu->next;
1413 GNUNET_CONTAINER_DLL_remove (handle->parallel_lookups_head,
1414 handle->parallel_lookups_tail,
1415 lu);
1416 GNUNET_free (lu);
1417 lu = tmp;
1418 }
1419 env = GNUNET_MQ_msg (arm,
1420 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
1421 arm->id = htonl (handle->r_id);
1422 arm->attr_len = htons (0);
1423 GNUNET_MQ_send (handle->client->mq, env);
1424
1425}
1426
1427
1428static void
1429process_attr_labels (void *cls, uint32_t rd_count,
1430 const struct GNUNET_GNSRECORD_Data *rd)
1431{
1432 struct ConsumeTicketHandle *handle = cls;
1433 struct GNUNET_HashCode new_key_hash;
1434 struct GNUNET_CRYPTO_SymmetricSessionKey enc_key;
1435 struct GNUNET_CRYPTO_SymmetricInitializationVector enc_iv;
1436 struct GNUNET_CRYPTO_EcdhePublicKey *ecdh_key;
1437 struct ParallelLookup *parallel_lookup;
1438 size_t size;
1439 char *buf;
1440 char *attr_lbl;
1441 char *lbls;
1442
1443 handle->lookup_request = NULL;
1444 if (1 != rd_count)
1445 {
1446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1447 "Number of keys %d != 1.",
1448 rd_count);
1449 cleanup_consume_ticket_handle (handle);
1450 GNUNET_CONTAINER_DLL_remove (handle->client->consume_op_head,
1451 handle->client->consume_op_tail,
1452 handle);
1453 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1454 return;
1455 }
1456
1457 //Decrypt
1458 ecdh_key = (struct GNUNET_CRYPTO_EcdhePublicKey *)rd->data;
1459
1460 buf = GNUNET_malloc (rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey));
1461
1462 //Calculate symmetric key from ecdh parameters
1463 GNUNET_assert (GNUNET_OK ==
1464 GNUNET_CRYPTO_ecdsa_ecdh (&handle->identity,
1465 ecdh_key,
1466 &new_key_hash));
1467 create_sym_key_from_ecdh (&new_key_hash,
1468 &enc_key,
1469 &enc_iv);
1470 size = GNUNET_CRYPTO_symmetric_decrypt (rd->data + sizeof (struct GNUNET_CRYPTO_EcdhePublicKey),
1471 rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey),
1472 &enc_key,
1473 &enc_iv,
1474 buf);
1475
1476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1477 "Decrypted bytes: %zd Expected bytes: %zd\n",
1478 size, rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey));
1479 GNUNET_STATISTICS_update (stats,
1480 "reclaim_authz_lookup_time_total",
1481 GNUNET_TIME_absolute_get_duration (handle->lookup_start_time).rel_value_us,
1482 GNUNET_YES);
1483 GNUNET_STATISTICS_update (stats,
1484 "reclaim_authz_lookups_count",
1485 1,
1486 GNUNET_YES);
1487 lbls = GNUNET_strdup (buf);
1488 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1489 "Attributes found %s\n", lbls);
1490 1240
1491 for (attr_lbl = strtok (lbls, ",");
1492 NULL != attr_lbl;
1493 attr_lbl = strtok (NULL, ","))
1494 {
1495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1496 "Looking up %s\n", attr_lbl);
1497 parallel_lookup = GNUNET_new (struct ParallelLookup);
1498 parallel_lookup->handle = handle;
1499 parallel_lookup->label = GNUNET_strdup (attr_lbl);
1500 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get();
1501 parallel_lookup->lookup_request
1502 = GNUNET_GNS_lookup (gns_handle,
1503 attr_lbl,
1504 &handle->ticket.identity,
1505 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR,
1506 GNUNET_GNS_LO_DEFAULT,
1507 &process_parallel_lookup2,
1508 parallel_lookup);
1509 GNUNET_CONTAINER_DLL_insert (handle->parallel_lookups_head,
1510 handle->parallel_lookups_tail,
1511 parallel_lookup);
1512 }
1513 GNUNET_free (lbls);
1514 GNUNET_free (buf);
1515 handle->kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES,3),
1516 &abort_parallel_lookups2,
1517 handle);
1518} 1241}
1519 1242
1520
1521static void 1243static void
1522handle_consume_ticket_message (void *cls, 1244handle_consume_ticket_message (void *cls,
1523 const struct ConsumeTicketMessage *cm) 1245 const struct ConsumeTicketMessage *cm)
1524{ 1246{
1525 struct ConsumeTicketHandle *ch; 1247 struct ConsumeTicketOperation *cop;
1248 struct GNUNET_RECLAIM_Ticket *ticket;
1526 struct IdpClient *idp = cls; 1249 struct IdpClient *idp = cls;
1527 char* rnd_label; 1250
1528 1251 cop = GNUNET_new (struct ConsumeTicketOperation);
1529 ch = GNUNET_new (struct ConsumeTicketHandle); 1252 cop->r_id = ntohl (cm->id);
1530 ch->r_id = ntohl (cm->id); 1253 cop->client = idp;
1531 ch->client = idp; 1254 ticket = (struct GNUNET_RECLAIM_Ticket*)&cm[1];
1532 ch->identity = cm->identity; 1255 cop->ch = RECLAIM_TICKETS_consume (&cm->identity,
1533 ch->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 1256 ticket,
1534 GNUNET_CRYPTO_ecdsa_key_get_public (&ch->identity, 1257 &consume_result_cb,
1535 &ch->identity_pub); 1258 cop);
1536 ch->ticket = *((struct GNUNET_RECLAIM_Ticket*)&cm[1]);
1537 rnd_label = GNUNET_STRINGS_data_to_string_alloc (&ch->ticket.rnd,
1538 sizeof (uint64_t));
1539 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1540 "Looking for ABE key under %s\n", rnd_label);
1541 ch->lookup_start_time = GNUNET_TIME_absolute_get ();
1542 ch->lookup_request
1543 = GNUNET_GNS_lookup (gns_handle,
1544 rnd_label,
1545 &ch->ticket.identity,
1546 GNUNET_GNSRECORD_TYPE_RECLAIM_AUTHZ,
1547 GNUNET_GNS_LO_DEFAULT,
1548 &process_attr_labels,
1549 ch);
1550 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, 1259 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head,
1551 idp->consume_op_tail, 1260 idp->consume_op_tail,
1552 ch); 1261 cop);
1553 GNUNET_free (rnd_label);
1554 GNUNET_SERVICE_client_continue (idp->client); 1262 GNUNET_SERVICE_client_continue (idp->client);
1555} 1263}
1556 1264
1265/*****************************************
1266 * Attribute store
1267 *****************************************/
1268
1557/** 1269/**
1558 * Cleanup attribute store handle 1270 * Cleanup attribute store handle
1559 * 1271 *
@@ -1694,6 +1406,10 @@ handle_attribute_store_message (void *cls,
1694 GNUNET_SCHEDULER_add_now (&attr_store_task, ash); 1406 GNUNET_SCHEDULER_add_now (&attr_store_task, ash);
1695} 1407}
1696 1408
1409/*************************************************
1410 * Attrubute iteration
1411 *************************************************/
1412
1697static void 1413static void
1698cleanup_attribute_iter_handle (struct AttributeIterator *ai) 1414cleanup_attribute_iter_handle (struct AttributeIterator *ai)
1699{ 1415{
@@ -1856,6 +1572,10 @@ handle_iteration_next (void *cls,
1856 GNUNET_SERVICE_client_continue (idp->client); 1572 GNUNET_SERVICE_client_continue (idp->client);
1857} 1573}
1858 1574
1575/******************************************************
1576 * Ticket iteration
1577 ******************************************************/
1578
1859static void 1579static void
1860ticket_iter_cb (void *cls, 1580ticket_iter_cb (void *cls,
1861 struct GNUNET_RECLAIM_Ticket *ticket) 1581 struct GNUNET_RECLAIM_Ticket *ticket)
@@ -1979,7 +1699,6 @@ run (void *cls,
1979 char *database; 1699 char *database;
1980 cfg = c; 1700 cfg = c;
1981 1701
1982 stats = GNUNET_STATISTICS_create ("reclaim", cfg);
1983 1702
1984 if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) 1703 if (GNUNET_OK != RECLAIM_TICKETS_init (cfg))
1985 { 1704 {
@@ -1995,11 +1714,6 @@ run (void *cls,
1995 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to namestore"); 1714 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to namestore");
1996 } 1715 }
1997 1716
1998 gns_handle = GNUNET_GNS_connect (cfg);
1999 if (NULL == gns_handle)
2000 {
2001 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
2002 }
2003 identity_handle = GNUNET_IDENTITY_connect (cfg, 1717 identity_handle = GNUNET_IDENTITY_connect (cfg,
2004 NULL, 1718 NULL,
2005 NULL); 1719 NULL);
@@ -2060,7 +1774,7 @@ client_disconnect_cb (void *cls,
2060 struct TicketIteration *ti; 1774 struct TicketIteration *ti;
2061 struct TicketRevocationHandle *rh; 1775 struct TicketRevocationHandle *rh;
2062 struct TicketIssueOperation *iss; 1776 struct TicketIssueOperation *iss;
2063 struct ConsumeTicketHandle *ct; 1777 struct ConsumeTicketOperation *ct;
2064 struct AttributeStoreHandle *as; 1778 struct AttributeStoreHandle *as;
2065 1779
2066 //TODO other operations 1780 //TODO other operations
@@ -2081,7 +1795,9 @@ client_disconnect_cb (void *cls,
2081 GNUNET_CONTAINER_DLL_remove (idp->consume_op_head, 1795 GNUNET_CONTAINER_DLL_remove (idp->consume_op_head,
2082 idp->consume_op_tail, 1796 idp->consume_op_tail,
2083 ct); 1797 ct);
2084 cleanup_consume_ticket_handle (ct); 1798 if (NULL != ct->ch)
1799 RECLAIM_TICKETS_consume_cancel (ct->ch);
1800 GNUNET_free (ct);
2085 } 1801 }
2086 while (NULL != (as = idp->store_op_head)) 1802 while (NULL != (as = idp->store_op_head))
2087 { 1803 {