ids1024 / reis

Emulated input for Wayland, in Rust
MIT License
18 stars 2 forks source link

jinja template notes #1

Open whot opened 1 year ago

whot commented 1 year ago

Not an issue, but I can't comment on files themselves so feel free to close this any time:

ids1024 commented 1 year ago

Yeah, something like {{interface.basename}} could help.

you don't need to, if that ever happens error out and disconnect. you could skip until message.length and continue but why would you.

This else case is actually handling a new_id argument without an interface. Looks like the only instance of that is <arg name="object" type="new_id" interface_arg="interface_name" /> on the ei_device::interface event.

Otherwise yeah, things like this are protocol errors. I need to add an Error enum and add variants for various things.

not sure what you mean here but: any message parser function must read message.length bytes, but there may be more bytes sitting on the fd after that.

I need to check exactly how sendmsg and recvmsg on a Unix stream socket as far as partial reads, writes, and what happens with cmesgs in such cases...

And then there's also handling EINTR, which the sendmsg and recvmsg man pages say those functions can return. It looks like libei doesn't currently handle that, which at least in theory could be a problem.

ids1024 commented 1 year ago

Looks like libei also doesn't check the return value of sendmsg to make sure that all bytes were sent, and re-send remaining bytes if not all were. Which can also happen in certain cases. (Low level Unix functions like this are a pain to deal with...)

I guess if EINTR is returned, the same send should be repeated, while if it returns a length less than what it attempted to send, it should send the remaining bytes and not the cmesgs.

whot commented 1 year ago

strip_prefix: do you want this or something like this in the scanner? Maybe interface.basename or interface.plainname or something?

ftr: libei's main branch now supports interface.plainname

Looks like libei also doesn't check the return value of sendmsg to make sure that all bytes were sent, and re-send remaining bytes if not all were. Which can also happen in certain cases. (Low level Unix functions like this are a pain to deal with...)

yeah, a lot of that low-level part was written quickly so i'm hoping these things can get fixed over time. Having said that, I wonder how many of these instances occur in our expected use-cases. If this some web-related server library I'd be worried about it but on your average desktop?

ids1024 commented 1 year ago

EINTR only occurs if a signal occurs when the system call is being run. In most cases the ei client or server isn't receiving signals, and when it does is going to terminate anyway. (Depending on how signals are being used.)

I'm somewhat less sure when a partial write would occur with sendmsg in this context. The POSIX standard doesn't say so you'd have to check the implementation in the Linux kernel (and BSDs, etc.) to be sure.

So yeah, probably unlikely to actually be an issue, and not critical. But something that should be done more correctly.