MySQL Forums
Forum List  »  Router & Proxy

Re: MySQL socket again...
Posted by: Jan Drobil
Date: July 28, 2007 05:57PM

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)) {

Options: ReplyQuote


Subject
Views
Written By
Posted
5130
July 09, 2007 02:21AM
2753
July 09, 2007 03:06AM
Re: MySQL socket again...
4962
July 28, 2007 05:57PM
3004
July 29, 2007 12:41PM
2867
July 30, 2007 03:27AM
2760
August 02, 2007 08:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.