You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The various UnixStream implementations currently use a fixed size for the internal queue of file descriptors. This is current fixed at 2, though there is no particularly good reasons for this value.
The constrains on the size of the internal queue are as follows:
it should be fairly small (at least by default) because it is used to calculate the size of an array allocated on the stack
it should be the same on both sides of the "fd passing" (assuming both processes use this library)
The reason for the second constraint is to try to avoid the control data being truncated in the underlying call to recvmsg. This crate treats this occurrence as an error though the call to recvmsg implements it as a flag set on the msghdr structure passed as a parameter.
The second constraint also makes it a breaking change to increment the current fixed value across the board because you could end up with the sending side using a larger fixed value than the receiving side which would risk errors due to the control data being truncated on the underlying call to recvmsg.
The proposed (and non-breaking) change to allow users of the crate to have a larger (though still fixed) queue size is to make the various UnixStream implementations rely on a const generic parameter for the queue size (which would default to the current 2 to keep the change non-breaking). The proposed interface is:
The design presented above leads to an error on stable Rust with the use of the generic const parameter N in the calculation needed for the stack array size (which ultimately ends with a call to the now const fnlibc::CMSG_SPACE). This error goes away with the incompletely implement #![feature(generic_const_exprs)] on nightly so it may eventually be possible to use a stack array for this purpose.
As an interim solution (until #![feature(generic_const_exprs)] is stabilized) I will try a solution using smallvec instead of a stack array.
Add a SIZE generic const to BiQueue which defaults to
DEFAULT_FD_QUEUE_SIZE (which is set to 2). This SIZE is used for the
length of the inbound and outbound queues of fd's. It is also used for
the size of the CMsgBuffer used as a part of the calls to recvmsg and
sendmsg wrapped through MsgHdr.
The value of DEFAULT_FD_QUEUE_SIZE is chosen to match the old value of
BiQueue::FD_QUEUE_SIZE to prevent a breaking change.
Currently CMsgBuffer is a SmallVec with the size of the inline part
of the vector based on DEFAULT_FD_QUEUE_SIZE (and not on SIZE).
Current limitations in Rust prevent basing this on SIZE (though that
may change if #![feature(generic_const_exprs)] is stabalized).
This is part of #55.
The various
UnixStream
implementations currently use a fixed size for the internal queue of file descriptors. This is current fixed at 2, though there is no particularly good reasons for this value.The constrains on the size of the internal queue are as follows:
The reason for the second constraint is to try to avoid the control data being truncated in the underlying call to
recvmsg
. This crate treats this occurrence as an error though the call torecvmsg
implements it as a flag set on themsghdr
structure passed as a parameter.The second constraint also makes it a breaking change to increment the current fixed value across the board because you could end up with the sending side using a larger fixed value than the receiving side which would risk errors due to the control data being truncated on the underlying call to
recvmsg
.The proposed (and non-breaking) change to allow users of the crate to have a larger (though still fixed) queue size is to make the various
UnixStream
implementations rely on a const generic parameter for the queue size (which would default to the current 2 to keep the change non-breaking). The proposed interface is:It may be desirable to increase
DEFAULT_FD_QUEUE_SIZE
for the next major release but for now we would keep it at 2 to avoid a breaking change.The text was updated successfully, but these errors were encountered: