aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-10-23 15:00:54 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-10-23 15:00:54 +0900
commitbb81464ede13b1cba93cd031de466bbc8c18f04f (patch)
tree6fc675d02f89c9611afb371b5291bb0fd86eb59e /src/namestore
parentb391cb1d41ad900385338936b655fc0699a61eca (diff)
downloadgnunet-bb81464ede13b1cba93cd031de466bbc8c18f04f.tar.gz
gnunet-bb81464ede13b1cba93cd031de466bbc8c18f04f.zip
NAMESTORE: Introduce GANA-managed error codes
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c17
-rw-r--r--src/namestore/gnunet-namestore-zonefile.c12
-rw-r--r--src/namestore/gnunet-namestore.c61
-rw-r--r--src/namestore/gnunet-service-namestore.c140
-rw-r--r--src/namestore/gnunet-zoneimport.c18
-rw-r--r--src/namestore/namestore.h37
-rw-r--r--src/namestore/namestore_api.c80
-rw-r--r--src/namestore/perf_namestore_api_import.c25
-rw-r--r--src/namestore/perf_namestore_api_zone_iteration.c5
-rw-r--r--src/namestore/plugin_rest_namestore.c221
-rw-r--r--src/namestore/test_namestore_api_edit_records.c29
-rw-r--r--src/namestore/test_namestore_api_lookup_nick.c10
-rw-r--r--src/namestore/test_namestore_api_monitoring.c5
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c5
-rw-r--r--src/namestore/test_namestore_api_remove.c16
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c16
-rw-r--r--src/namestore/test_namestore_api_store.c4
-rw-r--r--src/namestore/test_namestore_api_store_update.c8
-rw-r--r--src/namestore/test_namestore_api_tx_rollback.c21
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c7
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c16
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c7
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c6
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c8
24 files changed, 282 insertions, 492 deletions
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c
index 4a9c6e874..857b16def 100644
--- a/src/namestore/gnunet-namestore-fcfsd.c
+++ b/src/namestore/gnunet-namestore-fcfsd.c
@@ -432,31 +432,24 @@ register_error_cb (void *cls)
432} 432}
433 433
434 434
435/**
436 * A name/key pair has been successfully registered, or maybe not.
437 *
438 * @param cls the connection
439 * @param status result of the operation
440 * @param emsg error message if any
441 */
442static void 435static void
443register_done_cb (void *cls, 436register_done_cb (void *cls,
444 int32_t status, 437 enum GNUNET_ErrorCode ec)
445 const char *emsg)
446{ 438{
447 struct RequestData *rd = cls; 439 struct RequestData *rd = cls;
448 440
449 MHD_resume_connection (rd->c); 441 MHD_resume_connection (rd->c);
450 rd->searching = NULL; 442 rd->searching = NULL;
451 443
452 if ((GNUNET_SYSERR == status) || (GNUNET_NO == status)) 444 if (GNUNET_EC_NONE != ec)
453 { 445 {
454 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 446 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
455 _ ("Failed to create record for `%s': %s\n"), 447 _ ("Failed to create record for `%s': %s\n"),
456 rd->register_name, 448 rd->register_name,
457 emsg); 449 GNUNET_ErrorCode_get_hint (ec));
458 rd->body = make_json ("error", "true", 450 rd->body = make_json ("error", "true",
459 "message", emsg, 451 "message",
452 GNUNET_ErrorCode_get_hint (ec),
460 NULL); 453 NULL);
461 rd->body_length = strlen (rd->body); 454 rd->body_length = strlen (rd->body);
462 rd->code = MHD_HTTP_INTERNAL_SERVER_ERROR; 455 rd->code = MHD_HTTP_INTERNAL_SERVER_ERROR;
diff --git a/src/namestore/gnunet-namestore-zonefile.c b/src/namestore/gnunet-namestore-zonefile.c
index f8d876108..ff3b2a565 100644
--- a/src/namestore/gnunet-namestore-zonefile.c
+++ b/src/namestore/gnunet-namestore-zonefile.c
@@ -184,10 +184,10 @@ do_shutdown (void *cls)
184} 184}
185 185
186static void 186static void
187tx_end (void *cls, int32_t success, const char *emsg) 187tx_end (void *cls, enum GNUNET_ErrorCode ec)
188{ 188{
189 ns_qe = NULL; 189 ns_qe = NULL;
190 if (GNUNET_SYSERR == success) 190 if (GNUNET_EC_NONE != ec)
191 { 191 {
192 fprintf (stderr, 192 fprintf (stderr,
193 _ ("Ego `%s' not known to identity service\n"), 193 _ ("Ego `%s' not known to identity service\n"),
@@ -320,10 +320,10 @@ origin_lookup_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
320} 320}
321 321
322static void 322static void
323add_continuation (void *cls, int32_t success, const char *emsg) 323add_continuation (void *cls, enum GNUNET_ErrorCode ec)
324{ 324{
325 ns_qe = NULL; 325 ns_qe = NULL;
326 if (GNUNET_SYSERR == success) 326 if (GNUNET_EC_NONE != ec)
327 { 327 {
328 fprintf (stderr, 328 fprintf (stderr,
329 _ ("Failed to store records...\n")); 329 _ ("Failed to store records...\n"));
@@ -646,10 +646,10 @@ parse (void *cls)
646} 646}
647 647
648static void 648static void
649tx_start (void *cls, int32_t success, const char *emsg) 649tx_start (void *cls, enum GNUNET_ErrorCode ec)
650{ 650{
651 ns_qe = NULL; 651 ns_qe = NULL;
652 if (GNUNET_SYSERR == success) 652 if (GNUNET_EC_NONE != ec)
653 { 653 {
654 fprintf (stderr, 654 fprintf (stderr,
655 _ ("Ego `%s' not known to identity service\n"), 655 _ ("Ego `%s' not known to identity service\n"),
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 9ed8f400c..a636644f8 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -318,28 +318,18 @@ test_finished ()
318} 318}
319 319
320 320
321/**
322 * Continuation called to notify client about result of the
323 * operation.
324 *
325 * @param cls closure, location of the QueueEntry pointer to NULL out
326 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
327 * #GNUNET_NO if content was already there
328 * #GNUNET_YES (or other positive value) on success
329 * @param emsg NULL on success, otherwise an error message
330 */
331static void 321static void
332add_continuation (void *cls, int32_t success, const char *emsg) 322add_continuation (void *cls, enum GNUNET_ErrorCode ec)
333{ 323{
334 struct GNUNET_NAMESTORE_QueueEntry **qe = cls; 324 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
335 325
336 *qe = NULL; 326 *qe = NULL;
337 if (GNUNET_YES != success) 327 if (GNUNET_EC_NONE != ec)
338 { 328 {
339 fprintf (stderr, 329 fprintf (stderr,
340 _ ("Adding record failed: %s\n"), 330 _ ("Adding record failed: %s\n"),
341 (GNUNET_NO == success) ? "record exists" : emsg); 331 GNUNET_ErrorCode_get_hint (ec));
342 if (GNUNET_NO != success) 332 if (GNUNET_EC_NAMESTORE_RECORD_EXISTS != ec)
343 ret = 1; 333 ret = 1;
344 } 334 }
345 ret = 0; 335 ret = 0;
@@ -347,34 +337,15 @@ add_continuation (void *cls, int32_t success, const char *emsg)
347} 337}
348 338
349 339
350/**
351 * Continuation called to notify client about result of the
352 * operation.
353 *
354 * @param cls closure, unused
355 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
356 * #GNUNET_NO if content was already there
357 * #GNUNET_YES (or other positive value) on success
358 * @param emsg NULL on success, otherwise an error message
359 */
360static void 340static void
361del_continuation (void *cls, int32_t success, const char *emsg) 341del_continuation (void *cls, enum GNUNET_ErrorCode ec)
362{ 342{
363 (void) cls; 343 (void) cls;
364 del_qe = NULL; 344 del_qe = NULL;
365 if (GNUNET_NO == success) 345 if (GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND == ec)
366 { 346 {
367 fprintf (stderr, 347 fprintf (stderr,
368 _ ("Deleting record failed, record does not exist%s%s\n"), 348 _ ("Deleting record failed: %s\n"), GNUNET_ErrorCode_get_hint (ec));
369 (NULL != emsg) ? ": " : "",
370 (NULL != emsg) ? emsg : "");
371 }
372 if (GNUNET_SYSERR == success)
373 {
374 fprintf (stderr,
375 _ ("Deleting record failed%s%s\n"),
376 (NULL != emsg) ? ": " : "",
377 (NULL != emsg) ? emsg : "");
378 } 349 }
379 test_finished (); 350 test_finished ();
380} 351}
@@ -898,27 +869,17 @@ parse_expiration (const char *expirationstring,
898} 869}
899 870
900 871
901/**
902 * Function called when namestore is done with the replace
903 * operation.
904 *
905 * @param cls NULL
906 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
907 * #GNUNET_NO if content was already there or not found
908 * #GNUNET_YES (or other positive value) on success
909 * @param emsg NULL on success, otherwise an error message
910 */
911static void 872static void
912replace_cont (void *cls, int success, const char *emsg) 873replace_cont (void *cls, enum GNUNET_ErrorCode ec)
913{ 874{
914 (void) cls; 875 (void) cls;
915 876
916 set_qe = NULL; 877 set_qe = NULL;
917 if (GNUNET_OK != success) 878 if (GNUNET_EC_NONE != ec)
918 { 879 {
919 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 880 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
920 _ ("Failed to replace records: %s\n"), 881 _ ("%s\n"),
921 emsg); 882 GNUNET_ErrorCode_get_hint (ec));
922 ret = 1; /* fail from 'main' */ 883 ret = 1; /* fail from 'main' */
923 } 884 }
924 GNUNET_SCHEDULER_shutdown (); 885 GNUNET_SCHEDULER_shutdown ();
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 7cd36f317..0c8b89a91 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -941,11 +941,12 @@ send_lookup_response (struct NamestoreClient *nc,
941 * Send response to the store request to the client. 941 * Send response to the store request to the client.
942 * 942 *
943 * @param nc client to talk to 943 * @param nc client to talk to
944 * @param res status of the operation 944 * @param ec status of the operation
945 * @param rid client's request ID 945 * @param rid client's request ID
946 */ 946 */
947static void 947static void
948send_store_response (struct NamestoreClient *nc, int res, const char *emsg, 948send_store_response (struct NamestoreClient *nc,
949 enum GNUNET_ErrorCode ec,
949 uint32_t rid) 950 uint32_t rid)
950{ 951{
951 struct GNUNET_MQ_Envelope *env; 952 struct GNUNET_MQ_Envelope *env;
@@ -958,17 +959,10 @@ send_store_response (struct NamestoreClient *nc, int res, const char *emsg,
958 "Store requests completed", 959 "Store requests completed",
959 1, 960 1,
960 GNUNET_NO); 961 GNUNET_NO);
961 env = GNUNET_MQ_msg_extra (rcr_msg, 962 env = GNUNET_MQ_msg (rcr_msg,
962 (NULL != emsg) ? strlen (emsg) + 1 : 0, 963 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE);
963 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE);
964 rcr_msg->gns_header.r_id = htonl (rid); 964 rcr_msg->gns_header.r_id = htonl (rid);
965 rcr_msg->op_result = htonl (res); 965 rcr_msg->ec = htonl (ec);
966 rcr_msg->reserved = htons (0);
967 if (NULL != emsg)
968 {
969 rcr_msg->emsg_len = htons (strlen (emsg) + 1);
970 memcpy (&rcr_msg[1], emsg, strlen (emsg) + 1);
971 }
972 GNUNET_MQ_send (nc->mq, env); 966 GNUNET_MQ_send (nc->mq, env);
973} 967}
974 968
@@ -1043,7 +1037,7 @@ continue_store_activity (struct StoreActivity *sa,
1043 { 1037 {
1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1045 "Transaction not yet committed, delaying monitor and cache updates\n"); 1039 "Transaction not yet committed, delaying monitor and cache updates\n");
1046 send_store_response (sa->nc, GNUNET_YES, NULL, sa->rid); 1040 send_store_response (sa->nc, GNUNET_EC_NONE, sa->rid);
1047 if (GNUNET_YES == call_continue) 1041 if (GNUNET_YES == call_continue)
1048 GNUNET_SERVICE_client_continue (sa->nc->client); 1042 GNUNET_SERVICE_client_continue (sa->nc->client);
1049 return GNUNET_OK; 1043 return GNUNET_OK;
@@ -1114,7 +1108,7 @@ continue_store_activity (struct StoreActivity *sa,
1114 } 1108 }
1115 if (GNUNET_YES == call_continue) 1109 if (GNUNET_YES == call_continue)
1116 GNUNET_SERVICE_client_continue (sa->nc->client); 1110 GNUNET_SERVICE_client_continue (sa->nc->client);
1117 send_store_response (sa->nc, GNUNET_YES, NULL, sa->rid); 1111 send_store_response (sa->nc, GNUNET_EC_NONE, sa->rid);
1118 free_store_activity (sa); 1112 free_store_activity (sa);
1119 return GNUNET_OK; 1113 return GNUNET_OK;
1120} 1114}
@@ -1632,24 +1626,26 @@ get_existing_rd_exp (void *cls,
1632 } 1626 }
1633} 1627}
1634 1628
1635static enum GNUNET_GenericReturnValue 1629static enum GNUNET_ErrorCode
1636store_record_set (struct NamestoreClient *nc, 1630store_record_set (struct NamestoreClient *nc,
1637 const struct GNUNET_IDENTITY_PrivateKey *private_key, 1631 const struct GNUNET_IDENTITY_PrivateKey *private_key,
1638 const struct RecordSet *rd_set, 1632 const struct RecordSet *rd_set,
1639 ssize_t *len, 1633 ssize_t *len)
1640 char **emsg)
1641{ 1634{
1642 size_t name_len; 1635 size_t name_len;
1643 size_t rd_ser_len; 1636 size_t rd_ser_len;
1644 const char *name_tmp; 1637 const char *name_tmp;
1645 const char *rd_ser; 1638 const char *rd_ser;
1646 char *conv_name; 1639 char *conv_name;
1640 char *emsg;
1647 unsigned int rd_count; 1641 unsigned int rd_count;
1648 int res; 1642 int res;
1643 enum GNUNET_ErrorCode ec;
1649 struct GNUNET_TIME_Absolute new_block_exp; 1644 struct GNUNET_TIME_Absolute new_block_exp;
1650 struct LookupExistingRecordsContext lctx; 1645 struct LookupExistingRecordsContext lctx;
1651 *len = sizeof (struct RecordSet); 1646 *len = sizeof (struct RecordSet);
1652 1647
1648 ec = GNUNET_EC_NONE;
1653 lctx.only_tombstone = GNUNET_NO; 1649 lctx.only_tombstone = GNUNET_NO;
1654 lctx.exp = GNUNET_TIME_UNIT_ZERO_ABS; 1650 lctx.exp = GNUNET_TIME_UNIT_ZERO_ABS;
1655 new_block_exp = GNUNET_TIME_UNIT_ZERO_ABS; 1651 new_block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
@@ -1670,27 +1666,26 @@ store_record_set (struct NamestoreClient *nc,
1670 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1666 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1671 "Error normalizing name `%s'\n", 1667 "Error normalizing name `%s'\n",
1672 name_tmp); 1668 name_tmp);
1673 *emsg = GNUNET_strdup (_ ("Error normalizing name.")); 1669 return GNUNET_EC_NAMESTORE_LABEL_INVALID;
1674 return GNUNET_SYSERR;
1675 } 1670 }
1676 1671
1677 /* Check name for validity */ 1672 /* Check name for validity */
1678 if (GNUNET_OK != GNUNET_GNSRECORD_label_check (conv_name, emsg)) 1673 if (GNUNET_OK != GNUNET_GNSRECORD_label_check (conv_name, &emsg))
1679 { 1674 {
1680 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1675 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1681 "Label invalid: `%s'\n", 1676 "Label invalid: `%s'\n",
1682 *emsg); 1677 emsg);
1678 GNUNET_free (emsg);
1683 GNUNET_free (conv_name); 1679 GNUNET_free (conv_name);
1684 return -1; 1680 return GNUNET_EC_NAMESTORE_LABEL_INVALID;
1685 } 1681 }
1686 1682
1687 if (GNUNET_OK != 1683 if (GNUNET_OK !=
1688 GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count, 1684 GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count,
1689 rd)) 1685 rd))
1690 { 1686 {
1691 *emsg = GNUNET_strdup (_ ("Error deserializing records."));
1692 GNUNET_free (conv_name); 1687 GNUNET_free (conv_name);
1693 return GNUNET_SYSERR; 1688 return GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
1694 } 1689 }
1695 1690
1696 GNUNET_STATISTICS_update (statistics, 1691 GNUNET_STATISTICS_update (statistics,
@@ -1713,7 +1708,7 @@ store_record_set (struct NamestoreClient *nc,
1713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1708 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1714 "Name `%s' does not exist, no deletion required\n", 1709 "Name `%s' does not exist, no deletion required\n",
1715 conv_name); 1710 conv_name);
1716 res = GNUNET_NO; 1711 ec = GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND;
1717 } 1712 }
1718 else 1713 else
1719 { 1714 {
@@ -1758,10 +1753,14 @@ store_record_set (struct NamestoreClient *nc,
1758 &rd_nf_count, 1753 &rd_nf_count,
1759 &new_block_exp, 1754 &new_block_exp,
1760 GNUNET_GNSRECORD_FILTER_NONE, 1755 GNUNET_GNSRECORD_FILTER_NONE,
1761 emsg)) 1756 &emsg))
1762 { 1757 {
1763 GNUNET_free (conv_name); 1758 GNUNET_free (conv_name);
1764 return GNUNET_SYSERR; 1759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1760 "Error normalizing record set: `%s'\n",
1761 emsg);
1762 GNUNET_free (emsg);
1763 return GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
1765 } 1764 }
1766 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1765 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1767 "%u/%u records before tombstone\n", rd_nf_count, 1766 "%u/%u records before tombstone\n", rd_nf_count,
@@ -1808,21 +1807,19 @@ store_record_set (struct NamestoreClient *nc,
1808 { 1807 {
1809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1810 "Client tried to remove non-existant record\n"); 1809 "Client tried to remove non-existant record\n");
1811 *emsg = GNUNET_strdup (_ ("Not records to delete.")); 1810 ec = GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND;
1812 res = GNUNET_NO;
1813 } 1811 }
1814 } 1812 }
1815 1813
1816 if (GNUNET_SYSERR == res) 1814 if (GNUNET_SYSERR == res)
1817 { 1815 {
1818 /* store not successful, no need to tell monitors */ 1816 /* store not successful, no need to tell monitors */
1819 *emsg = GNUNET_strdup (_ ("Store failed"));
1820 GNUNET_free (conv_name); 1817 GNUNET_free (conv_name);
1821 return GNUNET_SYSERR; 1818 return GNUNET_EC_NAMESTORE_STORE_FAILED;
1822 } 1819 }
1823 } 1820 }
1824 GNUNET_free (conv_name); 1821 GNUNET_free (conv_name);
1825 return res; 1822 return ec;
1826} 1823}
1827 1824
1828/** 1825/**
@@ -1837,12 +1834,11 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1837 struct NamestoreClient *nc = cls; 1834 struct NamestoreClient *nc = cls;
1838 uint32_t rid; 1835 uint32_t rid;
1839 uint16_t rd_set_count; 1836 uint16_t rd_set_count;
1840 char *emsg = NULL;
1841 const char *buf; 1837 const char *buf;
1842 ssize_t read; 1838 ssize_t read;
1843 struct StoreActivity *sa; 1839 struct StoreActivity *sa;
1844 struct RecordSet *rs; 1840 struct RecordSet *rs;
1845 enum GNUNET_GenericReturnValue res; 1841 enum GNUNET_ErrorCode res;
1846 1842
1847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1843 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1848 "Received NAMESTORE_RECORD_STORE message\n"); 1844 "Received NAMESTORE_RECORD_STORE message\n");
@@ -1853,12 +1849,10 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1853 { 1849 {
1854 rs = (struct RecordSet *) buf; 1850 rs = (struct RecordSet *) buf;
1855 res = store_record_set (nc, &rp_msg->private_key, 1851 res = store_record_set (nc, &rp_msg->private_key,
1856 rs, &read, &emsg); 1852 rs, &read);
1857 if (GNUNET_OK != res) 1853 if (GNUNET_EC_NONE != res)
1858 { 1854 {
1859 send_store_response (nc, res, emsg, 1855 send_store_response (nc, res, rid);
1860 rid);
1861 GNUNET_free (emsg);
1862 GNUNET_SERVICE_client_continue (nc->client); 1856 GNUNET_SERVICE_client_continue (nc->client);
1863 return; 1857 return;
1864 } 1858 }
@@ -1882,27 +1876,15 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1882} 1876}
1883 1877
1884static void 1878static void
1885send_tx_response (int rid, int status, char *emsg, struct NamestoreClient *nc) 1879send_tx_response (int rid, enum GNUNET_ErrorCode ec, struct NamestoreClient *nc)
1886{ 1880{
1887 struct TxControlResultMessage *txr_msg; 1881 struct TxControlResultMessage *txr_msg;
1888 struct GNUNET_MQ_Envelope *env; 1882 struct GNUNET_MQ_Envelope *env;
1889 char *err_tmp;
1890 size_t err_len;
1891 1883
1892 err_len = (NULL == emsg) ? 0 : strlen (emsg) + 1;
1893 env = 1884 env =
1894 GNUNET_MQ_msg_extra (txr_msg, 1885 GNUNET_MQ_msg (txr_msg, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT);
1895 err_len,
1896 GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT);
1897 txr_msg->gns_header.header.size = htons (sizeof (struct
1898 TxControlResultMessage)
1899 + err_len);
1900 txr_msg->gns_header.r_id = rid; 1886 txr_msg->gns_header.r_id = rid;
1901 txr_msg->success = htons (status); 1887 txr_msg->ec = htonl (ec);
1902 err_tmp = (char *) &txr_msg[1];
1903 GNUNET_memcpy (err_tmp, emsg, err_len);
1904 if (NULL != emsg)
1905 GNUNET_free (emsg);
1906 GNUNET_MQ_send (nc->mq, env); 1888 GNUNET_MQ_send (nc->mq, env);
1907} 1889}
1908 1890
@@ -1929,14 +1911,31 @@ handle_tx_control (void *cls, const struct TxControlMessage *tx_msg)
1929 case GNUNET_NAMESTORE_TX_BEGIN: 1911 case GNUNET_NAMESTORE_TX_BEGIN:
1930 ret = nc->GSN_database->transaction_begin (nc->GSN_database->cls, 1912 ret = nc->GSN_database->transaction_begin (nc->GSN_database->cls,
1931 &emsg); 1913 &emsg);
1932 send_tx_response (tx_msg->gns_header.r_id, ret, emsg, nc); 1914 send_tx_response (tx_msg->gns_header.r_id,
1915 (GNUNET_SYSERR == ret) ?
1916 GNUNET_EC_NAMESTORE_BACKEND_FAILED : GNUNET_EC_NONE, nc);
1917 if (GNUNET_SYSERR == ret)
1918 {
1919 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1920 "Databse backend error: `%s'", emsg);
1921 GNUNET_free (emsg);
1922 }
1933 GNUNET_SERVICE_client_continue (nc->client); 1923 GNUNET_SERVICE_client_continue (nc->client);
1934 nc->in_transaction = GNUNET_YES; 1924 nc->in_transaction = GNUNET_YES;
1935 break; 1925 break;
1936 case GNUNET_NAMESTORE_TX_COMMIT: 1926 case GNUNET_NAMESTORE_TX_COMMIT:
1937 ret = nc->GSN_database->transaction_commit (nc->GSN_database->cls, 1927 ret = nc->GSN_database->transaction_commit (nc->GSN_database->cls,
1938 &emsg); 1928 &emsg);
1939 send_tx_response (tx_msg->gns_header.r_id, ret, emsg, nc); 1929 send_tx_response (tx_msg->gns_header.r_id,
1930 (GNUNET_SYSERR == ret) ?
1931 GNUNET_EC_NAMESTORE_BACKEND_FAILED : GNUNET_EC_NONE,
1932 nc);
1933 if (GNUNET_SYSERR == ret)
1934 {
1935 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1936 "Databse backend error: `%s'", emsg);
1937 GNUNET_free (emsg);
1938 }
1940 if (GNUNET_SYSERR != ret) 1939 if (GNUNET_SYSERR != ret)
1941 { 1940 {
1942 nc->in_transaction = GNUNET_NO; 1941 nc->in_transaction = GNUNET_NO;
@@ -1961,8 +1960,16 @@ handle_tx_control (void *cls, const struct TxControlMessage *tx_msg)
1961 case GNUNET_NAMESTORE_TX_ROLLBACK: 1960 case GNUNET_NAMESTORE_TX_ROLLBACK:
1962 ret = nc->GSN_database->transaction_rollback (nc->GSN_database->cls, 1961 ret = nc->GSN_database->transaction_rollback (nc->GSN_database->cls,
1963 &emsg); 1962 &emsg);
1964 send_tx_response (tx_msg->gns_header.r_id, ret, emsg, nc); 1963 send_tx_response (tx_msg->gns_header.r_id,
1964 (GNUNET_SYSERR == ret) ?
1965 GNUNET_EC_NAMESTORE_BACKEND_FAILED : GNUNET_EC_NONE, nc);
1965 GNUNET_SERVICE_client_continue (nc->client); 1966 GNUNET_SERVICE_client_continue (nc->client);
1967 if (GNUNET_SYSERR == ret)
1968 {
1969 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1970 "Databse backend error: `%s'", emsg);
1971 GNUNET_free (emsg);
1972 }
1966 if (GNUNET_SYSERR != ret) 1973 if (GNUNET_SYSERR != ret)
1967 { 1974 {
1968 nc->in_transaction = GNUNET_NO; 1975 nc->in_transaction = GNUNET_NO;
@@ -2010,7 +2017,7 @@ struct ZoneToNameCtx
2010 * not finding a name for the zone still counts as a 'success' here, 2017 * not finding a name for the zone still counts as a 'success' here,
2011 * as this field is about the success of executing the IPC protocol. 2018 * as this field is about the success of executing the IPC protocol.
2012 */ 2019 */
2013 int success; 2020 enum GNUNET_ErrorCode ec;
2014}; 2021};
2015 2022
2016 2023
@@ -2035,7 +2042,6 @@ handle_zone_to_name_it (void *cls,
2035 struct ZoneToNameCtx *ztn_ctx = cls; 2042 struct ZoneToNameCtx *ztn_ctx = cls;
2036 struct GNUNET_MQ_Envelope *env; 2043 struct GNUNET_MQ_Envelope *env;
2037 struct ZoneToNameResponseMessage *ztnr_msg; 2044 struct ZoneToNameResponseMessage *ztnr_msg;
2038 int16_t res;
2039 size_t name_len; 2045 size_t name_len;
2040 ssize_t rd_ser_len; 2046 ssize_t rd_ser_len;
2041 size_t msg_size; 2047 size_t msg_size;
@@ -2046,20 +2052,20 @@ handle_zone_to_name_it (void *cls,
2046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2052 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2047 "Found result for zone-to-name lookup: `%s'\n", 2053 "Found result for zone-to-name lookup: `%s'\n",
2048 name); 2054 name);
2049 res = GNUNET_YES; 2055 ztn_ctx->ec = GNUNET_EC_NONE;
2050 name_len = (NULL == name) ? 0 : strlen (name) + 1; 2056 name_len = (NULL == name) ? 0 : strlen (name) + 1;
2051 rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); 2057 rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
2052 if (rd_ser_len < 0) 2058 if (rd_ser_len < 0)
2053 { 2059 {
2054 GNUNET_break (0); 2060 GNUNET_break (0);
2055 ztn_ctx->success = GNUNET_SYSERR; 2061 ztn_ctx->ec = htonl (GNUNET_EC_NAMESTORE_UNKNOWN);
2056 return; 2062 return;
2057 } 2063 }
2058 msg_size = sizeof(struct ZoneToNameResponseMessage) + name_len + rd_ser_len; 2064 msg_size = sizeof(struct ZoneToNameResponseMessage) + name_len + rd_ser_len;
2059 if (msg_size >= GNUNET_MAX_MESSAGE_SIZE) 2065 if (msg_size >= GNUNET_MAX_MESSAGE_SIZE)
2060 { 2066 {
2061 GNUNET_break (0); 2067 GNUNET_break (0);
2062 ztn_ctx->success = GNUNET_SYSERR; 2068 ztn_ctx->ec = GNUNET_EC_NAMESTORE_RECORD_TOO_BIG;
2063 return; 2069 return;
2064 } 2070 }
2065 env = 2071 env =
@@ -2068,7 +2074,7 @@ handle_zone_to_name_it (void *cls,
2068 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); 2074 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE);
2069 ztnr_msg->gns_header.header.size = htons (msg_size); 2075 ztnr_msg->gns_header.header.size = htons (msg_size);
2070 ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid); 2076 ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid);
2071 ztnr_msg->res = htons (res); 2077 ztnr_msg->ec = htonl (ztn_ctx->ec);
2072 ztnr_msg->rd_len = htons (rd_ser_len); 2078 ztnr_msg->rd_len = htons (rd_ser_len);
2073 ztnr_msg->rd_count = htons (rd_count); 2079 ztnr_msg->rd_count = htons (rd_count);
2074 ztnr_msg->name_len = htons (name_len); 2080 ztnr_msg->name_len = htons (name_len);
@@ -2079,7 +2085,7 @@ handle_zone_to_name_it (void *cls,
2079 GNUNET_assert ( 2085 GNUNET_assert (
2080 rd_ser_len == 2086 rd_ser_len ==
2081 GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_tmp)); 2087 GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_tmp));
2082 ztn_ctx->success = GNUNET_OK; 2088 ztn_ctx->ec = GNUNET_EC_NONE;
2083 GNUNET_MQ_send (ztn_ctx->nc->mq, env); 2089 GNUNET_MQ_send (ztn_ctx->nc->mq, env);
2084} 2090}
2085 2091
@@ -2101,7 +2107,7 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME message\n"); 2107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME message\n");
2102 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id); 2108 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id);
2103 ztn_ctx.nc = nc; 2109 ztn_ctx.nc = nc;
2104 ztn_ctx.success = GNUNET_NO; 2110 ztn_ctx.ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
2105 if (GNUNET_SYSERR == nc->GSN_database->zone_to_name (nc->GSN_database->cls, 2111 if (GNUNET_SYSERR == nc->GSN_database->zone_to_name (nc->GSN_database->cls,
2106 &ztn_msg->zone, 2112 &ztn_msg->zone,
2107 &ztn_msg->value_zone, 2113 &ztn_msg->value_zone,
@@ -2114,7 +2120,7 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2114 GNUNET_SERVICE_client_drop (nc->client); 2120 GNUNET_SERVICE_client_drop (nc->client);
2115 return; 2121 return;
2116 } 2122 }
2117 if (GNUNET_NO == ztn_ctx.success) 2123 if (GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND == ztn_ctx.ec)
2118 { 2124 {
2119 /* no result found, send empty response */ 2125 /* no result found, send empty response */
2120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2122,7 +2128,7 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2122 env = GNUNET_MQ_msg (ztnr_msg, 2128 env = GNUNET_MQ_msg (ztnr_msg,
2123 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); 2129 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE);
2124 ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id; 2130 ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id;
2125 ztnr_msg->res = htons (GNUNET_NO); 2131 ztnr_msg->ec = htonl (GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND);
2126 GNUNET_MQ_send (nc->mq, env); 2132 GNUNET_MQ_send (nc->mq, env);
2127 } 2133 }
2128 GNUNET_SERVICE_client_continue (nc->client); 2134 GNUNET_SERVICE_client_continue (nc->client);
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index 9ae0fb146..0094baf0e 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -924,36 +924,26 @@ process_record (void *cls, const struct GNUNET_DNSPARSER_Record *rec)
924} 924}
925 925
926 926
927/**
928 * Continuation called to notify client about result of the
929 * operation.
930 *
931 * @param cls closure with our `struct Request`
932 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
933 * #GNUNET_NO if content was already there or not found
934 * #GNUNET_YES (or other positive value) on success
935 * @param emsg NULL on success, otherwise an error message
936 */
937static void 927static void
938store_completed_cb (void *cls, int32_t success, const char *emsg) 928store_completed_cb (void *cls, enum GNUNET_ErrorCode ec)
939{ 929{
940 static struct GNUNET_TIME_Absolute last; 930 static struct GNUNET_TIME_Absolute last;
941 struct Request *req = cls; 931 struct Request *req = cls;
942 932
943 req->qe = NULL; 933 req->qe = NULL;
944 if (GNUNET_SYSERR == success) 934 if (GNUNET_EC_NONE != ec)
945 { 935 {
946 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 936 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
947 "Failed to store zone data for `%s': %s\n", 937 "Failed to store zone data for `%s': %s\n",
948 req->hostname, 938 req->hostname,
949 emsg); 939 GNUNET_ErrorCode_get_hint (ec));
950 } 940 }
951 else 941 else
952 { 942 {
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
954 "Stored records under `%s' (%d)\n", 944 "Stored records under `%s' (%d)\n",
955 req->hostname, 945 req->hostname,
956 success); 946 ec);
957 } 947 }
958 total_reg_proc_dns_ns++; /* finished regular processing */ 948 total_reg_proc_dns_ns++; /* finished regular processing */
959 pending_rs--; 949 pending_rs--;
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index ea35269a4..37c1576bc 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -117,23 +117,10 @@ struct RecordStoreResponseMessage
117 struct GNUNET_NAMESTORE_Header gns_header; 117 struct GNUNET_NAMESTORE_Header gns_header;
118 118
119 /** 119 /**
120 * #GNUNET_SYSERR on failure, #GNUNET_OK on success 120 * GNUNET_ErrorCode
121 */ 121 */
122 int32_t op_result GNUNET_PACKED; 122 uint32_t ec GNUNET_PACKED;
123 123
124 /**
125 * Error message length
126 */
127 uint16_t emsg_len GNUNET_PACKED;
128
129 /**
130 * Reserved for alignment.
131 */
132 uint16_t reserved GNUNET_PACKED;
133
134 /**
135 * Followed by error message
136 */
137}; 124};
138 125
139 126
@@ -264,10 +251,12 @@ struct ZoneToNameResponseMessage
264 uint16_t rd_count GNUNET_PACKED; 251 uint16_t rd_count GNUNET_PACKED;
265 252
266 /** 253 /**
267 * result in NBO: #GNUNET_OK on success, #GNUNET_NO if there were no 254 * result in NBO: #GNUNET_EC_NONE on success,
268 * results, #GNUNET_SYSERR on error 255 * #GNUNET_EC_NAMESTORE_NO_RESULTS if there were no
256 * results.
257 * Other error messages on error.
269 */ 258 */
270 int16_t res GNUNET_PACKED; 259 int32_t ec GNUNET_PACKED;
271 260
272 /** 261 /**
273 * The private key of the zone that contained the name. 262 * The private key of the zone that contained the name.
@@ -361,18 +350,10 @@ struct TxControlResultMessage
361 struct GNUNET_NAMESTORE_Header gns_header; 350 struct GNUNET_NAMESTORE_Header gns_header;
362 351
363 /** 352 /**
364 * The type of control message to send 353 * Of type GNUNET_ErrorCode
365 */
366 uint16_t control GNUNET_PACKED;
367
368 /**
369 * Of type GNUNET_GenericReturnValue
370 */ 354 */
371 uint16_t success GNUNET_PACKED; 355 uint32_t ec GNUNET_PACKED;
372 356
373 /* followed by:
374 * an error message if status != ntohs(GNUNET_OK)
375 */
376}; 357};
377 358
378 359
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 5111deee9..5c6bf73eb 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_error_codes.h"
30#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
31#include "gnunet_crypto_lib.h" 32#include "gnunet_crypto_lib.h"
32#include "gnunet_constants.h" 33#include "gnunet_constants.h"
@@ -368,25 +369,11 @@ static int
368check_record_store_response (void *cls, 369check_record_store_response (void *cls,
369 const struct RecordStoreResponseMessage *msg) 370 const struct RecordStoreResponseMessage *msg)
370{ 371{
371 const char *emsg;
372 size_t msg_len; 372 size_t msg_len;
373 size_t emsg_len;
374 373
375 (void) cls; 374 (void) cls;
376 msg_len = ntohs (msg->gns_header.header.size); 375 msg_len = ntohs (msg->gns_header.header.size);
377 emsg_len = ntohs (msg->emsg_len); 376 if (msg_len != sizeof(struct RecordStoreResponseMessage))
378 if (0 != ntohs (msg->reserved))
379 {
380 GNUNET_break (0);
381 return GNUNET_SYSERR;
382 }
383 if (msg_len != sizeof(struct RecordStoreResponseMessage) + emsg_len)
384 {
385 GNUNET_break (0);
386 return GNUNET_SYSERR;
387 }
388 emsg = (const char *) &msg[1];
389 if ((0 != emsg_len) && ('\0' != emsg[emsg_len - 1]))
390 { 377 {
391 GNUNET_break (0); 378 GNUNET_break (0);
392 return GNUNET_SYSERR; 379 return GNUNET_SYSERR;
@@ -408,20 +395,17 @@ handle_record_store_response (void *cls,
408{ 395{
409 struct GNUNET_NAMESTORE_Handle *h = cls; 396 struct GNUNET_NAMESTORE_Handle *h = cls;
410 struct GNUNET_NAMESTORE_QueueEntry *qe; 397 struct GNUNET_NAMESTORE_QueueEntry *qe;
411 int res; 398 enum GNUNET_ErrorCode res;
412 const char *emsg;
413 399
414 qe = find_qe (h, ntohl (msg->gns_header.r_id)); 400 qe = find_qe (h, ntohl (msg->gns_header.r_id));
415 emsg = (const char *) &msg[1]; 401 res = ntohl (msg->ec);
416 res = ntohl (msg->op_result);
417 LOG (GNUNET_ERROR_TYPE_DEBUG, 402 LOG (GNUNET_ERROR_TYPE_DEBUG,
418 "Received RECORD_STORE_RESPONSE with result %d\n", 403 "Received RECORD_STORE_RESPONSE with result %d\n",
419 res); 404 res);
420 if (NULL == qe) 405 if (NULL == qe)
421 return; 406 return;
422 if (NULL != qe->cont) 407 if (NULL != qe->cont)
423 qe->cont (qe->cont_cls, res, 408 qe->cont (qe->cont_cls, res);
424 (GNUNET_OK == res) ? NULL : emsg);
425 free_qe (qe); 409 free_qe (qe);
426} 410}
427 411
@@ -705,7 +689,7 @@ check_tx_control_result (void *cls,
705 (void) cls; 689 (void) cls;
706 err_len = ntohs (msg->gns_header.header.size) 690 err_len = ntohs (msg->gns_header.header.size)
707 - sizeof (struct TxControlResultMessage); 691 - sizeof (struct TxControlResultMessage);
708 if ((GNUNET_YES == ntohs (msg->success)) && (err_len > 0)) 692 if ((GNUNET_EC_NONE == ntohs (msg->ec)) && (err_len > 0))
709 { 693 {
710 GNUNET_break (0); 694 GNUNET_break (0);
711 return GNUNET_SYSERR; 695 return GNUNET_SYSERR;
@@ -725,20 +709,17 @@ handle_tx_control_result (void *cls,
725{ 709{
726 struct GNUNET_NAMESTORE_Handle *h = cls; 710 struct GNUNET_NAMESTORE_Handle *h = cls;
727 struct GNUNET_NAMESTORE_QueueEntry *qe; 711 struct GNUNET_NAMESTORE_QueueEntry *qe;
728 int res; 712 enum GNUNET_ErrorCode res;
729 const char *emsg;
730 713
731 qe = find_qe (h, ntohl (msg->gns_header.r_id)); 714 qe = find_qe (h, ntohl (msg->gns_header.r_id));
732 emsg = (const char *) &msg[1]; 715 res = ntohs (msg->ec);
733 res = ntohs (msg->success);
734 LOG (GNUNET_ERROR_TYPE_DEBUG, 716 LOG (GNUNET_ERROR_TYPE_DEBUG,
735 "Received TX_CONTROL_RESULT with result %d\n", 717 "Received TX_CONTROL_RESULT with result %d\n",
736 res); 718 res);
737 if (NULL == qe) 719 if (NULL == qe)
738 return; 720 return;
739 if (NULL != qe->cont) 721 if (NULL != qe->cont)
740 qe->cont (qe->cont_cls, res, 722 qe->cont (qe->cont_cls, res);
741 (GNUNET_YES == res) ? NULL : emsg);
742 free_qe (qe); 723 free_qe (qe);
743} 724}
744 725
@@ -759,7 +740,7 @@ check_zone_to_name_response (void *cls,
759 const char *name_tmp; 740 const char *name_tmp;
760 741
761 (void) cls; 742 (void) cls;
762 if (GNUNET_OK != ntohs (msg->res)) 743 if (GNUNET_EC_NONE != ntohl (msg->ec))
763 return GNUNET_OK; 744 return GNUNET_OK;
764 name_len = ntohs (msg->name_len); 745 name_len = ntohs (msg->name_len);
765 rd_ser_len = ntohs (msg->rd_len); 746 rd_ser_len = ntohs (msg->rd_len);
@@ -792,7 +773,7 @@ handle_zone_to_name_response (void *cls,
792{ 773{
793 struct GNUNET_NAMESTORE_Handle *h = cls; 774 struct GNUNET_NAMESTORE_Handle *h = cls;
794 struct GNUNET_NAMESTORE_QueueEntry *qe; 775 struct GNUNET_NAMESTORE_QueueEntry *qe;
795 int res; 776 enum GNUNET_ErrorCode res;
796 size_t name_len; 777 size_t name_len;
797 size_t rd_ser_len; 778 size_t rd_ser_len;
798 unsigned int rd_count; 779 unsigned int rd_count;
@@ -807,15 +788,12 @@ handle_zone_to_name_response (void *cls,
807 "Response queue already gone...\n"); 788 "Response queue already gone...\n");
808 return; 789 return;
809 } 790 }
810 res = ntohs (msg->res); 791 res = ntohl (msg->ec);
811 switch (res) 792 switch (res)
812 { 793 {
813 case GNUNET_SYSERR: 794 break;
814 LOG (GNUNET_ERROR_TYPE_DEBUG,
815 "An error occurred during zone to name operation\n");
816 break;
817 795
818 case GNUNET_NO: 796 case GNUNET_EC_NAMESTORE_NO_RESULTS:
819 LOG (GNUNET_ERROR_TYPE_DEBUG, 797 LOG (GNUNET_ERROR_TYPE_DEBUG,
820 "Namestore has no result for zone to name mapping \n"); 798 "Namestore has no result for zone to name mapping \n");
821 if (NULL != qe->proc) 799 if (NULL != qe->proc)
@@ -823,7 +801,7 @@ handle_zone_to_name_response (void *cls,
823 free_qe (qe); 801 free_qe (qe);
824 return; 802 return;
825 803
826 case GNUNET_YES: 804 case GNUNET_EC_NONE:
827 LOG (GNUNET_ERROR_TYPE_DEBUG, 805 LOG (GNUNET_ERROR_TYPE_DEBUG,
828 "Namestore has result for zone to name mapping \n"); 806 "Namestore has result for zone to name mapping \n");
829 name_len = ntohs (msg->name_len); 807 name_len = ntohs (msg->name_len);
@@ -848,9 +826,10 @@ handle_zone_to_name_response (void *cls,
848 } 826 }
849 827
850 default: 828 default:
851 GNUNET_break (0); 829 LOG (GNUNET_ERROR_TYPE_DEBUG,
852 force_reconnect (h); 830 "An error occurred during zone to name operation: %s\n",
853 return; 831 GNUNET_ErrorCode_get_hint (res));
832 break;
854 } 833 }
855 /* error case, call continuation with error */ 834 /* error case, call continuation with error */
856 if (NULL != qe->error_cb) 835 if (NULL != qe->error_cb)
@@ -886,10 +865,10 @@ static void
886reconnect (struct GNUNET_NAMESTORE_Handle *h) 865reconnect (struct GNUNET_NAMESTORE_Handle *h)
887{ 866{
888 struct GNUNET_MQ_MessageHandler handlers[] = 867 struct GNUNET_MQ_MessageHandler handlers[] =
889 { GNUNET_MQ_hd_var_size (record_store_response, 868 { GNUNET_MQ_hd_fixed_size (record_store_response,
890 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE, 869 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE,
891 struct RecordStoreResponseMessage, 870 struct RecordStoreResponseMessage,
892 h), 871 h),
893 GNUNET_MQ_hd_var_size (zone_to_name_response, 872 GNUNET_MQ_hd_var_size (zone_to_name_response,
894 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, 873 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE,
895 struct ZoneToNameResponseMessage, 874 struct ZoneToNameResponseMessage,
@@ -906,10 +885,10 @@ reconnect (struct GNUNET_NAMESTORE_Handle *h)
906 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE, 885 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE,
907 struct LabelLookupResponseMessage, 886 struct LabelLookupResponseMessage,
908 h), 887 h),
909 GNUNET_MQ_hd_var_size (tx_control_result, 888 GNUNET_MQ_hd_fixed_size (tx_control_result,
910 GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT, 889 GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT,
911 struct TxControlResultMessage, 890 struct TxControlResultMessage,
912 h), 891 h),
913 GNUNET_MQ_handler_end () }; 892 GNUNET_MQ_handler_end () };
914 struct GNUNET_NAMESTORE_ZoneIterator *it; 893 struct GNUNET_NAMESTORE_ZoneIterator *it;
915 struct GNUNET_NAMESTORE_QueueEntry *qe; 894 struct GNUNET_NAMESTORE_QueueEntry *qe;
@@ -973,8 +952,7 @@ force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
973 qe->error_cb (qe->error_cb_cls); 952 qe->error_cb (qe->error_cb_cls);
974 if (NULL != qe->cont) 953 if (NULL != qe->cont)
975 qe->cont (qe->cont_cls, 954 qe->cont (qe->cont_cls,
976 GNUNET_SYSERR, 955 GNUNET_EC_NAMESTORE_UNKNOWN);
977 "failure in communication with namestore service");
978 free_qe (qe); 956 free_qe (qe);
979 } 957 }
980 958
@@ -1078,7 +1056,7 @@ warn_delay (void *cls)
1078 GNUNET_YES)); 1056 GNUNET_YES));
1079 if (NULL != qe->cont) 1057 if (NULL != qe->cont)
1080 { 1058 {
1081 qe->cont (qe->cont_cls, GNUNET_SYSERR, "timeout"); 1059 qe->cont (qe->cont_cls, GNUNET_EC_NAMESTORE_UNKNOWN);
1082 qe->cont = NULL; 1060 qe->cont = NULL;
1083 } 1061 }
1084 GNUNET_NAMESTORE_cancel (qe); 1062 GNUNET_NAMESTORE_cancel (qe);
diff --git a/src/namestore/perf_namestore_api_import.c b/src/namestore/perf_namestore_api_import.c
index 0bc70b70b..4452de16c 100644
--- a/src/namestore/perf_namestore_api_import.c
+++ b/src/namestore/perf_namestore_api_import.c
@@ -151,14 +151,13 @@ publish_records_single (void *cls);
151 151
152static void 152static void
153commit_cont (void *cls, 153commit_cont (void *cls,
154 int32_t success, 154 enum GNUNET_ErrorCode ec)
155 const char *emsg)
156{ 155{
157 struct GNUNET_TIME_Relative delay; 156 struct GNUNET_TIME_Relative delay;
158 157
159 (void) cls; 158 (void) cls;
160 qe = NULL; 159 qe = NULL;
161 if (GNUNET_OK != success) 160 if (GNUNET_EC_NONE != ec)
162 { 161 {
163 GNUNET_break (0); 162 GNUNET_break (0);
164 GNUNET_SCHEDULER_shutdown (); 163 GNUNET_SCHEDULER_shutdown ();
@@ -181,11 +180,10 @@ publish_records_bulk_tx (void *cls);
181 180
182static void 181static void
183put_cont_bulk_tx (void *cls, 182put_cont_bulk_tx (void *cls,
184 int32_t success, 183 enum GNUNET_ErrorCode ec)
185 const char *emsg)
186{ 184{
187 qe = NULL; 185 qe = NULL;
188 if (GNUNET_OK != success) 186 if (GNUNET_EC_NONE != ec)
189 { 187 {
190 GNUNET_break (0); 188 GNUNET_break (0);
191 GNUNET_SCHEDULER_shutdown (); 189 GNUNET_SCHEDULER_shutdown ();
@@ -219,8 +217,7 @@ publish_records_bulk_tx (void *cls)
219 217
220static void 218static void
221begin_cont (void *cls, 219begin_cont (void *cls,
222 int32_t success, 220 enum GNUNET_ErrorCode ec)
223 const char *emsg)
224{ 221{
225 unsigned int sent_rds; 222 unsigned int sent_rds;
226 qe = GNUNET_NAMESTORE_records_store2 (nsh, 223 qe = GNUNET_NAMESTORE_records_store2 (nsh,
@@ -239,14 +236,13 @@ publish_records_bulk (void *cls);
239 236
240static void 237static void
241put_cont_bulk (void *cls, 238put_cont_bulk (void *cls,
242 int32_t success, 239 enum GNUNET_ErrorCode ec)
243 const char *emsg)
244{ 240{
245 struct GNUNET_TIME_Relative delay; 241 struct GNUNET_TIME_Relative delay;
246 242
247 (void) cls; 243 (void) cls;
248 qe = NULL; 244 qe = NULL;
249 if (GNUNET_OK != success) 245 if (GNUNET_EC_NONE != ec)
250 { 246 {
251 GNUNET_break (0); 247 GNUNET_break (0);
252 GNUNET_SCHEDULER_shutdown (); 248 GNUNET_SCHEDULER_shutdown ();
@@ -268,7 +264,7 @@ put_cont_bulk (void *cls,
268 } 264 }
269 (void) cls; 265 (void) cls;
270 qe = NULL; 266 qe = NULL;
271 if (GNUNET_OK != success) 267 if (GNUNET_EC_NONE != ec)
272 { 268 {
273 GNUNET_break (0); 269 GNUNET_break (0);
274 GNUNET_SCHEDULER_shutdown (); 270 GNUNET_SCHEDULER_shutdown ();
@@ -297,13 +293,12 @@ publish_records_bulk (void *cls)
297 293
298static void 294static void
299put_cont_single (void *cls, 295put_cont_single (void *cls,
300 int32_t success, 296 enum GNUNET_ErrorCode ec)
301 const char *emsg)
302{ 297{
303 struct GNUNET_TIME_Relative delay; 298 struct GNUNET_TIME_Relative delay;
304 (void) cls; 299 (void) cls;
305 qe = NULL; 300 qe = NULL;
306 if (GNUNET_OK != success) 301 if (GNUNET_EC_NONE != ec)
307 { 302 {
308 GNUNET_break (0); 303 GNUNET_break (0);
309 GNUNET_SCHEDULER_shutdown (); 304 GNUNET_SCHEDULER_shutdown ();
diff --git a/src/namestore/perf_namestore_api_zone_iteration.c b/src/namestore/perf_namestore_api_zone_iteration.c
index ce1cddf87..33868784f 100644
--- a/src/namestore/perf_namestore_api_zone_iteration.c
+++ b/src/namestore/perf_namestore_api_zone_iteration.c
@@ -266,12 +266,11 @@ publish_record (void *cls);
266 266
267static void 267static void
268put_cont (void *cls, 268put_cont (void *cls,
269 int32_t success, 269 enum GNUNET_ErrorCode ec)
270 const char *emsg)
271{ 270{
272 (void) cls; 271 (void) cls;
273 qe = NULL; 272 qe = NULL;
274 if (GNUNET_OK != success) 273 if (GNUNET_EC_NONE != ec)
275 { 274 {
276 GNUNET_break (0); 275 GNUNET_break (0);
277 GNUNET_SCHEDULER_shutdown (); 276 GNUNET_SCHEDULER_shutdown ();
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c
index fcc6068e8..05495c23b 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_error_codes.h"
28#include "gnunet_rest_plugin.h" 29#include "gnunet_rest_plugin.h"
29#include "gnunet_gns_service.h" 30#include "gnunet_gns_service.h"
30#include "gnunet_namestore_service.h" 31#include "gnunet_namestore_service.h"
@@ -45,37 +46,6 @@
45#define GNUNET_REST_API_NS_NAMESTORE_IMPORT "/namestore/import" 46#define GNUNET_REST_API_NS_NAMESTORE_IMPORT "/namestore/import"
46 47
47/** 48/**
48 * Error message Unknown Error
49 */
50#define GNUNET_REST_NAMESTORE_ERROR_UNKNOWN "Unknown Error"
51
52/**
53 * Error message No identity found
54 */
55#define GNUNET_REST_IDENTITY_NOT_FOUND "Zone not found"
56
57/**
58 * Error message No record found
59 */
60#define GNUNET_REST_RECORD_NOT_FOUND "Record not found"
61
62
63/**
64 * Error message Failed request
65 */
66#define GNUNET_REST_NAMESTORE_FAILED "Namestore action failed"
67
68/**
69 * Error message invalid data
70 */
71#define GNUNET_REST_NAMESTORE_INVALID_DATA "Data invalid"
72
73/**
74 * Error message No data
75 */
76#define GNUNET_REST_NAMESTORE_NO_DATA "No data"
77
78/**
79 * State while collecting all egos 49 * State while collecting all egos
80 */ 50 */
81#define ID_REST_STATE_INIT 0 51#define ID_REST_STATE_INIT 0
@@ -287,14 +257,10 @@ struct RequestHandle
287 char *url; 257 char *url;
288 258
289 /** 259 /**
290 * Error response message 260 * Error code
291 */ 261 */
292 char *emsg; 262 enum GNUNET_ErrorCode ec;
293 263
294 /**
295 * Response code
296 */
297 int response_code;
298}; 264};
299 265
300/** 266/**
@@ -327,8 +293,6 @@ cleanup_handle (void *cls)
327 GNUNET_free (handle->record_name); 293 GNUNET_free (handle->record_name);
328 if (NULL != handle->url) 294 if (NULL != handle->url)
329 GNUNET_free (handle->url); 295 GNUNET_free (handle->url);
330 if (NULL != handle->emsg)
331 GNUNET_free (handle->emsg);
332 if (NULL != handle->rd) 296 if (NULL != handle->rd)
333 { 297 {
334 for (int i = 0; i < handle->rd_count; i++) 298 for (int i = 0; i < handle->rd_count; i++)
@@ -369,20 +333,22 @@ do_error (void *cls)
369 struct MHD_Response *resp; 333 struct MHD_Response *resp;
370 json_t *json_error = json_object (); 334 json_t *json_error = json_object ();
371 char *response; 335 char *response;
336 const char* emsg;
337 int response_code;
372 338
373 if (NULL == handle->emsg) 339 if (0 != handle->ec)
374 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_ERROR_UNKNOWN); 340 emsg = GNUNET_strdup (GNUNET_ErrorCode_get_hint (handle->ec));
375 341 json_object_set_new (json_error, "error", json_string (emsg));
376 json_object_set_new (json_error, "error", json_string (handle->emsg));
377 342
378 if (0 == handle->response_code) 343 response_code = GNUNET_ErrorCode_get_http_status (handle->ec);
379 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; 344 if (0 == response_code)
345 response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
380 response = json_dumps (json_error, 0); 346 response = json_dumps (json_error, 0);
381 resp = GNUNET_REST_create_response (response); 347 resp = GNUNET_REST_create_response (response);
382 GNUNET_assert (MHD_YES == 348 GNUNET_assert (MHD_YES ==
383 MHD_add_response_header (resp, "Content-Type", 349 MHD_add_response_header (resp, "Content-Type",
384 "application/json")); 350 "application/json"));
385 handle->proc (handle->proc_cls, resp, handle->response_code); 351 handle->proc (handle->proc_cls, resp, response_code);
386 json_decref (json_error); 352 json_decref (json_error);
387 GNUNET_free (response); 353 GNUNET_free (response);
388 cleanup_handle (handle); 354 cleanup_handle (handle);
@@ -433,35 +399,22 @@ namestore_iteration_error (void *cls)
433{ 399{
434 struct RequestHandle *handle = cls; 400 struct RequestHandle *handle = cls;
435 401
436 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 402 handle->ec = GNUNET_EC_NAMESTORE_ITERATION_FAILED;
437 GNUNET_SCHEDULER_add_now (&do_error, handle); 403 GNUNET_SCHEDULER_add_now (&do_error, handle);
438 return; 404 return;
439} 405}
440 406
441 407
442/**
443 * Create finished callback
444 *
445 * @param cls the `struct RequestHandle`
446 * @param success the success indicating integer, GNUNET_OK on success
447 * @param emsg the error message (can be NULL)
448 */
449static void 408static void
450create_finished (void *cls, int32_t success, const char *emsg) 409create_finished (void *cls, enum GNUNET_ErrorCode ec)
451{ 410{
452 struct RequestHandle *handle = cls; 411 struct RequestHandle *handle = cls;
453 struct MHD_Response *resp; 412 struct MHD_Response *resp;
454 413
455 handle->ns_qe = NULL; 414 handle->ns_qe = NULL;
456 if (GNUNET_YES != success) 415 handle->ec = ec;
416 if (GNUNET_EC_NONE != ec)
457 { 417 {
458 if (NULL != emsg)
459 {
460 handle->emsg = GNUNET_strdup (emsg);
461 GNUNET_SCHEDULER_add_now (&do_error, handle);
462 return;
463 }
464 handle->emsg = GNUNET_strdup ("Error storing records");
465 GNUNET_SCHEDULER_add_now (&do_error, handle); 418 GNUNET_SCHEDULER_add_now (&do_error, handle);
466 return; 419 return;
467 } 420 }
@@ -471,35 +424,15 @@ create_finished (void *cls, int32_t success, const char *emsg)
471} 424}
472 425
473 426
474/**
475 * Delete finished callback
476 *
477 * @param cls the `struct RequestHandle`
478 * @param success the success indicating integer, GNUNET_OK on success
479 * @param emsg the error message (can be NULL)
480 */
481static void 427static void
482del_finished (void *cls, int32_t success, const char *emsg) 428del_finished (void *cls, enum GNUNET_ErrorCode ec)
483{ 429{
484 struct RequestHandle *handle = cls; 430 struct RequestHandle *handle = cls;
485 431
486 handle->ns_qe = NULL; 432 handle->ns_qe = NULL;
487 if (GNUNET_NO == success) 433 handle->ec = ec;
434 if (GNUNET_EC_NONE != ec)
488 { 435 {
489 handle->response_code = MHD_HTTP_NOT_FOUND;
490 handle->emsg = GNUNET_strdup ("No record found");
491 GNUNET_SCHEDULER_add_now (&do_error, handle);
492 return;
493 }
494 if (GNUNET_SYSERR == success)
495 {
496 if (NULL != emsg)
497 {
498 handle->emsg = GNUNET_strdup (emsg);
499 GNUNET_SCHEDULER_add_now (&do_error, handle);
500 return;
501 }
502 handle->emsg = GNUNET_strdup ("Deleting record failed");
503 GNUNET_SCHEDULER_add_now (&do_error, handle); 436 GNUNET_SCHEDULER_add_now (&do_error, handle);
504 return; 437 return;
505 } 438 }
@@ -527,8 +460,7 @@ namestore_list_finished (void *cls)
527 460
528 if (NULL == handle->resp_object) 461 if (NULL == handle->resp_object)
529 { 462 {
530 handle->response_code = MHD_HTTP_NOT_FOUND; 463 handle->ec = GNUNET_EC_NAMESTORE_ZONE_EMPTY;
531 handle->emsg = GNUNET_strdup (GNUNET_REST_RECORD_NOT_FOUND);
532 GNUNET_SCHEDULER_add_now (&do_error, handle); 464 GNUNET_SCHEDULER_add_now (&do_error, handle);
533 return; 465 return;
534 } 466 }
@@ -603,7 +535,7 @@ ns_lookup_error_cb (void *cls)
603{ 535{
604 struct RequestHandle *handle = cls; 536 struct RequestHandle *handle = cls;
605 537
606 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 538 handle->ec = GNUNET_EC_NAMESTORE_LOOKUP_ERROR;
607 GNUNET_SCHEDULER_add_now (&do_error, handle); 539 GNUNET_SCHEDULER_add_now (&do_error, handle);
608} 540}
609 541
@@ -633,8 +565,7 @@ ns_get_lookup_cb (void *cls,
633 /** Return 404 if no set was found **/ 565 /** Return 404 if no set was found **/
634 if (j == 0) 566 if (j == 0)
635 { 567 {
636 handle->response_code = MHD_HTTP_NOT_FOUND; 568 handle->ec = GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND;
637 handle->emsg = GNUNET_strdup (GNUNET_REST_RECORD_NOT_FOUND);
638 GNUNET_SCHEDULER_add_now (&do_error, handle); 569 GNUNET_SCHEDULER_add_now (&do_error, handle);
639 return; 570 return;
640 } 571 }
@@ -672,8 +603,7 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
672 // set zone to name if given 603 // set zone to name if given
673 if (strlen (GNUNET_REST_API_NS_NAMESTORE) + 1 >= strlen (handle->url)) 604 if (strlen (GNUNET_REST_API_NS_NAMESTORE) + 1 >= strlen (handle->url))
674 { 605 {
675 handle->response_code = MHD_HTTP_NOT_FOUND; 606 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
676 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
677 GNUNET_SCHEDULER_add_now (&do_error, handle); 607 GNUNET_SCHEDULER_add_now (&do_error, handle);
678 return; 608 return;
679 } 609 }
@@ -681,8 +611,7 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
681 ego_entry = get_egoentry_namestore (handle, egoname); 611 ego_entry = get_egoentry_namestore (handle, egoname);
682 if (NULL == ego_entry) 612 if (NULL == ego_entry)
683 { 613 {
684 handle->response_code = MHD_HTTP_NOT_FOUND; 614 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
685 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
686 GNUNET_SCHEDULER_add_now (&do_error, handle); 615 GNUNET_SCHEDULER_add_now (&do_error, handle);
687 return; 616 return;
688 } 617 }
@@ -738,7 +667,7 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
738 filter_flags); 667 filter_flags);
739 if (NULL == handle->list_it) 668 if (NULL == handle->list_it)
740 { 669 {
741 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 670 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
742 GNUNET_SCHEDULER_add_now (&do_error, handle); 671 GNUNET_SCHEDULER_add_now (&do_error, handle);
743 return; 672 return;
744 } 673 }
@@ -755,7 +684,7 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
755 filter_flags); 684 filter_flags);
756 if (NULL == handle->ns_qe) 685 if (NULL == handle->ns_qe)
757 { 686 {
758 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 687 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
759 GNUNET_SCHEDULER_add_now (&do_error, handle); 688 GNUNET_SCHEDULER_add_now (&do_error, handle);
760 return; 689 return;
761 } 690 }
@@ -790,7 +719,7 @@ ns_lookup_cb (void *cls,
790 handle); 719 handle);
791 if (NULL == handle->ns_qe) 720 if (NULL == handle->ns_qe)
792 { 721 {
793 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 722 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
794 GNUNET_SCHEDULER_add_now (&do_error, handle); 723 GNUNET_SCHEDULER_add_now (&do_error, handle);
795 return; 724 return;
796 } 725 }
@@ -798,23 +727,17 @@ ns_lookup_cb (void *cls,
798 727
799 728
800static void 729static void
801bulk_tx_commit_cb (void *cls, int32_t success, const char *emsg) 730bulk_tx_commit_cb (void *cls, enum GNUNET_ErrorCode ec)
802{ 731{
803 struct RequestHandle *handle = cls; 732 struct RequestHandle *handle = cls;
804 struct MHD_Response *resp; 733 struct MHD_Response *resp;
805 734
806 handle->ns_qe = NULL; 735 handle->ns_qe = NULL;
807 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 736 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
808 "Commit finished, %d\n", success); 737 "Commit finished (%d)\n", ec);
809 if (GNUNET_YES != success) 738 handle->ec = ec;
739 if (GNUNET_EC_NONE != ec)
810 { 740 {
811 if (NULL != emsg)
812 {
813 handle->emsg = GNUNET_strdup (emsg);
814 GNUNET_SCHEDULER_add_now (&do_error, handle);
815 return;
816 }
817 handle->emsg = GNUNET_strdup ("Error importing records on commit");
818 GNUNET_SCHEDULER_add_now (&do_error, handle); 741 GNUNET_SCHEDULER_add_now (&do_error, handle);
819 return; 742 return;
820 } 743 }
@@ -824,30 +747,17 @@ bulk_tx_commit_cb (void *cls, int32_t success, const char *emsg)
824} 747}
825 748
826 749
827/**
828 * Import callback
829 *
830 * @param cls the `struct RequestHandle`
831 * @param success the success indicating integer, GNUNET_OK on success
832 * @param emsg the error message (can be NULL)
833 */
834static void 750static void
835import_next_cb (void *cls, int32_t success, const char *emsg) 751import_next_cb (void *cls, enum GNUNET_ErrorCode ec)
836{ 752{
837 struct RequestHandle *handle = cls; 753 struct RequestHandle *handle = cls;
838 754
839 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
840 "Import finished, %d\n", success); 756 "Import finished (%d)\n", ec);
841 handle->ns_qe = NULL; 757 handle->ns_qe = NULL;
842 if (GNUNET_YES != success) 758 handle->ec = ec;
759 if (GNUNET_EC_NONE != ec)
843 { 760 {
844 if (NULL != emsg)
845 {
846 handle->emsg = GNUNET_strdup (emsg);
847 GNUNET_SCHEDULER_add_now (&do_error, handle);
848 return;
849 }
850 handle->emsg = GNUNET_strdup ("Error importing records");
851 GNUNET_SCHEDULER_add_now (&do_error, handle); 761 GNUNET_SCHEDULER_add_now (&do_error, handle);
852 return; 762 return;
853 } 763 }
@@ -872,7 +782,7 @@ import_next_cb (void *cls, int32_t success, const char *emsg)
872 handle); 782 handle);
873 if ((NULL == handle->ns_qe) && (0 == sent_rds)) 783 if ((NULL == handle->ns_qe) && (0 == sent_rds))
874 { 784 {
875 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 785 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
876 GNUNET_SCHEDULER_add_now (&do_error, handle); 786 GNUNET_SCHEDULER_add_now (&do_error, handle);
877 return; 787 return;
878 } 788 }
@@ -880,7 +790,7 @@ import_next_cb (void *cls, int32_t success, const char *emsg)
880} 790}
881 791
882static void 792static void
883bulk_tx_start (void *cls, int32_t success, const char *emsg) 793bulk_tx_start (void *cls, enum GNUNET_ErrorCode ec)
884{ 794{
885 struct RequestHandle *handle = cls; 795 struct RequestHandle *handle = cls;
886 json_t *data_js; 796 json_t *data_js;
@@ -888,10 +798,15 @@ bulk_tx_start (void *cls, int32_t success, const char *emsg)
888 798
889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 799 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
890 "Transaction started...\n"); 800 "Transaction started...\n");
801 handle->ec = ec;
802 if (GNUNET_EC_NONE != ec)
803 {
804 GNUNET_SCHEDULER_add_now (&do_error, handle);
805 return;
806 }
891 if (0 >= handle->rest_handle->data_size) 807 if (0 >= handle->rest_handle->data_size)
892 { 808 {
893 handle->response_code = MHD_HTTP_BAD_REQUEST; 809 handle->ec = GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN;
894 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DATA);
895 GNUNET_SCHEDULER_add_now (&do_error, handle); 810 GNUNET_SCHEDULER_add_now (&do_error, handle);
896 return; 811 return;
897 } 812 }
@@ -903,13 +818,15 @@ bulk_tx_start (void *cls, int32_t success, const char *emsg)
903 data_js = json_loads (term_data, JSON_DECODE_ANY, &err); 818 data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
904 if (NULL == data_js) 819 if (NULL == data_js)
905 { 820 {
906 GNUNET_asprintf (&handle->emsg, "Error parsing data: %s", err.text); 821 handle->ec = GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
822 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
823 "Error parsing data: %s", err.text);
907 GNUNET_SCHEDULER_add_now (&do_error, handle); 824 GNUNET_SCHEDULER_add_now (&do_error, handle);
908 return; 825 return;
909 } 826 }
910 if (! json_is_array (data_js)) 827 if (! json_is_array (data_js))
911 { 828 {
912 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA); 829 handle->ec = GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
913 GNUNET_SCHEDULER_add_now (&do_error, handle); 830 GNUNET_SCHEDULER_add_now (&do_error, handle);
914 json_decref (data_js); 831 json_decref (data_js);
915 return; 832 return;
@@ -932,7 +849,7 @@ bulk_tx_start (void *cls, int32_t success, const char *emsg)
932 GNUNET_JSON_spec_end () }; 849 GNUNET_JSON_spec_end () };
933 if (GNUNET_OK != GNUNET_JSON_parse (value, gnsspec, NULL, NULL)) 850 if (GNUNET_OK != GNUNET_JSON_parse (value, gnsspec, NULL, NULL))
934 { 851 {
935 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA); 852 handle->ec = GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
936 GNUNET_SCHEDULER_add_now (&do_error, handle); 853 GNUNET_SCHEDULER_add_now (&do_error, handle);
937 json_decref (data_js); 854 json_decref (data_js);
938 return; 855 return;
@@ -958,7 +875,7 @@ bulk_tx_start (void *cls, int32_t success, const char *emsg)
958 handle); 875 handle);
959 if ((NULL == handle->ns_qe) && (0 == sent_rds)) 876 if ((NULL == handle->ns_qe) && (0 == sent_rds))
960 { 877 {
961 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 878 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
962 GNUNET_SCHEDULER_add_now (&do_error, handle); 879 GNUNET_SCHEDULER_add_now (&do_error, handle);
963 return; 880 return;
964 } 881 }
@@ -986,8 +903,7 @@ namestore_import (struct GNUNET_REST_RequestHandle *con_handle,
986 if (strlen (GNUNET_REST_API_NS_NAMESTORE_IMPORT) + 1 >= strlen ( 903 if (strlen (GNUNET_REST_API_NS_NAMESTORE_IMPORT) + 1 >= strlen (
987 handle->url)) 904 handle->url))
988 { 905 {
989 handle->response_code = MHD_HTTP_NOT_FOUND; 906 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
990 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
991 GNUNET_SCHEDULER_add_now (&do_error, handle); 907 GNUNET_SCHEDULER_add_now (&do_error, handle);
992 return; 908 return;
993 } 909 }
@@ -998,8 +914,7 @@ namestore_import (struct GNUNET_REST_RequestHandle *con_handle,
998 914
999 if (NULL == ego_entry) 915 if (NULL == ego_entry)
1000 { 916 {
1001 handle->response_code = MHD_HTTP_NOT_FOUND; 917 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
1002 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1003 GNUNET_SCHEDULER_add_now (&do_error, handle); 918 GNUNET_SCHEDULER_add_now (&do_error, handle);
1004 return; 919 return;
1005 } 920 }
@@ -1009,8 +924,7 @@ namestore_import (struct GNUNET_REST_RequestHandle *con_handle,
1009 handle->nc = GNUNET_NAMESTORE_connect (cfg); 924 handle->nc = GNUNET_NAMESTORE_connect (cfg);
1010 if (NULL == handle->nc) 925 if (NULL == handle->nc)
1011 { 926 {
1012 handle->response_code = MHD_HTTP_BAD_REQUEST; 927 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
1013 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DATA);
1014 GNUNET_SCHEDULER_add_now (&do_error, handle); 928 GNUNET_SCHEDULER_add_now (&do_error, handle);
1015 return; 929 return;
1016 } 930 }
@@ -1041,8 +955,7 @@ namestore_add_or_update (struct GNUNET_REST_RequestHandle *con_handle,
1041 955
1042 if (0 >= handle->rest_handle->data_size) 956 if (0 >= handle->rest_handle->data_size)
1043 { 957 {
1044 handle->response_code = MHD_HTTP_BAD_REQUEST; 958 handle->ec = GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN;
1045 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DATA);
1046 GNUNET_SCHEDULER_add_now (&do_error, handle); 959 GNUNET_SCHEDULER_add_now (&do_error, handle);
1047 return; 960 return;
1048 } 961 }
@@ -1057,7 +970,7 @@ namestore_add_or_update (struct GNUNET_REST_RequestHandle *con_handle,
1057 GNUNET_JSON_spec_end () }; 970 GNUNET_JSON_spec_end () };
1058 if (GNUNET_OK != GNUNET_JSON_parse (data_js, gnsspec, NULL, NULL)) 971 if (GNUNET_OK != GNUNET_JSON_parse (data_js, gnsspec, NULL, NULL))
1059 { 972 {
1060 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA); 973 handle->ec = GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
1061 GNUNET_SCHEDULER_add_now (&do_error, handle); 974 GNUNET_SCHEDULER_add_now (&do_error, handle);
1062 json_decref (data_js); 975 json_decref (data_js);
1063 return; 976 return;
@@ -1065,8 +978,7 @@ namestore_add_or_update (struct GNUNET_REST_RequestHandle *con_handle,
1065 GNUNET_JSON_parse_free (gnsspec); 978 GNUNET_JSON_parse_free (gnsspec);
1066 if (0 >= strlen (handle->record_name)) 979 if (0 >= strlen (handle->record_name))
1067 { 980 {
1068 handle->response_code = MHD_HTTP_BAD_REQUEST; 981 handle->ec = GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID;
1069 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);
1070 GNUNET_SCHEDULER_add_now (&do_error, handle); 982 GNUNET_SCHEDULER_add_now (&do_error, handle);
1071 json_decref (data_js); 983 json_decref (data_js);
1072 return; 984 return;
@@ -1079,8 +991,7 @@ namestore_add_or_update (struct GNUNET_REST_RequestHandle *con_handle,
1079 // set zone to name if given 991 // set zone to name if given
1080 if (strlen (GNUNET_REST_API_NS_NAMESTORE) + 1 >= strlen (handle->url)) 992 if (strlen (GNUNET_REST_API_NS_NAMESTORE) + 1 >= strlen (handle->url))
1081 { 993 {
1082 handle->response_code = MHD_HTTP_NOT_FOUND; 994 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
1083 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1084 GNUNET_SCHEDULER_add_now (&do_error, handle); 995 GNUNET_SCHEDULER_add_now (&do_error, handle);
1085 return; 996 return;
1086 } 997 }
@@ -1089,8 +1000,7 @@ namestore_add_or_update (struct GNUNET_REST_RequestHandle *con_handle,
1089 1000
1090 if (NULL == ego_entry) 1001 if (NULL == ego_entry)
1091 { 1002 {
1092 handle->response_code = MHD_HTTP_NOT_FOUND; 1003 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
1093 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1094 GNUNET_SCHEDULER_add_now (&do_error, handle); 1004 GNUNET_SCHEDULER_add_now (&do_error, handle);
1095 return; 1005 return;
1096 } 1006 }
@@ -1104,7 +1014,7 @@ namestore_add_or_update (struct GNUNET_REST_RequestHandle *con_handle,
1104 handle); 1014 handle);
1105 if (NULL == handle->ns_qe) 1015 if (NULL == handle->ns_qe)
1106 { 1016 {
1107 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 1017 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
1108 GNUNET_SCHEDULER_add_now (&do_error, handle); 1018 GNUNET_SCHEDULER_add_now (&do_error, handle);
1109 return; 1019 return;
1110 } 1020 }
@@ -1170,8 +1080,7 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
1170 // set zone to name if given 1080 // set zone to name if given
1171 if (strlen (GNUNET_REST_API_NS_NAMESTORE) + 1 >= strlen (handle->url)) 1081 if (strlen (GNUNET_REST_API_NS_NAMESTORE) + 1 >= strlen (handle->url))
1172 { 1082 {
1173 handle->response_code = MHD_HTTP_NOT_FOUND; 1083 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
1174 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1175 GNUNET_SCHEDULER_add_now (&do_error, handle); 1084 GNUNET_SCHEDULER_add_now (&do_error, handle);
1176 return; 1085 return;
1177 } 1086 }
@@ -1179,8 +1088,7 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
1179 ego_entry = get_egoentry_namestore (handle, egoname); 1088 ego_entry = get_egoentry_namestore (handle, egoname);
1180 if (NULL == ego_entry) 1089 if (NULL == ego_entry)
1181 { 1090 {
1182 handle->response_code = MHD_HTTP_NOT_FOUND; 1091 handle->ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
1183 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1184 GNUNET_SCHEDULER_add_now (&do_error, handle); 1092 GNUNET_SCHEDULER_add_now (&do_error, handle);
1185 return; 1093 return;
1186 } 1094 }
@@ -1190,8 +1098,7 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
1190 if (1 >= strlen (labelname)) 1098 if (1 >= strlen (labelname))
1191 { 1099 {
1192 /* label is only "/" */ 1100 /* label is only "/" */
1193 handle->response_code = MHD_HTTP_BAD_REQUEST; 1101 handle->ec = GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN;
1194 handle->emsg = GNUNET_strdup ("Label missing");
1195 GNUNET_SCHEDULER_add_now (&do_error, handle); 1102 GNUNET_SCHEDULER_add_now (&do_error, handle);
1196 } 1103 }
1197 1104
@@ -1205,7 +1112,7 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
1205 handle); 1112 handle);
1206 if (NULL == handle->ns_qe) 1113 if (NULL == handle->ns_qe)
1207 { 1114 {
1208 handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED); 1115 handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
1209 GNUNET_SCHEDULER_add_now (&do_error, handle); 1116 GNUNET_SCHEDULER_add_now (&do_error, handle);
1210 return; 1117 return;
1211 } 1118 }
@@ -1350,7 +1257,7 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1350 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_NAMESTORE, &options_cont }, 1257 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_NAMESTORE, &options_cont },
1351 GNUNET_REST_HANDLER_END }; 1258 GNUNET_REST_HANDLER_END };
1352 1259
1353 handle->response_code = 0; 1260 handle->ec = GNUNET_EC_NONE;
1354 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1261 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
1355 handle->proc_cls = proc_cls; 1262 handle->proc_cls = proc_cls;
1356 handle->proc = proc; 1263 handle->proc = proc;
diff --git a/src/namestore/test_namestore_api_edit_records.c b/src/namestore/test_namestore_api_edit_records.c
index c1c64ee9c..ee05f498a 100644
--- a/src/namestore/test_namestore_api_edit_records.c
+++ b/src/namestore/test_namestore_api_edit_records.c
@@ -112,15 +112,14 @@ fail_cb (void *cls)
112 112
113static void 113static void
114remove_cont (void *cls, 114remove_cont (void *cls,
115 int32_t success, 115 enum GNUNET_ErrorCode ec)
116 const char *emsg)
117{ 116{
118 nsqe = NULL; 117 nsqe = NULL;
119 if (GNUNET_YES != success) 118 if (GNUNET_EC_NONE != ec)
120 { 119 {
121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 120 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
122 _ ("Unable to roll back: `%s'\n"), 121 _ ("Unable to roll back: `%s'\n"),
123 emsg); 122 GNUNET_ErrorCode_get_hint (ec));
124 if (NULL != endbadly_task) 123 if (NULL != endbadly_task)
125 GNUNET_SCHEDULER_cancel (endbadly_task); 124 GNUNET_SCHEDULER_cancel (endbadly_task);
126 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, 125 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
@@ -167,19 +166,18 @@ edit_cont_b (void *cls,
167 166
168static void 167static void
169commit_cont_a (void *cls, 168commit_cont_a (void *cls,
170 int32_t success, 169 enum GNUNET_ErrorCode ec)
171 const char *emsg)
172{ 170{
173 const char *name = cls; 171 const char *name = cls;
174 172
175 GNUNET_assert (NULL != cls); 173 GNUNET_assert (NULL != cls);
176 nsqe = NULL; 174 nsqe = NULL;
177 if (GNUNET_SYSERR == success) 175 if (GNUNET_EC_NONE != ec)
178 { 176 {
179 GNUNET_break (0); 177 GNUNET_break (0);
180 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 178 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
181 "Namestore could not store record: `%s'\n", 179 "Namestore could not store record: `%s'\n",
182 emsg); 180 GNUNET_ErrorCode_get_hint (ec));
183 if (endbadly_task != NULL) 181 if (endbadly_task != NULL)
184 GNUNET_SCHEDULER_cancel (endbadly_task); 182 GNUNET_SCHEDULER_cancel (endbadly_task);
185 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 183 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
@@ -226,12 +224,11 @@ fail_cb_lock (void *cls)
226 224
227static void 225static void
228begin_cont_b (void *cls, 226begin_cont_b (void *cls,
229 int32_t success, 227 enum GNUNET_ErrorCode ec)
230 const char *emsg)
231{ 228{
232 const char *name = cls; 229 const char *name = cls;
233 230
234 GNUNET_assert (success == GNUNET_YES); 231 GNUNET_assert (GNUNET_EC_NONE == ec);
235 /** Now, we expect this to "hang" let's see how this behaves in practice. */ 232 /** Now, we expect this to "hang" let's see how this behaves in practice. */
236 nsqe = GNUNET_NAMESTORE_records_edit (nsh2, 233 nsqe = GNUNET_NAMESTORE_records_edit (nsh2,
237 &privkey, 234 &privkey,
@@ -262,8 +259,7 @@ edit_cont (void *cls,
262 259
263static void 260static void
264begin_cont (void *cls, 261begin_cont (void *cls,
265 int32_t success, 262 enum GNUNET_ErrorCode ec)
266 const char *emsg)
267{ 263{
268 const char *name = cls; 264 const char *name = cls;
269 265
@@ -281,19 +277,18 @@ begin_cont (void *cls,
281 277
282static void 278static void
283preload_cont (void *cls, 279preload_cont (void *cls,
284 int32_t success, 280 enum GNUNET_ErrorCode ec)
285 const char *emsg)
286{ 281{
287 const char *name = cls; 282 const char *name = cls;
288 283
289 GNUNET_assert (NULL != cls); 284 GNUNET_assert (NULL != cls);
290 nsqe = NULL; 285 nsqe = NULL;
291 if (GNUNET_SYSERR == success) 286 if (GNUNET_EC_NONE != ec)
292 { 287 {
293 GNUNET_break (0); 288 GNUNET_break (0);
294 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 289 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
295 "Namestore could not store record: `%s'\n", 290 "Namestore could not store record: `%s'\n",
296 emsg); 291 GNUNET_ErroCode_get_hint (ec));
297 if (endbadly_task != NULL) 292 if (endbadly_task != NULL)
298 GNUNET_SCHEDULER_cancel (endbadly_task); 293 GNUNET_SCHEDULER_cancel (endbadly_task);
299 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 294 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
diff --git a/src/namestore/test_namestore_api_lookup_nick.c b/src/namestore/test_namestore_api_lookup_nick.c
index 7decf39f8..85a7a4025 100644
--- a/src/namestore/test_namestore_api_lookup_nick.c
+++ b/src/namestore/test_namestore_api_lookup_nick.c
@@ -225,7 +225,7 @@ fail_cb (void *cls)
225 225
226 226
227static void 227static void
228put_cont (void *cls, int32_t success, const char *emsg) 228put_cont (void *cls, enum GNUNET_ErrorCode ec)
229{ 229{
230 const char *name = cls; 230 const char *name = cls;
231 231
@@ -234,9 +234,9 @@ put_cont (void *cls, int32_t success, const char *emsg)
234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
235 "Name store added record for `%s': %s\n", 235 "Name store added record for `%s': %s\n",
236 name, 236 name,
237 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 237 (ec == GNUNET_EC_NONE) ? "SUCCESS" : "FAIL");
238 238
239 if (GNUNET_OK != success) 239 if (GNUNET_EC_NONE != ec)
240 { 240 {
241 GNUNET_SCHEDULER_cancel (endbadly_task); 241 GNUNET_SCHEDULER_cancel (endbadly_task);
242 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 242 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
@@ -254,13 +254,13 @@ put_cont (void *cls, int32_t success, const char *emsg)
254 254
255 255
256static void 256static void
257nick_cont (void *cls, int32_t success, const char *emsg) 257nick_cont (void *cls, enum GNUNET_ErrorCode ec)
258{ 258{
259 const char *name = cls; 259 const char *name = cls;
260 260
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
262 "Nick added : %s\n", 262 "Nick added : %s\n",
263 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 263 (ec == GNUNET_EC_NONE) ? "SUCCESS" : "FAIL");
264 264
265 rd_orig.expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; 265 rd_orig.expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us;
266 rd_orig.record_type = TEST_RECORD_TYPE; 266 rd_orig.record_type = TEST_RECORD_TYPE;
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c
index df0c38608..018cf89b1 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -198,8 +198,7 @@ zone_proc (void *cls,
198 198
199static void 199static void
200put_cont (void *cls, 200put_cont (void *cls,
201 int32_t success, 201 enum GNUNET_ErrorCode ec)
202 const char *emsg)
203{ 202{
204 static int c = 0; 203 static int c = 0;
205 char *label = cls; 204 char *label = cls;
@@ -211,7 +210,7 @@ put_cont (void *cls,
211 else if (0 == strcmp (label, s_name_3)) 210 else if (0 == strcmp (label, s_name_3))
212 ns_ops[2] = NULL; 211 ns_ops[2] = NULL;
213 212
214 if (success == GNUNET_OK) 213 if (GNUNET_EC_NONE == ec)
215 { 214 {
216 c++; 215 c++;
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c
index 1803b8ba4..0123613fb 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -214,8 +214,7 @@ sync_cb (void *cls)
214 214
215static void 215static void
216put_cont (void *cls, 216put_cont (void *cls,
217 int32_t success, 217 enum GNUNET_ErrorCode ec)
218 const char *emsg)
219{ 218{
220 static int c = 0; 219 static int c = 0;
221 const char *label = cls; 220 const char *label = cls;
@@ -230,7 +229,7 @@ put_cont (void *cls,
230 s_name_3)) 229 s_name_3))
231 ns_ops[2] = NULL; 230 ns_ops[2] = NULL;
232 231
233 if (success == GNUNET_OK) 232 if (GNUNET_EC_NONE == ec)
234 { 233 {
235 c++; 234 c++;
236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index c2b70f64a..c6a4549d4 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.c
@@ -90,15 +90,14 @@ end (void *cls)
90 90
91static void 91static void
92remove_cont (void *cls, 92remove_cont (void *cls,
93 int32_t success, 93 enum GNUNET_ErrorCode ec)
94 const char *emsg)
95{ 94{
96 nsqe = NULL; 95 nsqe = NULL;
97 if (GNUNET_YES != success) 96 if (GNUNET_EC_NONE != ec)
98 { 97 {
99 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 98 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
100 _ ("Records could not be removed: `%s'\n"), 99 _ ("Records could not be removed: `%s'\n"),
101 emsg); 100 GNUNET_ErrorCode_get_hint (ec));
102 if (NULL != endbadly_task) 101 if (NULL != endbadly_task)
103 GNUNET_SCHEDULER_cancel (endbadly_task); 102 GNUNET_SCHEDULER_cancel (endbadly_task);
104 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, 103 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
@@ -116,19 +115,18 @@ remove_cont (void *cls,
116 115
117static void 116static void
118put_cont (void *cls, 117put_cont (void *cls,
119 int32_t success, 118 enum GNUNET_ErrorCode ec)
120 const char *emsg)
121{ 119{
122 const char *name = cls; 120 const char *name = cls;
123 121
124 GNUNET_assert (NULL != cls); 122 GNUNET_assert (NULL != cls);
125 nsqe = NULL; 123 nsqe = NULL;
126 if (GNUNET_SYSERR == success) 124 if (GNUNET_EC_NONE != ec)
127 { 125 {
128 GNUNET_break (0); 126 GNUNET_break (0);
129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 127 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
130 "Namestore could not store record: `%s'\n", 128 "Namestore could not store record: `%s'\n",
131 emsg); 129 GNUNET_ErrorCode_get_hint (ec));
132 if (endbadly_task != NULL) 130 if (endbadly_task != NULL)
133 GNUNET_SCHEDULER_cancel (endbadly_task); 131 GNUNET_SCHEDULER_cancel (endbadly_task);
134 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 132 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
@@ -138,7 +136,7 @@ put_cont (void *cls,
138 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 136 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
139 "Name store added record for `%s': %s\n", 137 "Name store added record for `%s': %s\n",
140 name, 138 name,
141 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 139 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
142 nsqe = GNUNET_NAMESTORE_records_store (nsh, 140 nsqe = GNUNET_NAMESTORE_records_store (nsh,
143 &privkey, 141 &privkey,
144 name, 142 name,
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c
index 958ea4bf2..ea95a6b57 100644
--- a/src/namestore/test_namestore_api_remove_not_existing_record.c
+++ b/src/namestore/test_namestore_api_remove_not_existing_record.c
@@ -87,8 +87,7 @@ end (void *cls)
87 87
88static void 88static void
89put_cont (void *cls, 89put_cont (void *cls,
90 int32_t success, 90 enum GNUNET_ErrorCode ec)
91 const char *emsg)
92{ 91{
93 GNUNET_assert (NULL != cls); 92 GNUNET_assert (NULL != cls);
94 nsqe = NULL; 93 nsqe = NULL;
@@ -97,25 +96,24 @@ put_cont (void *cls,
97 GNUNET_SCHEDULER_cancel (endbadly_task); 96 GNUNET_SCHEDULER_cancel (endbadly_task);
98 endbadly_task = NULL; 97 endbadly_task = NULL;
99 } 98 }
100 switch (success) 99 switch (ec)
101 { 100 {
102 case GNUNET_NO: 101 case GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND:
103 /* We expected GNUNET_NO, since record was not found */ 102 /* We expect that the record is not found */
104 GNUNET_SCHEDULER_add_now (&end, NULL); 103 GNUNET_SCHEDULER_add_now (&end, NULL);
105 break; 104 break;
106 105
107 case GNUNET_OK: 106 case GNUNET_EC_NONE:
108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
109 "Namestore could remove non-existing record: `%s'\n", 108 "Namestore could remove non-existing record: `%s'\n",
110 (NULL != emsg) ? emsg : ""); 109 GNUNET_ErrorCode_get_hint (ec));
111 GNUNET_SCHEDULER_add_now (&endbadly, NULL); 110 GNUNET_SCHEDULER_add_now (&endbadly, NULL);
112 break; 111 break;
113 112
114 case GNUNET_SYSERR:
115 default: 113 default:
116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
117 "Namestore failed: `%s'\n", 115 "Namestore failed: `%s'\n",
118 (NULL != emsg) ? emsg : ""); 116 GNUNET_ErrorCode_get_hint (ec));
119 GNUNET_SCHEDULER_add_now (&endbadly, NULL); 117 GNUNET_SCHEDULER_add_now (&endbadly, NULL);
120 break; 118 break;
121 } 119 }
diff --git a/src/namestore/test_namestore_api_store.c b/src/namestore/test_namestore_api_store.c
index e0b7daa5d..f4f1e36d3 100644
--- a/src/namestore/test_namestore_api_store.c
+++ b/src/namestore/test_namestore_api_store.c
@@ -87,7 +87,7 @@ end (void *cls)
87 87
88 88
89static void 89static void
90put_cont (void *cls, int32_t success, const char *emsg) 90put_cont (void *cls, enum GNUNET_ErrorCode ec)
91{ 91{
92 const char *name = cls; 92 const char *name = cls;
93 93
@@ -96,7 +96,7 @@ put_cont (void *cls, int32_t success, const char *emsg)
96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
97 "Name store added record for `%s': %s\n", 97 "Name store added record for `%s': %s\n",
98 name, 98 name,
99 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 99 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
100 GNUNET_SCHEDULER_cancel (endbadly_task); 100 GNUNET_SCHEDULER_cancel (endbadly_task);
101 endbadly_task = NULL; 101 endbadly_task = NULL;
102 GNUNET_SCHEDULER_add_now (&end, NULL); 102 GNUNET_SCHEDULER_add_now (&end, NULL);
diff --git a/src/namestore/test_namestore_api_store_update.c b/src/namestore/test_namestore_api_store_update.c
index f48fe5483..8f1f33542 100644
--- a/src/namestore/test_namestore_api_store_update.c
+++ b/src/namestore/test_namestore_api_store_update.c
@@ -96,8 +96,7 @@ end (void *cls)
96 96
97static void 97static void
98put_cont (void *cls, 98put_cont (void *cls,
99 int32_t success, 99 enum GNUNET_ErrorCode ec);
100 const char *emsg);
101 100
102 101
103static void 102static void
@@ -167,8 +166,7 @@ lookup_success (void *cls,
167 166
168static void 167static void
169put_cont (void *cls, 168put_cont (void *cls,
170 int32_t success, 169 enum GNUNET_ErrorCode ec)
171 const char *emsg)
172{ 170{
173 const char *name = cls; 171 const char *name = cls;
174 struct GNUNET_HashCode derived_hash; 172 struct GNUNET_HashCode derived_hash;
@@ -178,7 +176,7 @@ put_cont (void *cls,
178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
179 "Name store added record for `%s': %s\n", 177 "Name store added record for `%s': %s\n",
180 name, 178 name,
181 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 179 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
182 /* Create derived hash */ 180 /* Create derived hash */
183 GNUNET_GNSRECORD_query_from_private_key (&privkey, 181 GNUNET_GNSRECORD_query_from_private_key (&privkey,
184 name, 182 name,
diff --git a/src/namestore/test_namestore_api_tx_rollback.c b/src/namestore/test_namestore_api_tx_rollback.c
index a631160d7..3d0884e24 100644
--- a/src/namestore/test_namestore_api_tx_rollback.c
+++ b/src/namestore/test_namestore_api_tx_rollback.c
@@ -106,15 +106,14 @@ fail_cb (void *cls)
106 106
107static void 107static void
108remove_cont (void *cls, 108remove_cont (void *cls,
109 int32_t success, 109 enum GNUNET_ErrorCode ec)
110 const char *emsg)
111{ 110{
112 nsqe = NULL; 111 nsqe = NULL;
113 if (GNUNET_YES != success) 112 if (GNUNET_EC_NONE != ec)
114 { 113 {
115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
116 _ ("Unable to roll back: `%s'\n"), 115 _ ("Unable to roll back: `%s'\n"),
117 emsg); 116 GNUNET_ErrorCode_get_hint (ec));
118 if (NULL != endbadly_task) 117 if (NULL != endbadly_task)
119 GNUNET_SCHEDULER_cancel (endbadly_task); 118 GNUNET_SCHEDULER_cancel (endbadly_task);
120 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, 119 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
@@ -139,19 +138,18 @@ remove_cont (void *cls,
139 138
140static void 139static void
141put_cont (void *cls, 140put_cont (void *cls,
142 int32_t success, 141 enum GNUNET_ErrorCode ec)
143 const char *emsg)
144{ 142{
145 const char *name = cls; 143 const char *name = cls;
146 144
147 GNUNET_assert (NULL != cls); 145 GNUNET_assert (NULL != cls);
148 nsqe = NULL; 146 nsqe = NULL;
149 if (GNUNET_SYSERR == success) 147 if (GNUNET_EC_NONE != ec)
150 { 148 {
151 GNUNET_break (0); 149 GNUNET_break (0);
152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 150 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
153 "Namestore could not store record: `%s'\n", 151 "Namestore could not store record: `%s'\n",
154 emsg); 152 GNUNET_ErrorCode_get_hint (ec));
155 if (endbadly_task != NULL) 153 if (endbadly_task != NULL)
156 GNUNET_SCHEDULER_cancel (endbadly_task); 154 GNUNET_SCHEDULER_cancel (endbadly_task);
157 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 155 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
@@ -161,20 +159,19 @@ put_cont (void *cls,
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
162 "Name store added record for `%s': %s\n", 160 "Name store added record for `%s': %s\n",
163 name, 161 name,
164 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 162 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
165 nsqe = GNUNET_NAMESTORE_transaction_rollback (nsh, remove_cont, 163 nsqe = GNUNET_NAMESTORE_transaction_rollback (nsh, remove_cont,
166 (void *) name); 164 (void *) name);
167} 165}
168 166
169static void 167static void
170begin_cont (void *cls, 168begin_cont (void *cls,
171 int32_t success, 169 enum GNUNET_ErrorCode ec)
172 const char *emsg)
173{ 170{
174 struct GNUNET_GNSRECORD_Data rd; 171 struct GNUNET_GNSRECORD_Data rd;
175 const char *name = cls; 172 const char *name = cls;
176 173
177 GNUNET_assert (success == GNUNET_YES); 174 GNUNET_assert (GNUNET_EC_NONE == ec);
178 privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); 175 privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
179 GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); 176 GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key);
180 GNUNET_IDENTITY_key_get_public (&privkey, 177 GNUNET_IDENTITY_key_get_public (&privkey,
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index 55ca901e2..6e07f78f2 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -253,12 +253,11 @@ zone_proc (void *cls,
253 253
254static void 254static void
255put_cont (void *cls, 255put_cont (void *cls,
256 int32_t success, 256 enum GNUNET_ErrorCode ec)
257 const char *emsg)
258{ 257{
259 static int c = 0; 258 static int c = 0;
260 259
261 if (success == GNUNET_OK) 260 if (GNUNET_EC_NONE == ec)
262 { 261 {
263 c++; 262 c++;
264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -269,7 +268,7 @@ put_cont (void *cls,
269 { 268 {
270 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
271 "Failed to created records: `%s'\n", 270 "Failed to created records: `%s'\n",
272 emsg); 271 GNUNET_ErrorCode_get_hint (ec));
273 GNUNET_break (0); 272 GNUNET_break (0);
274 GNUNET_SCHEDULER_shutdown (); 273 GNUNET_SCHEDULER_shutdown ();
275 res = 1; 274 res = 1;
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index c203a63a6..941d43c28 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -207,12 +207,11 @@ fail_cb (void *cls)
207 207
208static void 208static void
209put_cont (void *cls, 209put_cont (void *cls,
210 int32_t success, 210 enum GNUNET_ErrorCode ec)
211 const char *emsg)
212{ 211{
213 static int c = 0; 212 static int c = 0;
214 213
215 if (success == GNUNET_OK) 214 if (GNUNET_EC_NONE == ec)
216 { 215 {
217 c++; 216 c++;
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u \n", c); 217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u \n", c);
@@ -220,7 +219,7 @@ put_cont (void *cls,
220 else 219 else
221 { 220 {
222 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", 221 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n",
223 emsg); 222 GNUNET_ErrorCode_get_hint (ec));
224 GNUNET_break (0); 223 GNUNET_break (0);
225 GNUNET_SCHEDULER_shutdown (); 224 GNUNET_SCHEDULER_shutdown ();
226 return; 225 return;
@@ -274,12 +273,11 @@ create_record (unsigned int count)
274 273
275static void 274static void
276nick_2_cont (void *cls, 275nick_2_cont (void *cls,
277 int32_t success, 276 enum GNUNET_ErrorCode ec)
278 const char *emsg)
279{ 277{
280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
281 "Nick added : %s\n", 279 "Nick added : %s\n",
282 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 280 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
283 281
284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); 282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n");
285 283
@@ -309,11 +307,11 @@ nick_2_cont (void *cls,
309 307
310 308
311static void 309static void
312nick_1_cont (void *cls, int32_t success, const char *emsg) 310nick_1_cont (void *cls, enum GNUNET_ErrorCode ec)
313{ 311{
314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
315 "Nick 1 added : %s\n", 313 "Nick 1 added : %s\n",
316 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 314 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
317 struct GNUNET_GNSRECORD_Data rd; 315 struct GNUNET_GNSRECORD_Data rd;
318 316
319 memset (&rd, 0, sizeof(rd)); 317 memset (&rd, 0, sizeof(rd));
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
index 70097a69e..daf711c3d 100644
--- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
+++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
@@ -232,12 +232,11 @@ zone_proc_end (void *cls)
232 232
233static void 233static void
234put_cont (void *cls, 234put_cont (void *cls,
235 int32_t success, 235 enum GNUNET_ErrorCode ec)
236 const char *emsg)
237{ 236{
238 static int c = 0; 237 static int c = 0;
239 238
240 if (success == GNUNET_OK) 239 if (GNUNET_EC_NONE == ec)
241 { 240 {
242 c++; 241 c++;
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -247,7 +246,7 @@ put_cont (void *cls,
247 { 246 {
248 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 247 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
249 "Failed to created records: `%s'\n", 248 "Failed to created records: `%s'\n",
250 emsg); 249 GNUNET_ErrorCode_get_hint (ec));
251 GNUNET_break (0); 250 GNUNET_break (0);
252 res = 2; 251 res = 2;
253 GNUNET_SCHEDULER_shutdown (); 252 GNUNET_SCHEDULER_shutdown ();
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index 71b36ba09..c51224d91 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -246,11 +246,11 @@ zone_proc_end (void *cls)
246 246
247 247
248static void 248static void
249put_cont (void *cls, int32_t success, const char *emsg) 249put_cont (void *cls, enum GNUNET_ErrorCode ec)
250{ 250{
251 static int c = 0; 251 static int c = 0;
252 252
253 if (success == GNUNET_OK) 253 if (GNUNET_EC_NONE == ec)
254 { 254 {
255 c++; 255 c++;
256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u \n", c); 256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u \n", c);
@@ -258,7 +258,7 @@ put_cont (void *cls, int32_t success, const char *emsg)
258 else 258 else
259 { 259 {
260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", 260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n",
261 emsg); 261 GNUNET_ErrorCode_get_hint (ec));
262 GNUNET_break (0); 262 GNUNET_break (0);
263 GNUNET_SCHEDULER_shutdown (); 263 GNUNET_SCHEDULER_shutdown ();
264 return; 264 return;
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c
index 1e2f8248b..c9d781d39 100644
--- a/src/namestore/test_namestore_api_zone_to_name.c
+++ b/src/namestore/test_namestore_api_zone_to_name.c
@@ -157,16 +157,16 @@ error_cb (void *cls)
157 157
158static void 158static void
159put_cont (void *cls, 159put_cont (void *cls,
160 int32_t success, 160 enum GNUNET_ErrorCode ec)
161 const char *emsg)
162{ 161{
163 char *name = cls; 162 char *name = cls;
164 163
165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
166 "Name store added record for `%s': %s\n", 165 "Name store added record for `%s': %s\n",
167 name, 166 name,
168 (success == GNUNET_OK) ? "SUCCESS" : emsg); 167 (GNUNET_EC_NONE == ec) ?
169 if (success == GNUNET_OK) 168 "SUCCESS" : GNUNET_ErrorCode_get_hint (ec));
169 if (GNUNET_EC_NONE == ec)
170 { 170 {
171 res = 0; 171 res = 0;
172 172