summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ccfc35a)
raw | patch | inline | side by side (parent: ccfc35a)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 16 Sep 2014 17:36:23 +0000 (19:36 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 16 Sep 2014 17:36:23 +0000 (19:36 +0200) |
Let the frontend send back a DATA message even on empty queries to make sure
the client sees the expected reply.
Let sysdb handle empty replies correctly and also not print any errors on
empty replies (successful command not returning any data).
the client sees the expected reply.
Let sysdb handle empty replies correctly and also not print any errors on
empty replies (successful command not returning any data).
src/frontend/connection.c | patch | blob | history | |
src/frontend/query.c | patch | blob | history | |
src/include/frontend/proto.h | patch | blob | history | |
src/tools/sysdb/command.c | patch | blob | history |
index a8dfeee86e93597b5239f9709487c867bb1a5670..6cad74788cbef796e42ef01a3fd6f334430fdabd 100644 (file)
status = -1;
}
- if (status)
+ if (status) {
+ if (! sdb_strbuf_len(conn->errbuf))
+ sdb_strbuf_sprintf(conn->errbuf, "Failed to execute command");
sdb_connection_send(conn, CONNECTION_ERROR,
(uint32_t)sdb_strbuf_len(conn->errbuf),
sdb_strbuf_string(conn->errbuf));
+ }
return status;
} /* command_handle */
diff --git a/src/frontend/query.c b/src/frontend/query.c
index 52d27ec3c47ba7e7dc940ba552e76b43cf0b38a2..f55975edda8c55188410cfbfc68acab9d19dcd66 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
switch (sdb_llist_len(parsetree)) {
case 0:
- /* skipping empty command */
+ /* skipping empty command; send back an empty reply */
+ sdb_connection_send(conn, CONNECTION_DATA, 0, NULL);
break;
case 1:
node = SDB_CONN_NODE(sdb_llist_get(parsetree, 0));
index 2fabad513b06e5c156c021617262606de628c7f2..91dd3609ce4307de6ff8ae54a01f68dfbbd2055b 100644 (file)
* contain the type of the data and the result encoded as a JSON string.
* The type is the same as the command code of the respective command (see
* below) and is stored as an unsigned 32bit integer in network
- * byte-order. The result may be empty (but the type is still included).
+ * byte-order. The result may be empty (but the type is still included) if
+ * the query did not return any result. The type and the result message
+ * are empty on empty commands.
*
* 0 32 64
* +---------------+---------------+
index d30ec6084179a614fcf386cf87e3a9dcad9e0079..81f679233d969ccb203f5f938c07e6d5f98fd693 100644 (file)
static void
data_printer(sdb_strbuf_t *buf)
{
- if (sdb_strbuf_len(buf) <= sizeof(uint32_t)) {
+ size_t len = sdb_strbuf_len(buf);
+
+ if ((! len) || (len == sizeof(uint32_t))) {
+ /* empty command or empty reply */
+ return;
+ }
+ else if (len < sizeof(uint32_t)) {
printf("ERROR: Received a DATA message with invalid "
"or missing data-type\n");
return;