[Bug 3049] ssh startup time on OSX is linear to _SC_OPEN_MAX

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Fri Aug 2 15:54:23 AEST 2019


https://bugzilla.mindrot.org/show_bug.cgi?id=3049

--- Comment #3 from likan_999.student at sina.com ---
Thanks for reviewing it. Good catch, the error case should fallback to
original implementation. For detecting table size change, I was
previously thinking the function will be called in single thread
situation (such as in ssh, at beginning) thus the fd table is not
possible to change. 

If we want to make it robust enough to handle the case where another
thread opens/closes the files between the two calls to proc_fdinfo (do
we have such case for openssh codebase?), it is incorrect the way the
refactored patch detects the table change. Here is the source code of
proc_pidinfo:
https://opensource.apple.com/source/xnu/xnu-2050.7.9/bsd/kern/proc_info.c

>From the code (function proc_pidfdlist), we can see if bufsize is not
large enough to hold all file descriptors, it only returns as many as
possible to be held in the buffer, without reporting any error, thus
won't be detected by comparing return value with NULL (actually, it is
not a good style to compare buffer size with NULL).

If we really want to detect the change of file descriptors, we need to
compare with the previous buffer size, if it is the same as previous
value, then it is possible new ones are added, thus we need to retry.
But IMHO, is this really needed? If yes, we also need to retry in the
fallback method.

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list