dcb.c
: dcb_alloc switched malloc to calloc, dcb->fd is initialized to -1. : dcb_process_zombies return value of close(fd) is checked. Closed fds are stored to conn_open array. : dcb_connect assigns new fd only if backend connection succeeds. Dcb is added to poll set in the same way, only if connect succeed. gateway.c : conn_open array is initialized in main. For each created socket, a true is set to corresponding slot. Max. number of slots is 1024. mysql_client_server_protocol.h : gw_do_connect_to declaration mysql_backend.c : gw_create_backend_connection returns rv >= 0 and a protocol which is assigned to backend_dcb. In error, -1 is returned and fd is not set. mysql_client.c : conn_open array is kept up-to-date and protocol pointer is assigned also to dcb outside mysql_protocol_init. mysql_common.c : gw_do_connect_to_backend 3rd argument is pointer to fd, not protocol. dcb is added to poll set later in dcb_connect. skygw_debug.h : define conn_open[1024] array where open connections can be marked in debug build.
This commit is contained in:
@ -826,6 +826,9 @@ int gw_MySQLListener(
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
conn_open[l_so] = true;
|
||||
#endif
|
||||
listen_dcb->func.accept = gw_MySQLAccept;
|
||||
|
||||
return 1;
|
||||
@ -865,7 +868,6 @@ int gw_MySQLAccept(DCB *listener)
|
||||
}
|
||||
else if (eno == ENFILE)
|
||||
{
|
||||
|
||||
/**
|
||||
* Exceeded system's max. number of files limit.
|
||||
*/
|
||||
@ -879,8 +881,7 @@ int gw_MySQLAccept(DCB *listener)
|
||||
goto retry_accept;
|
||||
}
|
||||
else if (eno == EMFILE)
|
||||
{
|
||||
|
||||
{
|
||||
/**
|
||||
* Exceeded processes max. number of files limit.
|
||||
*/
|
||||
@ -893,7 +894,6 @@ int gw_MySQLAccept(DCB *listener)
|
||||
usleep(100*i*i++);
|
||||
goto retry_accept;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/**
|
||||
@ -913,7 +913,16 @@ int gw_MySQLAccept(DCB *listener)
|
||||
i = 0;
|
||||
|
||||
listener->stats.n_accepts++;
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
if (c_sock > 0) {
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
"%lu [gw_MySQLAccept] Accepted fd %d.",
|
||||
pthread_self(),
|
||||
c_sock);
|
||||
conn_open[c_sock] = true;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr,
|
||||
"Processing %i connection fd %i for listener %i\n",
|
||||
listener->stats.n_accepts,
|
||||
@ -940,6 +949,7 @@ int gw_MySQLAccept(DCB *listener)
|
||||
pthread_self());
|
||||
return 1;
|
||||
}
|
||||
client_dcb->protocol = protocol;
|
||||
// assign function poiters to "func" field
|
||||
memcpy(&client_dcb->func, &MyObject, sizeof(GWPROTOCOL));
|
||||
//send handshake to the client_dcb
|
||||
|
Reference in New Issue
Block a user