Skip to content

add some log messages to help troubleshooting #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/lens-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ fn main() -> Result<()> {

let mut server = Server::listen();

info!("Loading library...");

let library = unsafe { LensLibrary::new(dll_path, (2448, 2448))? };

info!("Listening for requests...");

loop {
let req = server.recv().context("failed to read request")?;
match req {
Expand Down
5 changes: 5 additions & 0 deletions crates/lens-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub enum Error {
MissingPipe,
#[error("failed to ping server")]
PingFailed,
#[error("Invalid size of message (is the pipeline really speaking lens?): {0}")]
InvalidMessageSize(u32),
}
type Result<T, E = Error> = result::Result<T, E>;

Expand Down Expand Up @@ -204,6 +206,9 @@ pub fn read_message(read: &mut impl Read) -> Result<Vec<u8>> {
let mut len_buf = [0; 4];
read.read_exact(&mut len_buf)?;
let len = u32::from_be_bytes(len_buf);
if len < 0 || len > 0xFFFFFF {
return Err(Error::InvalidMessageSize(len));
}
// This protocol isn't talkative, its ok to allocate here.
let mut data = vec![0; len as usize];
read.read_exact(&mut data)?;
Expand Down