summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 566874e)
raw | patch | inline | side by side (parent: 566874e)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 18 Feb 2015 20:32:48 +0000 (21:32 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 18 Feb 2015 20:32:48 +0000 (21:32 +0100) |
src/plugins/store/network.c | patch | blob | history |
index 2d41bae3f1cb2f899c4cad770cd961598e982501..c7ee4293a5384a1485c20adaf6ab3eae81be6e51 100644 (file)
char *username;
sdb_ssl_options_t ssl_opts;
} user_data_t;
-#define UD(obj) ((user_data_t *)(obj))
-#define CLIENT(obj) UD(SDB_OBJ_WRAPPER(obj)->data)->client
+#define UD(obj) SDB_OBJ_WRAPPER(obj)->data
static void
user_data_destroy(void *obj)
{
- user_data_t *ud = UD(obj);
+ user_data_t *ud = obj;
if (! ud)
return;
*/
static int
-store_rpc(sdb_client_t *client, const char *msg, size_t msg_len)
+store_rpc(user_data_t *ud, const char *msg, size_t msg_len)
{
sdb_strbuf_t *buf = sdb_strbuf_create(128);
uint32_t rstatus = 0;
ssize_t status;
- status = sdb_client_rpc(client, SDB_CONNECTION_STORE,
+ if (sdb_client_eof(ud->client)) {
+ sdb_client_close(ud->client);
+ if (sdb_client_connect(ud->client, ud->username)) {
+ sdb_log(SDB_LOG_ERR, "store::network: Failed to reconnect "
+ "to SysDB at %s as user %s", ud->addr, ud->username);
+ return -1;
+ }
+ sdb_log(SDB_LOG_INFO, "store::network: Successfully reconnected "
+ "to SysDB at %s as user %s", ud->addr, ud->username);
+ }
+
+ status = sdb_client_rpc(ud->client, SDB_CONNECTION_STORE,
(uint32_t)msg_len, msg, &rstatus, buf);
if (status < 0)
sdb_log(SDB_LOG_ERR, "store::network: %s", sdb_strbuf_string(buf));
char buf[len];
sdb_proto_marshal_host(buf, len, &host);
- return store_rpc(CLIENT(user_data), buf, len);
+ return store_rpc(UD(user_data), buf, len);
} /* store_host */
static int
char buf[len];
sdb_proto_marshal_service(buf, len, &svc);
- return store_rpc(CLIENT(user_data), buf, len);
+ return store_rpc(UD(user_data), buf, len);
} /* store_service */
static int
char buf[len];
sdb_proto_marshal_metric(buf, len, &metric);
- return store_rpc(CLIENT(user_data), buf, len);
+ return store_rpc(UD(user_data), buf, len);
} /* store_metric */
static int
char buf[len];
sdb_proto_marshal_attribute(buf, len, &attr);
- return store_rpc(CLIENT(user_data), buf, len);
+ return store_rpc(UD(user_data), buf, len);
} /* store_attr */
static int
char buf[len];
sdb_proto_marshal_attribute(buf, len, &attr);
- return store_rpc(CLIENT(user_data), buf, len);
+ return store_rpc(UD(user_data), buf, len);
} /* store_service_attr */
static int
char buf[len];
sdb_proto_marshal_attribute(buf, len, &attr);
- return store_rpc(CLIENT(user_data), buf, len);
+ return store_rpc(UD(user_data), buf, len);
} /* store_metric_attr */
static sdb_store_writer_t store_impl = {