diff options
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index a173e8927..1f621c5f0 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1728,6 +1728,57 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1728 | } | 1728 | } |
1729 | } | 1729 | } |
1730 | 1730 | ||
1731 | /** | ||
1732 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL message | ||
1733 | * | ||
1734 | * @param cls client sending the message | ||
1735 | * @param tx_msg message of type `struct TxControlMessage` | ||
1736 | */ | ||
1737 | static void | ||
1738 | handle_tx_control (void *cls, const struct TxControlMessage *tx_msg) | ||
1739 | { | ||
1740 | struct NamestoreClient *nc = cls; | ||
1741 | struct TxControlResultMessage *txr_msg; | ||
1742 | struct GNUNET_MQ_Envelope *env; | ||
1743 | enum GNUNET_GenericReturnValue ret; | ||
1744 | char *emsg; | ||
1745 | char *err_tmp; | ||
1746 | size_t err_len; | ||
1747 | |||
1748 | switch (ntohs (tx_msg->control)) | ||
1749 | { | ||
1750 | case GNUNET_NAMESTORE_TX_BEGIN: | ||
1751 | ret = nc->GSN_database->transaction_begin (nc->GSN_database->cls, | ||
1752 | &emsg); | ||
1753 | break; | ||
1754 | case GNUNET_NAMESTORE_TX_COMMIT: | ||
1755 | ret = nc->GSN_database->transaction_commit (nc->GSN_database->cls, | ||
1756 | &emsg); | ||
1757 | break; | ||
1758 | case GNUNET_NAMESTORE_TX_ROLLBACK: | ||
1759 | ret = nc->GSN_database->transaction_rollback (nc->GSN_database->cls, | ||
1760 | &emsg); | ||
1761 | break; | ||
1762 | default: | ||
1763 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1764 | "Unknown control type %u\n", ntohs (tx_msg->control)); | ||
1765 | GNUNET_break (0); | ||
1766 | } | ||
1767 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1768 | "TX status is %u\n", ret); | ||
1769 | err_len = (GNUNET_YES == ret) ? 0 : strlen (emsg) + 1; | ||
1770 | env = | ||
1771 | GNUNET_MQ_msg_extra (txr_msg, | ||
1772 | err_len, | ||
1773 | GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT); | ||
1774 | txr_msg->gns_header.header.size = htons (sizeof (struct TxControlResultMessage) + err_len); | ||
1775 | txr_msg->gns_header.r_id = tx_msg->gns_header.r_id; | ||
1776 | txr_msg->success = htons (ret); | ||
1777 | err_tmp = (char *) &txr_msg[1]; | ||
1778 | GNUNET_memcpy (err_tmp, emsg, err_len); | ||
1779 | GNUNET_MQ_send (nc->mq, env); | ||
1780 | GNUNET_SERVICE_client_continue (nc->client); | ||
1781 | } | ||
1731 | 1782 | ||
1732 | /** | 1783 | /** |
1733 | * Context for record remove operations passed from #handle_zone_to_name to | 1784 | * Context for record remove operations passed from #handle_zone_to_name to |
@@ -2371,6 +2422,10 @@ GNUNET_SERVICE_MAIN ( | |||
2371 | &client_connect_cb, | 2422 | &client_connect_cb, |
2372 | &client_disconnect_cb, | 2423 | &client_disconnect_cb, |
2373 | NULL, | 2424 | NULL, |
2425 | GNUNET_MQ_hd_fixed_size (tx_control, | ||
2426 | GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL, | ||
2427 | struct TxControlMessage, | ||
2428 | NULL), | ||
2374 | GNUNET_MQ_hd_var_size (record_store, | 2429 | GNUNET_MQ_hd_var_size (record_store, |
2375 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, | 2430 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, |
2376 | struct RecordStoreMessage, | 2431 | struct RecordStoreMessage, |