From 237a311dda9c904b6726dce1b144c688a91cbcec Mon Sep 17 00:00:00 2001 From: Massimiliano Pinto Date: Thu, 20 Jun 2013 19:06:16 +0200 Subject: [PATCH] In newSession (readconnroute.c) connect_dcb will create backend connection via backend_dcb->func.connect() session_alloc will not start a newSession for the LISTENING socket In dcb.h void *data was added to keep protocol session data if the session is not started in accept(9 but later. --- core/session.c | 4 +++- include/dcb.h | 3 +++ modules/routing/readconnroute.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/session.c b/core/session.c index 6cb57807d..00a30ef7c 100644 --- a/core/session.c +++ b/core/session.c @@ -66,7 +66,9 @@ SESSION *session; session->state = SESSION_STATE_ALLOC; client->session = session; - session->router_session = service->router->newSession(service->router_instance, session); + // this will prevent the connect() backends via connect_dcb() for listening socket + if (client->state != DCB_STATE_LISTENING) + session->router_session = service->router->newSession(service->router_instance, session); spinlock_acquire(&session_spin); session->next = allSessions; diff --git a/include/dcb.h b/include/dcb.h index 01a50930b..fcc0a0bc2 100644 --- a/include/dcb.h +++ b/include/dcb.h @@ -22,6 +22,7 @@ struct session; struct server; +struct service; /** * @file dcb.h The Descriptor Control Block @@ -111,6 +112,8 @@ typedef struct dcb { DCBSTATS stats; /**< DCB related statistics */ struct dcb *next; /**< Next DCB in the chain of allocated DCB's */ + struct service *service; /**< The related service */ + void *data; /**< Specific client data */ } DCB; /* DCB states */ diff --git a/modules/routing/readconnroute.c b/modules/routing/readconnroute.c index b27084a80..75551ec18 100644 --- a/modules/routing/readconnroute.c +++ b/modules/routing/readconnroute.c @@ -209,7 +209,8 @@ int i; * Open a backend connection, putting the DCB for this * connection in the client->dcb */ - //client->dcb = backend_connect(session); + + client->dcb = connect_dcb(candidate->server, session, candidate->server->protocol); /* Add this session to the list of active sessions */ spinlock_acquire(&inst->lock);