Skip to content

Commit

Permalink
fix hangs on authenticate
Browse files Browse the repository at this point in the history
  • Loading branch information
flaneur2020 committed Mar 3, 2022
1 parent c9e9360 commit 90c897e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ common-tracing = { path = "../common/tracing" }

# Github dependencies
cargo-license = { git = "https://github.com/datafuse-extras/cargo-license", rev = "f1ce4a2" }
msql-srv = { git = "https://github.com/datafuse-extras/msql-srv", rev = "70aa0b2" }
msql-srv = { git = "https://github.com/flaneur2020/msql-srv", rev = "6134ff" }
sqlparser = { git = "https://github.com/datafuse-extras/sqlparser-rs", rev = "472f5b6" }

# Crates.io dependencies
Expand Down
31 changes: 15 additions & 16 deletions query/src/servers/mysql/mysql_interactive_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct InteractiveWorker<W: std::io::Write> {
}

#[async_trait::async_trait]
impl<W: std::io::Write + Send> AsyncMysqlShim<W> for InteractiveWorker<W> {
impl<W: std::io::Write + Send + Sync> AsyncMysqlShim<W> for InteractiveWorker<W> {
type Error = ErrorCode;

fn version(&self) -> &str {
Expand All @@ -78,34 +78,33 @@ impl<W: std::io::Write + Send> AsyncMysqlShim<W> for InteractiveWorker<W> {
self.salt
}

fn authenticate(
async fn authenticate(
&self,
_auth_plugin: &str,
username: &[u8],
salt: &[u8],
auth_data: &[u8],
) -> bool {
let username = String::from_utf8_lossy(username);
let info = CertifiedInfo::create(&username, auth_data, &self.client_addr);
let client_addr = self.client_addr.clone();
let info = CertifiedInfo::create(&username, auth_data, &client_addr);

let authenticate = self.base.authenticate(salt, info);
futures::executor::block_on(async move {
match authenticate.await {
Ok(res) => res,
Err(failure) => {
tracing::error!(
"MySQL handler authenticate failed, \
match authenticate.await {
Ok(res) => res,
Err(failure) => {
tracing::error!(
"MySQL handler authenticate failed, \
user_name: {}, \
client_address: {}, \
failure_cause: {}",
username,
self.client_addr,
failure
);
false
}
username,
client_addr,
failure
);
false
}
})
}
}

async fn on_prepare<'a>(
Expand Down

0 comments on commit 90c897e

Please sign in to comment.