summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorroot <root@gpfs1.sernet.private>2008-03-20 15:59:37 +0100
committerVolker Lendecke <vl@samba.org>2008-03-20 16:54:05 +0100
commit3d2ec806937b3f8e3c30b4a32d4f97fed6dfdd74 (patch)
treeded4379eb53db012c84e758a650a4e00b51f9293 /source3
parent427c60e92c79734b09bdf00aa807c558fdd1a029 (diff)
downloadsamba-3d2ec806937b3f8e3c30b4a32d4f97fed6dfdd74.tar.gz
samba-3d2ec806937b3f8e3c30b4a32d4f97fed6dfdd74.tar.bz2
samba-3d2ec806937b3f8e3c30b4a32d4f97fed6dfdd74.zip
Port 3c1f1f0797e from 3-0-ctdb
We need to inform ctdb about the client's TCP connection so that after a fail over ctdbd can trigger the client to reconnect very quickly (This used to be commit ddc989886deff173b8a2a2a753a896770efe7545)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/server.c60
1 files changed, 57 insertions, 3 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 50c84f9da9..179d480f43 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -59,6 +59,23 @@ int get_client_fd(void)
return server_fd;
}
+int client_get_tcp_info(struct sockaddr_in *server, struct sockaddr_in *client)
+{
+ socklen_t length;
+ if (server_fd == -1) {
+ return -1;
+ }
+ length = sizeof(*server);
+ if (getsockname(server_fd, (struct sockaddr *)server, &length) != 0) {
+ return -1;
+ }
+ length = sizeof(*client);
+ if (getpeername(server_fd, (struct sockaddr *)client, &length) != 0) {
+ return -1;
+ }
+ return 0;
+}
+
struct event_context *smbd_event_context(void)
{
static struct event_context *ctx;
@@ -946,10 +963,8 @@ void exit_server_fault(void)
/****************************************************************************
received when we should release a specific IP
****************************************************************************/
-static void msg_release_ip(struct messaging_context *msg_ctx, void *private_data,
- uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
+static void release_ip(const char *ip, void *priv)
{
- const char *ip = (const char *)data->data;
char addr[INET6_ADDRSTRLEN];
if (strcmp(client_socket_addr(get_client_fd(),addr,sizeof(addr)), ip) == 0) {
@@ -964,6 +979,11 @@ static void msg_release_ip(struct messaging_context *msg_ctx, void *private_data
}
}
+static void msg_release_ip(struct messaging_context *msg_ctx, void *private_data,
+ uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
+{
+ release_ip((char *)data->data, NULL);
+}
/****************************************************************************
Initialise connect, service and file structs.
@@ -1378,6 +1398,40 @@ extern void build_options(bool screen);
exit(1);
}
+#ifdef CLUSTER_SUPPORT
+
+ if (lp_clustering()) {
+ /*
+ * We need to tell ctdb about our client's TCP
+ * connection, so that for failover ctdbd can send
+ * tickle acks, triggering a reconnection by the
+ * client.
+ */
+
+ struct sockaddr_in srv, clnt;
+
+ if (client_get_tcp_info(&srv, &clnt) == 0) {
+
+ NTSTATUS status;
+
+ status = ctdbd_register_ips(
+ messaging_ctdbd_connection(),
+ &srv, &clnt, release_ip, NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("ctdbd_register_ips failed: %s\n",
+ nt_errstr(status)));
+ }
+ } else
+ {
+ DEBUG(0,("Unable to get tcp info for "
+ "CTDB_CONTROL_TCP_CLIENT: %s\n",
+ strerror(errno)));
+ }
+ }
+
+#endif
+
TALLOC_FREE(frame);
smbd_process();