Switch remaining clock_gettimes to libredox.
This commit is contained in:
+5
-6
@@ -11,6 +11,7 @@ use std::str::FromStr;
|
||||
use std::rc::Rc;
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
use libredox::flag;
|
||||
use syscall::data::TimeSpec;
|
||||
use syscall::{Error as SyscallError, EventFlags as SyscallEventFlags, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
|
||||
use syscall;
|
||||
@@ -430,9 +431,8 @@ impl SchemeMut for Dnsd<'_> {
|
||||
}
|
||||
let fd = self.next_fd;
|
||||
self.next_fd += 1;
|
||||
let mut cur_time = TimeSpec::default();
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut cur_time)?;
|
||||
let dns_file = self.domains.file_from_domain(&domain, fd, &cur_time, self.queue);
|
||||
let cur_time = libredox::call::clock_gettime(flag::CLOCK_MONOTONIC)?;
|
||||
let dns_file = self.domains.file_from_domain(&domain, fd, &TimeSpec { tv_sec: cur_time.tv_sec, tv_nsec: cur_time.tv_nsec as i32 }, self.queue);
|
||||
self.files.insert(fd, dns_file);
|
||||
trace!("Open {} {}", &domain, fd);
|
||||
Ok(fd)
|
||||
@@ -462,11 +462,10 @@ impl SchemeMut for Dnsd<'_> {
|
||||
.get_mut(&fd)
|
||||
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
|
||||
|
||||
let mut cur_time = TimeSpec::default();
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut cur_time)?;
|
||||
let cur_time = libredox::call::clock_gettime(flag::CLOCK_MONOTONIC)?;
|
||||
|
||||
if let DnsFile::Waiting { ref domain } = *file {
|
||||
*file = self.domains.file_from_domain(domain, fd, &cur_time, self.queue);
|
||||
*file = self.domains.file_from_domain(domain, fd, &TimeSpec { tv_sec: cur_time.tv_sec, tv_nsec: cur_time.tv_nsec as i32 }, self.queue);
|
||||
}
|
||||
|
||||
match *file {
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::ops::DerefMut;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
|
||||
use libredox::flag::CLOCK_MONOTONIC;
|
||||
use libredox::flag::{self, CLOCK_MONOTONIC};
|
||||
use syscall::{self, KSMSG_CANCEL};
|
||||
use syscall::data::TimeSpec;
|
||||
use syscall::flag::{EVENT_READ, EVENT_WRITE};
|
||||
@@ -317,9 +317,8 @@ where
|
||||
}
|
||||
|
||||
pub fn notify_sockets(&mut self) -> Result<()> {
|
||||
let mut cur_time = TimeSpec::default();
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut cur_time)
|
||||
.map_err(|e| Error::from_syscall_error(e, "Can't get time"))?;
|
||||
let cur_time = libredox::call::clock_gettime(flag::CLOCK_MONOTONIC)
|
||||
.map_err(|e| Error::from_syscall_error(e.into(), "Can't get time"))?;
|
||||
|
||||
// Notify non-blocking sockets
|
||||
for (&fd, ref mut file) in &mut self.files {
|
||||
@@ -345,7 +344,7 @@ where
|
||||
Some(until)
|
||||
if (until.tv_sec < cur_time.tv_sec
|
||||
|| (until.tv_sec == cur_time.tv_sec
|
||||
&& until.tv_nsec < cur_time.tv_nsec)) =>
|
||||
&& i64::from(until.tv_nsec) < cur_time.tv_nsec)) =>
|
||||
{
|
||||
self.wait_queue.remove(i);
|
||||
packet.a = (-syscall::ETIMEDOUT) as usize;
|
||||
|
||||
Reference in New Issue
Block a user