gint gcluster_push_virtual_ns_space_used(addr_info_t * addr, long timeout, GHashTable *space_used, GError ** error) { static struct code_handler_s codes[] = { {200, REPSEQ_FINAL, NULL, NULL}, {0, 0, NULL, NULL} }; struct reply_sequence_data_s data = { NULL, 0, codes }; MESSAGE req = NULL; GByteArray *buf = NULL; GSList *kv_list = NULL; /* send the hashtable in the body */ kv_list = key_value_pairs_convert_from_map(space_used, FALSE, error); if (!kv_list) { GSETERROR(error, "Conversion HashTable->List failure"); return (0); } /*encode the list */ buf = key_value_pairs_marshall_gba(kv_list, error); if (!buf) { GSETERROR(error, "Failed to marshall kv list"); goto error_marshall; } req = build_request(NAME_MSGNAME_CS_PUSH_VNS_SPACE_USED, buf->data, buf->len, error); if (req == NULL) { GSETERROR(error, "Failed to build request %s", NAME_MSGNAME_CS_PUSH_VNS_SPACE_USED); goto error_buildreq; } /*reads the answers */ if (!metaXClient_reply_sequence_run_from_addrinfo(error, req, addr, timeout, &data)) { GSETERROR(error, "Cannot execute the query %s and receive all the responses", NAME_MSGNAME_CS_PUSH_BROKEN_CONT); goto error_reply; } message_destroy(req, NULL); g_byte_array_free(buf, TRUE); if(kv_list) { g_slist_foreach(kv_list, g_free1, NULL); g_slist_free(kv_list); } return (1); error_reply: message_destroy(req, NULL); error_buildreq: g_byte_array_free(buf, TRUE); error_marshall: if(kv_list) { g_slist_foreach(kv_list, g_free1, NULL); g_slist_free(kv_list); } return (0); }
GByteArray * sqlx_pack_PROPSET_pairs(struct sqlx_name_s *name, gboolean flush, GSList *pairs) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_PROPSET, name); if (flush) metautils_message_add_field_strint (req, NAME_MSGKEY_FLUSH, 1); metautils_message_add_body_unref (req, key_value_pairs_marshall_gba (pairs, NULL)); return message_marshall_gba_and_clean(req); }