Re: MySQL socket again...
Hi,
as I need this feature too, here is little patch which looks working for me.
Just use option with unix socket path: --proxy-address=/var/run/mysqld/mysqld.sock
If you need mysql-proxy listen on both TCP port and unix socket, run two instances of them.
There is no warranty as I don't know much about C and programming, I do only few small tests.
diff -ur mysql-proxy-0.5.1.orig/src/network-mysqld.c mysql-proxy-0.5.1/src/network-mysqld.c
--- mysql-proxy-0.5.1.orig/src/network-mysqld.c 2007-06-27 17:45:45.000000000 +0200
+++ mysql-proxy-0.5.1/src/network-mysqld.c 2007-07-29 01:34:12.000000000 +0200
@@ -376,12 +376,21 @@
g_assert(con->addr.len);
- if (-1 == (con->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))) {
- g_critical("socket() failed");
+ if (con->addr.addr.ipv4.sin_family == AF_INET) {
+ if (-1 == (con->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))) {
+ g_critical("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) failed");
+ return -1;
+ }
+ setsockopt(con->fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
+ } else if (con->addr.addr.ipv4.sin_family == AF_UNIX) {
+ if (-1 == (con->fd = socket(AF_UNIX, SOCK_STREAM, 0))) {
+ g_critical("socket(AF_UNIX, SOCK_STREAM, 0)) failed");
+ return -1;
+ }
+ } else {
+ g_critical("socket() failed - unknown family");
return -1;
}
-
- setsockopt(con->fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
setsockopt(con->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
if (-1 == bind(con->fd, (struct sockaddr *) &(con->addr.addr), con->addr.len)) {