diff --git a/.cargo/config.toml b/.cargo/config.toml index b0de92499..e69de29bb 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +0,0 @@ -[target.x86_64-unknown-linux-gnu] -linker = "/usr/bin/clang" -rustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"] diff --git a/pgdog-plugin/src/bindings.rs b/pgdog-plugin/src/bindings.rs index 561d24e5b..02951f5f7 100644 --- a/pgdog-plugin/src/bindings.rs +++ b/pgdog-plugin/src/bindings.rs @@ -37,7 +37,7 @@ pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; pub const __STDC_ISO_10646__: u32 = 201706; pub const __GNU_LIBRARY__: u32 = 6; pub const __GLIBC__: u32 = 2; -pub const __GLIBC_MINOR__: u32 = 42; +pub const __GLIBC_MINOR__: u32 = 41; pub const _SYS_CDEFS_H: u32 = 1; pub const __glibc_c99_flexarr_available: u32 = 1; pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; diff --git a/pgdog/src/auth/scram/server.rs b/pgdog/src/auth/scram/server.rs index 3cb6a3a36..546d545b4 100644 --- a/pgdog/src/auth/scram/server.rs +++ b/pgdog/src/auth/scram/server.rs @@ -50,10 +50,13 @@ use base64::prelude::*; impl AuthenticationProvider for UserPassword { fn get_password_for(&self, _user: &str) -> Option { - // TODO: This is slow. We should move it to its own thread pool. let iterations = 4096; let salt = rand::thread_rng().gen::<[u8; 16]>().to_vec(); - let hash = hash_password(&self.password, NonZeroU32::new(iterations).unwrap(), &salt); + // Perform the expensive PBKDF2 computation in a blocking section + // so that we don't stall the async runtime worker. + let hash = tokio::task::block_in_place(|| { + hash_password(&self.password, NonZeroU32::new(iterations).unwrap(), &salt) + }); Some(PasswordInfo::new(hash.to_vec(), iterations as u16, salt)) } } @@ -216,4 +219,13 @@ mod test { let info = hashed.get_password_for("user"); assert!(info.is_some()); } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_user_password_get_password_for_blocking_ok() { + let plain = UserPassword { + password: "secret".to_string(), + }; + let info = plain.get_password_for("user"); + assert!(info.is_some()); + } }