Page MenuHomeFreeBSD

bhyve: close fd in rfb
AbandonedPublic

Authored by aokblast on Aug 7 2025, 3:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 13, 4:47 AM
Unknown Object (File)
Sat, Nov 8, 10:02 PM
Unknown Object (File)
Fri, Nov 7, 3:43 AM
Unknown Object (File)
Nov 2 2025, 3:54 AM
Unknown Object (File)
Oct 23 2025, 6:05 PM
Unknown Object (File)
Oct 19 2025, 12:17 PM
Unknown Object (File)
Oct 19 2025, 12:17 PM
Unknown Object (File)
Oct 19 2025, 12:17 PM
Subscribers

Details

Reviewers
markj
lwhsu
khng
Group Reviewers
bhyve
Summary

cfd may still be valid after reaching the 'done' label,
especially in cases like incorrect password authentication in VNC authentication step.
To ensure the connection is properly terminated, we manually close the fd.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 66062
Build 62945: arc lint + arc unit

Event Timeline

usr.sbin/bhyve/rfb.c
1194

This socket is closed in the caller.

Note that double-close can be dangerous, especially in a multi-threaded program, since the fd might be reused by a different thread in between the first and second close() calls.

aokblast added inline comments.
usr.sbin/bhyve/rfb.c
1194

Emm, you are right. I have this when I using builtin vnc viewer from the MacOS and it stucks when I type a wrong password. I try to add this and it works. Maybe it is because of other reason. I would close this patch right now. Sorry for the bothering!