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:
Zach Reizner 2017-08-02 14:34:29 -07:00 committed by chrome-bot
parent 174ce13e55
commit 3eddedd005

View file

@ -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.
///