diff --git a/src/frontend/query.c b/src/frontend/query.c
index bbf98530afedcb106abc34174e9c61e9dc8a55ae..52d27ec3c47ba7e7dc940ba552e76b43cf0b38a2 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
{
sdb_strbuf_t *buf;
sdb_store_obj_t *host;
+ uint32_t type = htonl(CONNECTION_FETCH);
host = sdb_store_get_host(name);
if (! host) {
return -1;
}
+ sdb_strbuf_memcpy(buf, &type, sizeof(uint32_t));
if (sdb_store_host_tojson(host, buf, filter, /* flags = */ 0)) {
sdb_log(SDB_LOG_ERR, "frontend: Failed to serialize "
"host '%s' to JSON", name);
return -1;
}
- sdb_connection_send(conn, CONNECTION_OK,
+ sdb_connection_send(conn, CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
sdb_object_deref(SDB_OBJ(host));
sdb_fe_exec_list(sdb_conn_t *conn, sdb_store_matcher_t *filter)
{
sdb_strbuf_t *buf;
+ uint32_t type = htonl(CONNECTION_LIST);
buf = sdb_strbuf_create(1024);
if (! buf) {
return -1;
}
+ sdb_strbuf_memcpy(buf, &type, sizeof(uint32_t));
if (sdb_store_tojson(buf, filter, /* flags = */ SDB_SKIP_ALL)) {
sdb_log(SDB_LOG_ERR, "frontend: Failed to serialize "
"store to JSON");
return -1;
}
- sdb_connection_send(conn, CONNECTION_OK,
+ sdb_connection_send(conn, CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
return 0;
sdb_store_matcher_t *filter)
{
tojson_data_t data = { NULL, filter, 0 };
+ uint32_t type = htonl(CONNECTION_LOOKUP);
data.buf = sdb_strbuf_create(1024);
if (! data.buf) {
return -1;
}
+ sdb_strbuf_memcpy(data.buf, &type, sizeof(uint32_t));
sdb_strbuf_append(data.buf, "[");
/* Let the JSON serializer handle the filter instead of the scanner. Else,
sdb_strbuf_append(data.buf, "]");
- sdb_connection_send(conn, CONNECTION_OK,
+ sdb_connection_send(conn, CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(data.buf), sdb_strbuf_string(data.buf));
sdb_strbuf_destroy(data.buf);
return 0;
sdb_timeseries_opts_t *opts)
{
sdb_strbuf_t *buf;
+ uint32_t type = htonl(CONNECTION_TIMESERIES);
buf = sdb_strbuf_create(1024);
if (! buf) {
return -1;
}
+ sdb_strbuf_memcpy(buf, &type, sizeof(uint32_t));
if (sdb_store_fetch_timeseries(hostname, metric, opts, buf)) {
sdb_log(SDB_LOG_ERR, "frontend: Failed to fetch time-series");
sdb_strbuf_sprintf(conn->errbuf, "Failed to fetch time-series");
return -1;
}
- sdb_connection_send(conn, CONNECTION_OK,
+ sdb_connection_send(conn, CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
return 0;