fn wnbind_get(cmd: &str, arg: &str) -> NssResult<String> {
    let now = SystemTime::now();
    loop {
        if let Ok(elapsed) = now.elapsed() {
            if duration_millis(&elapsed) > MAX_TIMEOUT_MS {
                return Err(NssError::TryAgainLater);
            }
        }
        match wnbind_try(cmd, arg) {
            Ok(r) => {
                if r.contains(0 as char) {
                    debug!("wnbind answer contains a literal 0");
                    return Err(NssError::Unavailable);
                }
                return Ok(r);
            },
            res @ Err(NssError::NotFound) => return res,
            res @ Err(NssError::TryAgainLater) => return res,
            res @ Err(NssError::InsufficientBuffer) => return res,
            res @ Err(NssError::Unavailable) => return res,
            Err(NssError::TimedOut) => {},
            Err(NssError::TryAgainNow) => {
                if let Ok(elapsed) = now.elapsed() {
                    if duration_millis(&elapsed) + RETRY_DELAY_MS < MAX_TIMEOUT_MS {
                        sleep(Duration::from_millis(RETRY_DELAY_MS));
                    }
                }
            },
        }
    }
}
// call cmd_run and sleep/retry a few times if we fail.
call cmd_run and sleep/retry a few times if we fail.
call cmd_run and sleep / retry a few times if we fail .
fn wnbind_get(cmd: &str, arg: &str) -> NssResult<String> {
    let now = SystemTime::now();
    loop {
        if let Ok(elapsed) = now.elapsed() {
            if duration_millis(&elapsed) > MAX_TIMEOUT_MS {
                return Err(NssError::TryAgainLater);
            }
        }
        match wnbind_try(cmd, arg) {
            Ok(r) => {
                if r.contains(0 as char) {
                    debug!("wnbind answer contains a literal 0");
                    return Err(NssError::Unavailable);
                }
                return Ok(r);
            },
            res @ Err(NssError::NotFound) => return res,
            res @ Err(NssError::TryAgainLater) => return res,
            res @ Err(NssError::InsufficientBuffer) => return res,
            res @ Err(NssError::Unavailable) => return res,
            Err(NssError::TimedOut) => {},
            Err(NssError::TryAgainNow) => {
                if let Ok(elapsed) = now.elapsed() {
                    if duration_millis(&elapsed) + RETRY_DELAY_MS < MAX_TIMEOUT_MS {
                        sleep(Duration::from_millis(RETRY_DELAY_MS));
                    }
                }
            },
        }
    }
}
fn wnbind_get ( cmd : & str , arg : & str ) -> NssResult < String > { let now = SystemTime :: now ( ) ; loop { if let Ok ( elapsed ) = now . elapsed ( ) { if duration_millis ( & elapsed ) > MAX_TIMEOUT_MS { return Err ( NssError :: TryAgainLater ) ; } } match wnbind_try ( cmd , arg ) { Ok ( r ) => { if r . contains ( 0 as char ) { debug ! ( " " ) ; return Err ( NssError :: Unavailable ) ; } return Ok ( r ) ; } , res @ Err ( NssError :: NotFound ) => return res , res @ Err ( NssError :: TryAgainLater ) => return res , res @ Err ( NssError :: InsufficientBuffer ) => return res , res @ Err ( NssError :: Unavailable ) => return res , Err ( NssError :: TimedOut ) => { } , Err ( NssError :: TryAgainNow ) => { if let Ok ( elapsed ) = now . elapsed ( ) { if duration_millis ( & elapsed ) + RETRY_DELAY_MS < MAX_TIMEOUT_MS { sleep ( Duration :: from_millis ( RETRY_DELAY_MS ) ) ; } } } , } } }
call cmd_run and sleep/retry a few times if we fail.
call cmd_run and sleep / retry a few times if we fail .
cmd
&str
arg
&str