summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f80142a)
raw | patch | inline | side by side (parent: f80142a)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sun, 8 Oct 2017 06:23:32 +0000 (13:23 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Mon, 9 Oct 2017 05:33:07 +0000 (12:33 +0700) |
* Do not request reading unless domain is connected
* Report instance name in error messages
* Report instance name in error messages
src/ipmi.c | patch | blob | history |
diff --git a/src/ipmi.c b/src/ipmi.c
index 6f8a18f46cb2be76da4bd8dc1f607285804bbb8a..7b22bc26b8ea1c8f233a663a5b99e8f78d2c39f6 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
char *password;
unsigned int authtype;
+ _Bool connected;
ipmi_con_t *connection;
pthread_mutex_t sensor_list_lock;
c_ipmi_sensor_list_t *sensor_list;
/*
* Misc private functions
*/
-static void c_ipmi_error(const char *func, int status) {
+static void c_ipmi_error(c_ipmi_instance_t *st, const char *func, int status) {
char errbuf[4096] = {0};
if (IPMI_IS_OS_ERR(status) || IPMI_IS_RMCPP_ERR(status) ||
}
errbuf[sizeof(errbuf) - 1] = 0;
- ERROR("ipmi plugin: %s failed: %s", func, errbuf);
+ ERROR("ipmi plugin: %s failed for `%s`: %s", func, st->name, errbuf);
} /* void c_ipmi_error */
static void c_ipmi_log(os_handler_t *handler, const char *format,
status = ipmi_entity_add_sensor_update_handler(
entity, entity_sensor_update_handler, /* user data = */ (void *)st);
if (status != 0) {
- c_ipmi_error("ipmi_entity_add_sensor_update_handler", status);
+ c_ipmi_error(st, "ipmi_entity_add_sensor_update_handler", status);
}
} else if (op == IPMI_DELETED) {
status = ipmi_entity_remove_sensor_update_handler(
entity, entity_sensor_update_handler, /* user data = */ (void *)st);
if (status != 0) {
- c_ipmi_error("ipmi_entity_remove_sensor_update_handler", status);
+ c_ipmi_error(st, "ipmi_entity_remove_sensor_update_handler", status);
}
}
} /* void domain_entity_update_handler */
"user_data = %p);",
(void *)domain, err, conn_num, port_num, still_connected, user_data);
+ c_ipmi_instance_t *st = (c_ipmi_instance_t *)user_data;
+
if (err != 0)
- c_ipmi_error("domain_connection_change_handler", err);
+ c_ipmi_error(st, "domain_connection_change_handler", err);
- if (!still_connected)
+ if (!still_connected) {
+ st->connected = 0;
return;
+ }
- c_ipmi_instance_t *st = (c_ipmi_instance_t *)user_data;
+ st->connected = 1;
int status = ipmi_domain_add_entity_update_handler(
domain, domain_entity_update_handler, /* user data = */ st);
if (status != 0) {
- c_ipmi_error("ipmi_domain_add_entity_update_handler", status);
+ c_ipmi_error(st, "ipmi_domain_add_entity_update_handler", status);
}
status = st->connection->add_event_handler(st->connection, smi_event_handler,
(void *)domain);
if (status != 0)
- c_ipmi_error("Failed to register smi event handler", status);
+ c_ipmi_error(st, "Failed to register smi event handler", status);
} /* void domain_connection_change_handler */
static int c_ipmi_thread_init(c_ipmi_instance_t *st) {
strlen(st->password), os_handler,
/* user data = */ NULL, &st->connection);
if (status != 0) {
- c_ipmi_error("ipmi_ip_setup_con", status);
+ c_ipmi_error(st, "ipmi_ip_setup_con", status);
return -1;
}
} else {
status = ipmi_smi_setup_con(/* if_num = */ 0, os_handler,
/* user data = */ NULL, &st->connection);
if (status != 0) {
- c_ipmi_error("ipmi_smi_setup_con", status);
+ c_ipmi_error(st, "ipmi_smi_setup_con", status);
return -1;
}
}
/* domain_fully_up_handler = */ NULL, /* user data = */ NULL, open_option,
open_option_num, &domain_id);
if (status != 0) {
- c_ipmi_error("ipmi_open_domain", status);
+ c_ipmi_error(st, "ipmi_open_domain", status);
return -1;
}
return -1;
}
+ if (st->connected == 0)
+ return 0;
+
sensor_list_read_all(st);
if (st->init_in_progress > 0)