MXS-2196: Pass the SERVICE pointer when allocating a DCB
The value would otherwise be assigned outside of it and in some cases not at all. Now all DCBs (apart from internal ones) have a valid SERVICE pointer. The SERV_LISTENER pointer should not be in the DCBs but in the session. This way the listener is an attribute of a session instead of a connection. If this is implemented, the authenticator data can be more easily shared.
This commit is contained in:
@ -261,7 +261,7 @@ void dcb_global_init();
|
|||||||
|
|
||||||
int dcb_write(DCB*, GWBUF*);
|
int dcb_write(DCB*, GWBUF*);
|
||||||
DCB* dcb_accept(DCB* listener);
|
DCB* dcb_accept(DCB* listener);
|
||||||
DCB* dcb_alloc(dcb_role_t, SERV_LISTENER*);
|
DCB* dcb_alloc(dcb_role_t, SERV_LISTENER*, SERVICE* service);
|
||||||
DCB* dcb_connect(struct server*, struct session*, const char*);
|
DCB* dcb_connect(struct server*, struct session*, const char*);
|
||||||
int dcb_read(DCB*, GWBUF**, int);
|
int dcb_read(DCB*, GWBUF**, int);
|
||||||
int dcb_drain_writeq(DCB*);
|
int dcb_drain_writeq(DCB*);
|
||||||
|
@ -180,7 +180,7 @@ static void dcb_initialize(DCB* dcb)
|
|||||||
*
|
*
|
||||||
* @return An available DCB or NULL if none could be allocated.
|
* @return An available DCB or NULL if none could be allocated.
|
||||||
*/
|
*/
|
||||||
DCB* dcb_alloc(dcb_role_t role, SERV_LISTENER* listener)
|
DCB* dcb_alloc(dcb_role_t role, SERV_LISTENER* listener, SERVICE* service)
|
||||||
{
|
{
|
||||||
DCB* newdcb;
|
DCB* newdcb;
|
||||||
|
|
||||||
@ -192,6 +192,7 @@ DCB* dcb_alloc(dcb_role_t role, SERV_LISTENER* listener)
|
|||||||
dcb_initialize(newdcb);
|
dcb_initialize(newdcb);
|
||||||
newdcb->dcb_role = role;
|
newdcb->dcb_role = role;
|
||||||
newdcb->listener = listener;
|
newdcb->listener = listener;
|
||||||
|
newdcb->service = service;
|
||||||
newdcb->last_read = mxs_clock();
|
newdcb->last_read = mxs_clock();
|
||||||
newdcb->low_water = config_writeq_low_water();
|
newdcb->low_water = config_writeq_low_water();
|
||||||
newdcb->high_water = config_writeq_high_water();
|
newdcb->high_water = config_writeq_high_water();
|
||||||
@ -410,7 +411,7 @@ DCB* dcb_connect(SERVER* server, MXS_SESSION* session, const char* protocol)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dcb = dcb_alloc(DCB_ROLE_BACKEND_HANDLER, NULL)) == NULL)
|
if ((dcb = dcb_alloc(DCB_ROLE_BACKEND_HANDLER, NULL, session->service)) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2401,7 +2402,7 @@ DCB* dcb_accept(DCB* dcb)
|
|||||||
|
|
||||||
configure_network_socket(c_sock, client_conn.ss_family);
|
configure_network_socket(c_sock, client_conn.ss_family);
|
||||||
|
|
||||||
client_dcb = dcb_alloc(DCB_ROLE_CLIENT_HANDLER, dcb->listener);
|
client_dcb = dcb_alloc(DCB_ROLE_CLIENT_HANDLER, dcb->listener, dcb->service);
|
||||||
|
|
||||||
if (client_dcb == NULL)
|
if (client_dcb == NULL)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ static int test1()
|
|||||||
SERV_LISTENER* dummy = nullptr;
|
SERV_LISTENER* dummy = nullptr;
|
||||||
/* Single buffer tests */
|
/* Single buffer tests */
|
||||||
fprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_INTERNAL");
|
fprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_INTERNAL");
|
||||||
dcb = dcb_alloc(DCB_ROLE_INTERNAL, dummy);
|
dcb = dcb_alloc(DCB_ROLE_INTERNAL, dummy, NULL);
|
||||||
printDCB(dcb);
|
printDCB(dcb);
|
||||||
fprintf(stderr, "\t..done\nAllocated dcb.");
|
fprintf(stderr, "\t..done\nAllocated dcb.");
|
||||||
// TODO: Without running workers, the following will hang. As it does not
|
// TODO: Without running workers, the following will hang. As it does not
|
||||||
|
@ -59,7 +59,7 @@ static int test1()
|
|||||||
"testpoll : Initialise the polling system.");
|
"testpoll : Initialise the polling system.");
|
||||||
init_test_env(NULL);
|
init_test_env(NULL);
|
||||||
fprintf(stderr, "\t..done\nAdd a DCB");
|
fprintf(stderr, "\t..done\nAdd a DCB");
|
||||||
dcb = dcb_alloc(DCB_ROLE_CLIENT_HANDLER, dummy);
|
dcb = dcb_alloc(DCB_ROLE_CLIENT_HANDLER, dummy, NULL);
|
||||||
|
|
||||||
if (dcb == NULL)
|
if (dcb == NULL)
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ static void blr_start_master(void* data)
|
|||||||
|
|
||||||
pthread_mutex_unlock(&router->lock);
|
pthread_mutex_unlock(&router->lock);
|
||||||
|
|
||||||
DCB* client = dcb_alloc(DCB_ROLE_INTERNAL, NULL);
|
DCB* client = dcb_alloc(DCB_ROLE_INTERNAL, NULL, NULL);
|
||||||
|
|
||||||
/* Create fake 'client' DCB */
|
/* Create fake 'client' DCB */
|
||||||
if (client == NULL)
|
if (client == NULL)
|
||||||
|
Reference in New Issue
Block a user