1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmpolld-client.c: be more specific about fallback on error

if client fails to contact lvmpolld it fallbacks to using classical
polldaemon. Be more specific and give some hints to users what went
possibly wrong
This commit is contained in:
Ondrej Kozina 2015-05-12 15:34:45 +02:00
parent c3d351ec9b
commit 24a92e08c0

View File

@ -34,7 +34,7 @@ static const char* _lvmpolld_socket;
static daemon_handle _lvmpolld = { .error = 0 }; static daemon_handle _lvmpolld = { .error = 0 };
static daemon_handle _lvmpolld_connect(const char *socket) static daemon_handle _lvmpolld_open(const char *socket)
{ {
daemon_info lvmpolld_info = { daemon_info lvmpolld_info = {
.path = "lvmpolld", .path = "lvmpolld",
@ -56,15 +56,26 @@ void lvmpolld_set_socket(const char *socket)
_lvmpolld_socket = socket; _lvmpolld_socket = socket;
} }
static void _lvmpolld_connect_or_warn(void)
{
if (!_lvmpolld_connected && !_lvmpolld.error) {
_lvmpolld = _lvmpolld_open(_lvmpolld_socket);
if ( _lvmpolld.socket_fd >= 0 && !_lvmpolld.error) {
log_debug_lvmpolld("Sucessfully connected to lvmpolld on fd %d.", _lvmpolld.socket_fd);
_lvmpolld_connected = 1;
} else {
log_warn("WARNING: Failed to connect to lvmpolld. Proceeding with polling without using lvmpolld.");
log_warn("WARNING: Check global/use_lvmpolld in lvm.conf or the lvmpolld daemon state.");
}
}
}
int lvmpolld_use(void) int lvmpolld_use(void)
{ {
if (!_lvmpolld_use) if (!_lvmpolld_use || !_lvmpolld_socket)
return 0; return 0;
if (!_lvmpolld_connected && !_lvmpolld.error) { _lvmpolld_connect_or_warn();
_lvmpolld = _lvmpolld_connect(_lvmpolld_socket);
_lvmpolld_connected = _lvmpolld.socket_fd >= 0;
}
return _lvmpolld_connected; return _lvmpolld_connected;
} }