MXS-2196: Move DCB initialization into DCB constructor
More of the DCB initialization is now done in the DCB constructor. This makes the creation of new DCBs simpler but it can be even simpler. By passing the file descriptor that the DCB should use into the constructor almost all of the initialization would be done inside it. Also removed the unused path member variable.
This commit is contained in:
@ -168,6 +168,15 @@ DCB::DCB(dcb_role_t role, const SListener& listener, SERVICE* service)
|
||||
, service(service)
|
||||
, last_read(mxs_clock())
|
||||
{
|
||||
session_set_dummy(this);
|
||||
|
||||
// TODO: Remove DCB_ROLE_INTERNAL to always have a valid listener
|
||||
if (listener)
|
||||
{
|
||||
func = listener->protocol_func();
|
||||
authfunc = listener->auth_func();
|
||||
}
|
||||
|
||||
if (high_water && low_water)
|
||||
{
|
||||
dcb_add_callback(this, DCB_REASON_HIGH_WATER, downstream_throttle_callback, NULL);
|
||||
@ -201,7 +210,6 @@ DCB::~DCB()
|
||||
|
||||
MXS_FREE(remote);
|
||||
MXS_FREE(user);
|
||||
MXS_FREE(path);
|
||||
MXS_FREE(protocol);
|
||||
gwbuf_free(delayq);
|
||||
gwbuf_free(writeq);
|
||||
@ -1215,14 +1223,6 @@ void dcb_final_close(DCB* dcb)
|
||||
|
||||
MXS_DEBUG("Closed socket %d on dcb %p.", dcb->fd, dcb);
|
||||
}
|
||||
|
||||
if (dcb->path && (dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER))
|
||||
{
|
||||
if (unlink(dcb->path) != 0)
|
||||
{
|
||||
MXS_ERROR("Could not unlink %s: %s", dcb->path, mxs_strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -942,7 +942,6 @@ DCB* dcb_accept(const SListener& listener)
|
||||
}
|
||||
else
|
||||
{
|
||||
client_dcb->session = session_set_dummy(client_dcb);
|
||||
client_dcb->fd = c_sock;
|
||||
|
||||
// get client address
|
||||
@ -951,7 +950,6 @@ DCB* dcb_accept(const SListener& listener)
|
||||
// client address
|
||||
client_dcb->ip.ss_family = AF_UNIX;
|
||||
client_dcb->remote = MXS_STRDUP_A("localhost");
|
||||
client_dcb->path = MXS_STRDUP_A(listener->address());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -976,9 +974,6 @@ DCB* dcb_accept(const SListener& listener)
|
||||
}
|
||||
}
|
||||
|
||||
client_dcb->func = listener->protocol_func();
|
||||
client_dcb->authfunc = listener->auth_func();
|
||||
|
||||
/** Allocate DCB specific authentication data */
|
||||
if (client_dcb->authfunc.create
|
||||
&& (client_dcb->authenticator_data =
|
||||
|
Reference in New Issue
Block a user