summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a7596ce)
raw | patch | inline | side by side (parent: a7596ce)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 11 Dec 2014 08:57:49 +0000 (09:57 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 11 Dec 2014 08:57:49 +0000 (09:57 +0100) |
src/tools/sysdb/command.c | patch | blob | history | |
src/tools/sysdb/input.c | patch | blob | history | |
src/tools/sysdb/input.h | patch | blob | history |
index f9195a644057ee9b2c849f4f764f4ef6bacd65d4..5044c0e5213aac42cb4456cd9dafe465264f4010 100644 (file)
--query_len;
if (sdb_client_eof(input->client)) {
- sdb_client_close(input->client);
- if (sdb_client_connect(input->client, input->user)) {
- printf("Failed to reconnect to SysDBd.\n");
+ if (sdb_input_reconnect()) {
clear_query(input);
return NULL;
}
- printf("Successfully reconnected to SysDBd.\n");
}
if (query_len) {
index 52036028d2905d35555705ec026e2bc30f96c55e..08f639f1ac104c9a8c0527321bc92ba89070e4db 100644 (file)
--- a/src/tools/sysdb/input.c
+++ b/src/tools/sysdb/input.c
return;
}
+ if (sdb_client_eof(sysdb_input->client))
+ sdb_input_reconnect();
+
sdb_strbuf_append(sysdb_input->input, "%s\n", line);
free(line);
return 0;
} /* sdb_input_exec_query */
+int
+sdb_input_reconnect(void)
+{
+ sdb_client_close(sysdb_input->client);
+ if (sdb_client_connect(sysdb_input->client, sysdb_input->user)) {
+ printf("Failed to reconnect to SysDBd.\n");
+ return -1;
+ }
+ printf("Successfully reconnected to SysDBd.\n");
+ return 0;
+} /* sdb_input_reconnect */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
index eb13043b4cea2acb948cc3ec031f075311cbb818..0aeabf8b7b653197f98ffa0678d13b769e0c21e2 100644 (file)
--- a/src/tools/sysdb/input.h
+++ b/src/tools/sysdb/input.h
int
sdb_input_exec_query(void);
+/*
+ * sdb_input_reconnect:
+ * Let the client reconnect to the server using the settings stored in
+ * sysdb_input.
+ */
+int
+sdb_input_reconnect(void);
+
#endif /* SYSDB_INPUT_H */
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */