From: Andrew Tridgell Date: Sat, 18 Nov 2006 04:33:56 +0000 (+1100) Subject: don't talk to ourselves X-Git-Tag: tevent-0.9.20~348^2~3020 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b97e51b76585cb37a660421a10e248ae3612d138;p=thirdparty%2Fsamba.git don't talk to ourselves (This used to be ctdb commit 0e90e364cb0602c59030aaa8e51064589849efe8) --- diff --git a/ctdb/ctdb_tcp.c b/ctdb/ctdb_tcp.c index 2327647753a..6b423abf35a 100644 --- a/ctdb/ctdb_tcp.c +++ b/ctdb/ctdb_tcp.c @@ -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); }