Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions grpc/src/client/load_balancing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::{
fmt::{Debug, Display},
hash::{Hash, Hasher},
ops::{Add, Sub},
ptr::addr_eq,
sync::{
atomic::{AtomicI64, Ordering::Relaxed},
Arc, Mutex, Weak,
Expand Down Expand Up @@ -456,21 +457,13 @@ impl WeakSubchannel {

impl Hash for WeakSubchannel {
fn hash<H: Hasher>(&self, state: &mut H) {
if let Some(strong) = self.upgrade() {
return strong.dyn_hash(&mut Box::new(state as &mut dyn Hasher));
}
panic!("WeakSubchannel is not valid");
(self.0.as_ptr() as *const () as usize).hash(state);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels really weird but I guess its okay lol

}
}

impl PartialEq for WeakSubchannel {
fn eq(&self, other: &Self) -> bool {
if let Some(strong_self) = self.upgrade() {
if let Some(strong_other) = other.upgrade() {
return strong_self.dyn_eq(&Box::new(&strong_other as &dyn Any));
}
}
false
addr_eq(self.0.as_ptr(), other.0.as_ptr())
}
}

Expand Down
Loading