| Bug #25939 | Allow to specify source bind address for client (and replication slave) | ||
|---|---|---|---|
| Submitted: | 30 Jan 2007 12:40 | Modified: | 22 Oct 2007 15:41 |
| Reporter: | Domas Mituzas | ||
| Status: | Closed | ||
| Category: | Server: Replication | Severity: | S4 (Feature request) |
| Version: | any | OS: | Any |
| Assigned to: | Bugs System | Target Version: | |
| Triage: | D5 (Feature request) | ||
[30 Jan 2007 12:40]
Domas Mituzas
[18 May 2007 12:15]
Bernhard Ocklin
The following function bound_connect() included in client.c will fix the problem in 5.1.
It uses the command line bind-address parameter which is never for anything anyway.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <netdb.h>
/*
* Connect.
*/
int bound_connect(int fd,
const struct sockaddr *serv_addr,
socklen_t serv_addr_size)
{
socklen_t addr_size;
union
{
struct sockaddr sa;
struct sockaddr_in sin;
} addr = { };
struct sockaddr_in *sin = (struct sockaddr_in *)serv_addr;
int ret = 0;
/* Get sockname */
addr_size = sizeof(addr);
ret = getsockname(fd, &addr.sa, &addr_size);
if (!ret)
{
/* hope it is not already bound */
if ((addr.sin.sin_family == AF_INET) && (my_bind_addr_str != NULL))
{
ret = inet_pton(AF_INET,
my_bind_addr_str,
&addr.sin.sin_addr);
}
if((ret > 0) &&
(sin != NULL) &&
(serv_addr_size >= sizeof(*sin)) &&
(sin->sin_family == AF_INET))
{
ret = bind(fd, &addr.sa, sizeof(addr.sin));
if (ret)
{
return (-1);
}
}
}
return (connect(fd, serv_addr, serv_addr_size));
}
[18 May 2007 12:22]
Bernhard Ocklin
Forgot to mention that it should replace connect() functions in my_connect().
[5 Sep 2007 2:59]
Stewart Smith
I have updated all the test results (again) due to merges into the telco tree and am about ready (as in hopefully today) to send off the patch series for final review. I'm now convinced that the best thing to do to somebody you don't like is to make them add a column to SHOW SLAVE STATUS and then fix the test case results.
[12 Oct 2007 7:31]
Stewart Smith
pushed into telco-6.3
[22 Oct 2007 15:41]
Jon Stephens
Bugfix documented in mysql-5.1.22-ndb-6.3.4 changelog. Syntax additions for executable startup and CHANGE MASTER statement documented in 5.1/5.2 Manual.
[22 Oct 2007 16:19]
Domas Mituzas
When is it going to be added to mainstream versions?
[13 May 2008 14:44]
Domas Mituzas
It is WL#3127 - and is scheduled to be merged into 6.0.
