Fix #2 by blocking if more than 64 packets are collected

This commit is contained in:
Jeremy Soller
2018-01-29 21:53:39 -07:00
parent 4f2895f401
commit 416206e1db
3 changed files with 15 additions and 5 deletions
Generated
+5 -5
View File
@@ -1,14 +1,14 @@
[root]
[[package]]
name = "ptyd"
version = "0.1.0"
dependencies = [
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_syscall"
version = "0.1.31"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -16,9 +16,9 @@ name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
+4
View File
@@ -62,6 +62,10 @@ impl Resource for PtyMaster {
fn write(&self, buf: &[u8]) -> Result<usize> {
let mut pty = self.pty.borrow_mut();
if pty.mosi.len() >= 64 {
return Err(Error::new(EWOULDBLOCK));
}
pty.input(buf);
Ok(buf.len())
+6
View File
@@ -70,6 +70,11 @@ impl Resource for PtySlave {
fn write(&self, buf: &[u8]) -> Result<usize> {
if let Some(pty_lock) = self.pty.upgrade() {
let mut pty = pty_lock.borrow_mut();
if pty.miso.len() >= 64 {
return Err(Error::new(EWOULDBLOCK));
}
pty.output(buf);
Ok(buf.len())
@@ -81,6 +86,7 @@ impl Resource for PtySlave {
fn sync(&self) -> Result<usize> {
if let Some(pty_lock) = self.pty.upgrade() {
let mut pty = pty_lock.borrow_mut();
pty.miso.push_back(vec![1]);
Ok(0)