summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 42af3b6)
raw | patch | inline | side by side (parent: 42af3b6)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 1 May 2014 13:56:23 +0000 (15:56 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 1 May 2014 13:56:23 +0000 (15:56 +0200) |
There might be some intermediate log messages, which should be printed but
then we need to wait for further replies.
then we need to wait for further replies.
src/tools/sysdb/command.c | patch | blob | history | |
src/tools/sysdb/main.c | patch | blob | history |
index 77f3c8346498c430be10fcbafcf1ab9a06ee5cc2..7cbde41a7e05e1bff9f6c3f0dfd5d966dda62e8f 100644 (file)
return -1;
if (rcode == CONNECTION_ERROR)
- status = 1;
+ status = CONNECTION_ERROR;
if (rcode == UINT32_MAX)
printf("ERROR: ");
/* ignore errors; we'll only hide the command from the caller */
sdb_client_send(input->client, CONNECTION_QUERY, query_len, query);
+
+ /* The server will send back *something*, either error/log messages
+ * and/or the reply to the query. Here, we don't care about what it
+ * sends back. We'll wait for the first reply and then return to the
+ * main loop which will handle any subsequent replies, including
+ * eventually the reply to the query (if it's not the first reply). */
if (sdb_command_print_reply(input->client) < 0)
return NULL;
}
diff --git a/src/tools/sysdb/main.c b/src/tools/sysdb/main.c
index 8455a6c7000e4856483b8650ce02a932c0fa98a2..1174fa9fa0462ddb13603456b7de2bba19a4d33e 100644 (file)
--- a/src/tools/sysdb/main.c
+++ b/src/tools/sysdb/main.c
while (sdb_llist_iter_has_next(iter)) {
sdb_object_t *obj = sdb_llist_iter_get_next(iter);
- int err;
if (sdb_client_send(client, CONNECTION_QUERY,
(uint32_t)strlen(obj->name), obj->name) <= 0) {
status = 1;
break;
}
- err = sdb_command_print_reply(client);
- if (err) {
- if (err < 0)
+
+ /* Wait for server replies. We might get any number of log messages
+ * but eventually see the reply to the query, which is either OK or
+ * ERROR. */
+ while (42) {
+ status = sdb_command_print_reply(client);
+ if (status < 0) {
sdb_log(SDB_LOG_ERR, "Failed to read reply from server");
- status = 1;
- break;
+ break;
+ }
+
+ if ((status == CONNECTION_OK) || (status == CONNECTION_ERROR))
+ break;
}
+
+ if (status)
+ break;
}
sdb_llist_iter_destroy(iter);