diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-11-28 17:56:10 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2006-11-28 17:56:10 +1100 |
commit | fdb317facfdb60c87695b557a4680401c210031a (patch) | |
tree | cbd2b28aab25f51704605d90a00bd466b2b8faf9 /ctdb/tcp | |
parent | 5d0ba69e06d2f37788697c3b7c39287334d2fa22 (diff) | |
download | samba-fdb317facfdb60c87695b557a4680401c210031a.tar.gz samba-fdb317facfdb60c87695b557a4680401c210031a.tar.xz samba-fdb317facfdb60c87695b557a4680401c210031a.zip |
- added simple (fake) vnn system
- split up ctdb layer code into 3 modules
- added a simple test suite
- added packet structures for ctdb_call
- switched to an array for ctdb_node to make vnn lookup easy and fast
(This used to be ctdb commit 8a17460a816a5970f2df8244a06aec55d814f186)
Diffstat (limited to 'ctdb/tcp')
-rw-r--r-- | ctdb/tcp/tcp_connect.c | 16 | ||||
-rw-r--r-- | ctdb/tcp/tcp_init.c | 5 |
2 files changed, 9 insertions, 12 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c index fff6938e56..c7e361f9ca 100644 --- a/ctdb/tcp/tcp_connect.c +++ b/ctdb/tcp/tcp_connect.c @@ -43,16 +43,12 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f struct ctdb_tcp_node *tnode = talloc_get_type(node->private, struct ctdb_tcp_node); struct ctdb_context *ctdb = node->ctdb; - int error; + int error = 0; socklen_t len; if (getsockopt(tnode->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0 || error != 0) { - if (error == EINPROGRESS) { - printf("connect in progress\n"); - return; - } - printf("getsockopt errno=%s\n", strerror(errno)); + printf("getsockopt error=%s\n", strerror(error)); talloc_free(fde); close(tnode->fd); tnode->fd = -1; @@ -61,10 +57,12 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f return; } - printf("Established connection to %s\n", node->name); talloc_free(fde); tnode->fde = event_add_fd(node->ctdb->ev, node, tnode->fd, EVENT_FD_READ, ctdb_tcp_node_write, node); + + /* tell the ctdb layer we are connected */ + node->ctdb->upcalls->node_connected(node); } /* @@ -97,7 +95,7 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, } /* non-blocking connect - wait for write event */ - event_add_fd(node->ctdb->ev, node, tnode->fd, EVENT_FD_WRITE, + event_add_fd(node->ctdb->ev, node, tnode->fd, EVENT_FD_WRITE|EVENT_FD_READ, ctdb_node_connect_write, node); } @@ -143,8 +141,6 @@ static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde, ctdb_tcp_incoming_read, in); talloc_set_destructor(in, ctdb_incoming_destructor); - - printf("New incoming socket %d\n", in->fd); } diff --git a/ctdb/tcp/tcp_init.c b/ctdb/tcp/tcp_init.c index b98a92818d..39ecec4dbd 100644 --- a/ctdb/tcp/tcp_init.c +++ b/ctdb/tcp/tcp_init.c @@ -30,14 +30,15 @@ */ int ctdb_tcp_start(struct ctdb_context *ctdb) { - struct ctdb_node *node; + int i; /* listen on our own address */ if (ctdb_tcp_listen(ctdb) != 0) return -1; /* startup connections to the other servers - will happen on next event loop */ - for (node=ctdb->nodes;node;node=node->next) { + for (i=0;i<ctdb->num_nodes;i++) { + struct ctdb_node *node = *(ctdb->nodes + i); if (ctdb_same_address(&ctdb->address, &node->address)) continue; event_add_timed(ctdb->ev, node, timeval_zero(), ctdb_tcp_node_connect, node); |