1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-20 22:50:26 +03:00

Some "ctdb ..." commands can be run without having the main daemon running.

In that case, when the main daemon is not running
the ctdb context will be initialized to NULL, since we can not connect.

Move the calls to read the ctdb socketname and connecting via libctdb to
only happen when we are executing a "ctdb ..." command that requires that we talk to the actual daemon.
Otherwise we will get an ugly SEGV for the "ctdb ..." commandline tool
when trying to run a command that is supposed to work also when the daemon is down.

(This used to be ctdb commit 18168da84a6aa8d69465e43402444c7ec979604a)
This commit is contained in:
Ronnie Sahlberg 2010-06-09 09:17:35 +10:00
parent e169d689b9
commit 5699091e9a

View File

@ -4555,7 +4555,6 @@ int main(int argc, const char *argv[])
for (i=0;i<ARRAY_SIZE(ctdb_commands);i++) {
if (strcmp(control, ctdb_commands[i].name) == 0) {
int j;
const char *socket_name;
if (ctdb_commands[i].without_daemon == true) {
close(2);
@ -4564,21 +4563,23 @@ int main(int argc, const char *argv[])
/* initialise ctdb */
ctdb = ctdb_cmdline_client(ev);
/* initialize a libctdb connection as well */
socket_name = ctdb_get_socketname(ctdb);
ctdb_connection = ctdb_connect(socket_name,
ctdb_log_file, stderr);
if (ctdb_connection == NULL) {
fprintf(stderr, "Failed to connect to daemon from libctdb\n");
exit(1);
}
if (ctdb_commands[i].without_daemon == false) {
const char *socket_name;
if (ctdb == NULL) {
DEBUG(DEBUG_ERR, ("Failed to init ctdb\n"));
exit(1);
}
/* initialize a libctdb connection as well */
socket_name = ctdb_get_socketname(ctdb);
ctdb_connection = ctdb_connect(socket_name,
ctdb_log_file, stderr);
if (ctdb_connection == NULL) {
fprintf(stderr, "Failed to connect to daemon from libctdb\n");
exit(1);
}
/* verify the node exists */
verify_node(ctdb);