mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
sys_util: add Pollable impls for UnixDatagram and UnixStream
UnixDatagram and UnixStream are both wrappers around unix domain sockets which are often polled. TEST=None BUG=chromium:738638 Change-Id: Ib5572faf1d601b89b9fdd323f654ba04650b7600 Reviewed-on: https://chromium-review.googlesource.com/599041 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
parent
174ce13e55
commit
3eddedd005
1 changed files with 13 additions and 1 deletions
|
@ -2,7 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use std::os::unix::net::{UnixDatagram, UnixStream};
|
||||
|
||||
use libc::{nfds_t, pollfd, poll, POLLIN};
|
||||
|
||||
|
@ -18,6 +19,17 @@ pub unsafe trait Pollable {
|
|||
fn pollable_fd(&self) -> RawFd;
|
||||
}
|
||||
|
||||
unsafe impl Pollable for UnixStream {
|
||||
fn pollable_fd(&self) -> RawFd {
|
||||
self.as_raw_fd()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Pollable for UnixDatagram {
|
||||
fn pollable_fd(&self) -> RawFd {
|
||||
self.as_raw_fd()
|
||||
}
|
||||
}
|
||||
|
||||
/// Used to poll multiple `Pollable` objects at once.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue