mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-14 02:50:47 +00:00
Merge pull request #63 from Stremio/claude/fix/server-reader-error-break
Some checks are pending
Continuous integration / test (push) Waiting to run
Some checks are pending
Continuous integration / test (push) Waiting to run
Fix server reader IO error loop
This commit is contained in:
commit
5632cd7dc4
1 changed files with 16 additions and 16 deletions
|
|
@ -85,10 +85,14 @@ impl StremioServer {
|
||||||
let http_endpoint = String::new();
|
let http_endpoint = String::new();
|
||||||
loop {
|
loop {
|
||||||
let mut buffer = [0; SRV_BUFFER_SIZE];
|
let mut buffer = [0; SRV_BUFFER_SIZE];
|
||||||
let on = stdout.read(&mut buffer[..]).unwrap_or(!0);
|
let on = match stdout.read(&mut buffer[..]) {
|
||||||
if on > buffer.len() {
|
Ok(0) => break,
|
||||||
continue;
|
Ok(n) => n,
|
||||||
}
|
Err(err) => {
|
||||||
|
eprintln!("server stdout read error: {err}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
std::io::stdout().write_all(&buffer).ok();
|
std::io::stdout().write_all(&buffer).ok();
|
||||||
let string_data = String::from_utf8_lossy(&buffer[..on]);
|
let string_data = String::from_utf8_lossy(&buffer[..on]);
|
||||||
{
|
{
|
||||||
|
|
@ -116,10 +120,6 @@ impl StremioServer {
|
||||||
.collect::<Vec<&str>>()
|
.collect::<Vec<&str>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
};
|
};
|
||||||
if on == 0 {
|
|
||||||
// Server terminated
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -128,10 +128,14 @@ impl StremioServer {
|
||||||
let err_thread = thread::spawn(move || {
|
let err_thread = thread::spawn(move || {
|
||||||
let mut buffer = [0; SRV_BUFFER_SIZE];
|
let mut buffer = [0; SRV_BUFFER_SIZE];
|
||||||
loop {
|
loop {
|
||||||
let en = stderr.read(&mut buffer[..]).unwrap_or(!0);
|
let en = match stderr.read(&mut buffer[..]) {
|
||||||
if en > buffer.len() {
|
Ok(0) => break,
|
||||||
continue;
|
Ok(n) => n,
|
||||||
}
|
Err(err) => {
|
||||||
|
eprintln!("server stderr read error: {err}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
std::io::stderr().write_all(&buffer).ok();
|
std::io::stderr().write_all(&buffer).ok();
|
||||||
let string_data = String::from_utf8_lossy(&buffer[..en]);
|
let string_data = String::from_utf8_lossy(&buffer[..en]);
|
||||||
// eprint!("{:?}", &buffer);
|
// eprint!("{:?}", &buffer);
|
||||||
|
|
@ -148,10 +152,6 @@ impl StremioServer {
|
||||||
.collect::<Vec<&str>>()
|
.collect::<Vec<&str>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
};
|
};
|
||||||
if en == 0 {
|
|
||||||
// Server terminated
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
out_thread.join().ok();
|
out_thread.join().ok();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue