Merge lp:~ramon-van-alteren/mysql-proxy/funnel-private-backend into lp:~trickie/mysql-proxy/funnel

Proposed by Ramon
Status: Merged
Approved by: trickie
Approved revision: 661
Merged at revision: not available
Proposed branch: lp:~ramon-van-alteren/mysql-proxy/funnel-private-backend
Merge into: lp:~trickie/mysql-proxy/funnel
Diff against target: None lines
To merge this branch: bzr merge lp:~ramon-van-alteren/mysql-proxy/funnel-private-backend
Reviewer Review Type Date Requested Status
nickloeve Pending
Review via email: mp+5244@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ramon (ramon-van-alteren) wrote :

As the commit statement reads...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/funnel/funnel-plugin.c'
--- plugins/funnel/funnel-plugin.c 2009-03-24 10:44:50 +0000
+++ plugins/funnel/funnel-plugin.c 2009-04-06 12:00:28 +0000
@@ -390,6 +390,7 @@
390 390
391 /* try for a pooled connection and possibly go to backlog */391 /* try for a pooled connection and possibly go to backlog */
392 if (!con->server) {392 if (!con->server) {
393 network_socket_set_keepalive(con->client);
393 g_static_mutex_lock(&current_backend_cons_mutex);394 g_static_mutex_lock(&current_backend_cons_mutex);
394 if (current_backend_cons >= con->config->min_backend_cons) { /* we want to get a minimum in our pool */395 if (current_backend_cons >= con->config->min_backend_cons) { /* we want to get a minimum in our pool */
395 396
@@ -413,6 +414,7 @@
413 stats->no_of_frontend_conns++;414 stats->no_of_frontend_conns++;
414415
415 if (!con->server) {416 if (!con->server) {
417 network_socket_set_keepalive(con->client);
416 current_backend_cons++;418 current_backend_cons++;
417 g_static_mutex_unlock(&current_backend_cons_mutex);419 g_static_mutex_unlock(&current_backend_cons_mutex);
418 con->server = network_socket_new();420 con->server = network_socket_new();
@@ -995,9 +997,15 @@
995 return -1;997 return -1;
996 }998 }
997999
1000 /** Set listen socket to do tcp_keepalive
1001 * This should be inherited by all subsequent sockets
1002 **/
1003
1004 // network_socket_set_keepalive(listen_sock);
1005
998 /**1006 /**
999 * call network_mysqld_con_accept() with this connection when we are done1007 * call network_mysqld_con_accept() with this connection when we are done
1000 */1008 **/
10011009
1002 event_set(&(listen_sock->event), listen_sock->fd, EV_READ|EV_PERSIST, network_mysqld_con_accept, con);1010 event_set(&(listen_sock->event), listen_sock->fd, EV_READ|EV_PERSIST, network_mysqld_con_accept, con);
1003 event_base_set(chas->event_base, &(listen_sock->event));1011 event_base_set(chas->event_base, &(listen_sock->event));
10041012
=== modified file 'src/network-socket.c'
--- src/network-socket.c 2009-02-23 23:58:26 +0000
+++ src/network-socket.c 2009-04-06 12:00:28 +0000
@@ -279,6 +279,60 @@
279}279}
280280
281/**281/**
282 * set keepalive properties on the socket
283 *
284 * @param fd socket-fd
285 * @return 0
286 */
287network_socket_retval_t network_socket_set_keepalive(network_socket *sock) {
288 int optval = 1;
289 int optlen = sizeof(optval);
290
291#ifdef linux
292 if(setsockopt(sock->fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) {
293 g_critical("%s.%d: set_keepalive() failed: %s (%d)",
294 __FILE__, __LINE__,
295 g_strerror(errno), errno);
296 return NETWORK_SOCKET_ERROR;
297 }
298
299 /* start sending keepalive ack's after 2 minutes */
300 optval = 120;
301 optlen = sizeof(optval);
302
303 if(setsockopt(sock->fd, IPPROTO_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
304 g_critical("%s.%d: set_keepalive() failed: %s (%d)",
305 __FILE__, __LINE__,
306 g_strerror(errno), errno);
307 return NETWORK_SOCKET_ERROR;
308 }
309
310 /* send keepalive every 2 minutes when idle */
311 if(setsockopt(sock->fd, IPPROTO_TCP, TCP_KEEPINTVL, &optval, optlen) < 0) {
312 g_critical("%s.%d: set_keepalive() failed: %s (%d)",
313 __FILE__, __LINE__,
314 g_strerror(errno), errno);
315 return NETWORK_SOCKET_ERROR;
316 }
317
318 /* fail after 1 failed keepalive packet */
319 optval = 1;
320
321 if(setsockopt(sock->fd, IPPROTO_TCP, TCP_KEEPCNT, &optval, optlen) < 0) {
322 g_critical("%s.%d: set_keepalive() failed: %s (%d)",
323 __FILE__, __LINE__,
324 g_strerror(errno), errno);
325 return NETWORK_SOCKET_ERROR;
326 }
327
328 return NETWORK_SOCKET_SUCCESS;
329#else
330 //todo, fix this on other platforms
331 return NETWORK_SOCKET_SUCCESS;
332#endif
333}
334
335/**
282 * accept a connection336 * accept a connection
283 *337 *
284 * event handler for listening connections338 * event handler for listening connections
@@ -300,13 +354,16 @@
300354
301 return NULL;355 return NULL;
302 }356 }
303357
304 network_socket_set_non_blocking(client);358 network_socket_set_non_blocking(client);
305359
306 if (network_address_refresh_name(client->src)) {360 if (network_address_refresh_name(client->src)) {
307 network_socket_free(client);361 network_socket_free(client);
308 return NULL;362 return NULL;
309 }363 }
364
365 /* set socket to do tcp_keepalive */
366 //network_socket_set_keepalive(client);
310367
311 /* the listening side may be INADDR_ANY, let's get which address the client really connected to */368 /* the listening side may be INADDR_ANY, let's get which address the client really connected to */
312 if (-1 == getsockname(client->fd, &client->dst->addr.common, &(client->dst->len))) {369 if (-1 == getsockname(client->fd, &client->dst->addr.common, &(client->dst->len))) {

Subscribers

People subscribed via source and target branches