1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

don't talk to ourselves

(This used to be ctdb commit 0e90e364cb0602c59030aaa8e51064589849efe8)
This commit is contained in:
Andrew Tridgell 2006-11-18 15:33:56 +11:00
parent 9ef0cfa2e9
commit b97e51b765

View File

@ -254,7 +254,11 @@ static void ctdb_incoming_read(struct event_context *ev, struct fd_event *fde,
struct ctdb_incoming *in = talloc_get_type(private, struct ctdb_incoming);
char c;
printf("Incoming data\n");
if (read(in->fd, &c, 1) <= 0) {
/* socket is dead */
close(in->fd);
talloc_free(in);
}
}
@ -329,6 +333,14 @@ static int ctdb_listen(struct ctdb_context *ctdb)
return 0;
}
/*
check if two addresses are the same
*/
static bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2)
{
return strcmp(a1->address, a2->address) == 0 && a1->port == a2->port;
}
/*
start the protocol going
*/
@ -342,6 +354,7 @@ int ctdb_start(struct ctdb_context *ctdb)
/* startup connections to the other servers - will happen on
next event loop */
for (node=ctdb->nodes;node;node=node->next) {
if (ctdb_same_address(&ctdb->address, &node->address)) continue;
event_add_timed(ctdb->ev, node, timeval_zero(),
ctdb_node_connect, node);
}