in squangle/mysql_client/AsyncConnectionPool.cpp [949:985]
void ConnectPoolOperation::connectionCallback(
std::unique_ptr<MysqlPooledHolder> mysql_conn) {
DCHECK(client()->getEventBase()->isInEventBaseThread());
if (!mysql_conn) {
LOG(DFATAL) << "Unexpected error";
completeOperation(OperationResult::Failed);
return;
}
if (mysql_errno_) {
LOG_EVERY_N(ERROR, 1000)
<< "Connection pool callback was called with mysql err: "
<< mysql_errno_;
completeOperation(OperationResult::Failed);
return;
}
conn()->socketHandler()->changeHandlerFD(folly::NetworkSocket::fromFd(
mysql_get_socket_descriptor(mysql_conn->mysql())));
conn()->setMysqlConnectionHolder(std::move(mysql_conn));
conn()->setConnectionOptions(getConnectionOptions());
auto pool = pool_;
conn()->setConnectionDyingCallback(
[pool](std::unique_ptr<MysqlConnectionHolder> mysql_conn) {
auto shared_pool = pool.lock();
if (shared_pool) {
shared_pool->recycleMysqlConnection(std::move(mysql_conn));
}
});
if (conn()->mysql()) {
attemptSucceeded(OperationResult::Succeeded);
} else {
VLOG(2) << "Error: Failed to acquire connection";
attemptFailed(OperationResult::Failed);
}
}