On Sun, Oct 8, 2023 at 9:10 PM Noah Misch <n...@leadboat.com> wrote:

>
> I didn't think of any phrasing that clearly explained things without the
> reader consulting the code.  I considered these:
>
>   "socket file descriptor out of range: %d" [what range?]
>
>
Quick drive-by...but it seems that < 0 is a distinctly different problem
than exceeding FD_SETSIZE.  I'm unsure what would cause the former but the
error for the later seems like:

error: "Requested socket file descriptor %d exceeds connection limit of
%d", fd, FD_SETSIZE-1
hint: Reduce the requested number of concurrent connections

In short, the concept of range doesn't seem applicable here.  There is an
error state at the max, and some invalid system state condition where the
position within a set is somehow negative.  These should be separated -
with the < 0 check happening first.

And apparently this condition isn't applicable when dealing with jobs in
connect_slot?  Also, I see that for connections we immediately issue FD_SET
so this check on the boundary of the file descriptor makes sense.  But the
remaining code in connect_slot doesn't involve FD_SET so the test for the
file descriptor falling within its maximum seems to be coming out of
nowhere.  Likely this is all good, and the lack of symmetry is just due to
the natural progressive development of the code, but it stands out to the
uninitiated looking at this patch.

David J.

Reply via email to