fix ordering issue in refcount increment for trng

want to add to the reference before claiming, so if
a drop happens while we're claiming we don't get
the connection being destroyed in the race.
This commit is contained in:
bunnie 2022-07-14 03:50:30 +08:00
parent 239cdef1ef
commit 18abf7ca0a

View file

@ -12,10 +12,10 @@ pub struct Trng {
}
impl Trng {
pub fn new(xns: &xous_names::XousNames) -> Result<Self, xous::Error> {
REFCOUNT.fetch_add(1, Ordering::Relaxed);
let conn = xns
.request_connection_blocking(api::SERVER_NAME_TRNG)
.expect("Can't connect to TRNG server");
REFCOUNT.fetch_add(1, Ordering::Relaxed);
Ok(Trng {
conn,
error_sid: None,