poll_add_db moved from dcb_connect to backend_dcb->func.connect()
This commit is contained in:
11
core/dcb.c
11
core/dcb.c
@ -263,9 +263,14 @@ DCB *ptr, *lptr;
|
|||||||
/**
|
/**
|
||||||
* Connect to a server
|
* Connect to a server
|
||||||
*
|
*
|
||||||
|
* This routine will create a server connection
|
||||||
|
* If succesful the new dcb will be put in
|
||||||
|
* epoll set by dcb->func.connect
|
||||||
|
*
|
||||||
* @param server The server to connect to
|
* @param server The server to connect to
|
||||||
* @param session The session this connection is being made for
|
* @param session The session this connection is being made for
|
||||||
* @param protocol The protocol module to use
|
* @param protocol The protocol module to use
|
||||||
|
* @return The new allocated dcb
|
||||||
*/
|
*/
|
||||||
DCB *
|
DCB *
|
||||||
dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||||
@ -294,10 +299,14 @@ GWPROTOCOL *funcs;
|
|||||||
server->name, server->port, dcb);
|
server->name, server->port, dcb);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The dcb will be addded into poll set by dcb->func.connect
|
||||||
|
*/
|
||||||
|
|
||||||
atomic_add(&server->stats.n_connections, 1);
|
atomic_add(&server->stats.n_connections, 1);
|
||||||
atomic_add(&server->stats.n_current, 1);
|
atomic_add(&server->stats.n_current, 1);
|
||||||
|
|
||||||
poll_add_dcb(dcb);
|
|
||||||
/*
|
/*
|
||||||
* We are now connected, the authentication etc will happen as
|
* We are now connected, the authentication etc will happen as
|
||||||
* part of the EPOLLOUT event that will be received once the connection
|
* part of the EPOLLOUT event that will be received once the connection
|
||||||
|
|||||||
@ -484,12 +484,25 @@ int gw_do_connect_to_backend(char *host, int port, MySQLProtocol *conn) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Assign so to the caller dcb, conn->descriptor */
|
||||||
|
|
||||||
|
conn->descriptor->fd = so;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the dcb in the poll set
|
||||||
|
*/
|
||||||
|
|
||||||
|
poll_add_dcb(conn->descriptor);
|
||||||
|
|
||||||
|
/* prepare for connect */
|
||||||
|
|
||||||
setipaddress(&serv_addr.sin_addr, host);
|
setipaddress(&serv_addr.sin_addr, host);
|
||||||
serv_addr.sin_port = htons(port);
|
serv_addr.sin_port = htons(port);
|
||||||
|
|
||||||
/* set NON BLOCKING here */
|
/* set NON BLOCKING here */
|
||||||
setnonblocking(so);
|
setnonblocking(so);
|
||||||
|
|
||||||
|
/* do the connect */
|
||||||
if ((rv = connect(so, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) < 0) {
|
if ((rv = connect(so, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) < 0) {
|
||||||
/* If connection is not yet completed just return 1 */
|
/* If connection is not yet completed just return 1 */
|
||||||
if (errno == EINPROGRESS) {
|
if (errno == EINPROGRESS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user